Java 类org.springframework.beans.Mergeable 实例源码

项目:lams    文件:ConstructorArgumentValues.java   
/**
 * Add a generic argument value, merging the new value (typically a collection)
 * with the current value if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeGenericArgumentValue(ValueHolder newValue) {
    if (newValue.getName() != null) {
        for (Iterator<ValueHolder> it = this.genericArgumentValues.iterator(); it.hasNext();) {
            ValueHolder currentValue = it.next();
            if (newValue.getName().equals(currentValue.getName())) {
                if (newValue.getValue() instanceof Mergeable) {
                    Mergeable mergeable = (Mergeable) newValue.getValue();
                    if (mergeable.isMergeEnabled()) {
                        newValue.setValue(mergeable.merge(currentValue.getValue()));
                    }
                }
                it.remove();
            }
        }
    }
    this.genericArgumentValues.add(newValue);
}
项目:spring4-understanding    文件:ConstructorArgumentValues.java   
/**
 * Add a generic argument value, merging the new value (typically a collection)
 * with the current value if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeGenericArgumentValue(ValueHolder newValue) {
    if (newValue.getName() != null) {
        for (Iterator<ValueHolder> it = this.genericArgumentValues.iterator(); it.hasNext();) {
            ValueHolder currentValue = it.next();
            if (newValue.getName().equals(currentValue.getName())) {
                if (newValue.getValue() instanceof Mergeable) {
                    Mergeable mergeable = (Mergeable) newValue.getValue();
                    if (mergeable.isMergeEnabled()) {
                        newValue.setValue(mergeable.merge(currentValue.getValue()));
                    }
                }
                it.remove();
            }
        }
    }
    this.genericArgumentValues.add(newValue);
}
项目:spring    文件:ConstructorArgumentValues.java   
/**
 * Add a generic argument value, merging the new value (typically a collection)
 * with the current value if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeGenericArgumentValue(ValueHolder newValue) {
    if (newValue.getName() != null) {
        for (Iterator<ValueHolder> it = this.genericArgumentValues.iterator(); it.hasNext();) {
            ValueHolder currentValue = it.next();
            if (newValue.getName().equals(currentValue.getName())) {
                if (newValue.getValue() instanceof Mergeable) {
                    Mergeable mergeable = (Mergeable) newValue.getValue();
                    if (mergeable.isMergeEnabled()) {
                        newValue.setValue(mergeable.merge(currentValue.getValue()));
                    }
                }
                it.remove();
            }
        }
    }
    this.genericArgumentValues.add(newValue);
}
项目:class-guard    文件:ConstructorArgumentValues.java   
/**
 * Add a generic argument value, merging the new value (typically a collection)
 * with the current value if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeGenericArgumentValue(ValueHolder newValue) {
    if (newValue.getName() != null) {
        for (Iterator<ValueHolder> it = this.genericArgumentValues.iterator(); it.hasNext();) {
            ValueHolder currentValue = it.next();
            if (newValue.getName().equals(currentValue.getName())) {
                if (newValue.getValue() instanceof Mergeable) {
                    Mergeable mergeable = (Mergeable) newValue.getValue();
                    if (mergeable.isMergeEnabled()) {
                        newValue.setValue(mergeable.merge(currentValue.getValue()));
                    }
                }
                it.remove();
            }
        }
    }
    this.genericArgumentValues.add(newValue);
}
项目:gemini.blueprint    文件:ComponentMetadataFactory.java   
private static void processBeanMetadata(BeanMetadataElement metadata, Collection<ComponentMetadata> to) {
    if (metadata instanceof BeanDefinition) {
        processBeanDefinition((BeanDefinition) metadata, to);
    }

    else if (metadata instanceof BeanDefinitionHolder) {
        BeanDefinitionHolder bh = (BeanDefinitionHolder) metadata;
        processBeanDefinition(bh.getBeanDefinition(), to);
    }

    else if (metadata instanceof Mergeable && metadata instanceof Iterable) {
        processIterable((Iterable) metadata, to);
    }
}
项目:lams    文件:ConstructorArgumentValues.java   
/**
 * Add an argument value for the given index in the constructor argument list,
 * merging the new value (typically a collection) with the current value
 * if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param key the index in the constructor argument list
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeIndexedArgumentValue(Integer key, ValueHolder newValue) {
    ValueHolder currentValue = this.indexedArgumentValues.get(key);
    if (currentValue != null && newValue.getValue() instanceof Mergeable) {
        Mergeable mergeable = (Mergeable) newValue.getValue();
        if (mergeable.isMergeEnabled()) {
            newValue.setValue(mergeable.merge(currentValue.getValue()));
        }
    }
    this.indexedArgumentValues.put(key, newValue);
}
项目:spring4-understanding    文件:ConstructorArgumentValues.java   
/**
 * Add an argument value for the given index in the constructor argument list,
 * merging the new value (typically a collection) with the current value
 * if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param key the index in the constructor argument list
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeIndexedArgumentValue(Integer key, ValueHolder newValue) {
    ValueHolder currentValue = this.indexedArgumentValues.get(key);
    if (currentValue != null && newValue.getValue() instanceof Mergeable) {
        Mergeable mergeable = (Mergeable) newValue.getValue();
        if (mergeable.isMergeEnabled()) {
            newValue.setValue(mergeable.merge(currentValue.getValue()));
        }
    }
    this.indexedArgumentValues.put(key, newValue);
}
项目:spring    文件:ConstructorArgumentValues.java   
/**
 * Add an argument value for the given index in the constructor argument list,
 * merging the new value (typically a collection) with the current value
 * if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param key the index in the constructor argument list
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeIndexedArgumentValue(Integer key, ValueHolder newValue) {
    ValueHolder currentValue = this.indexedArgumentValues.get(key);
    if (currentValue != null && newValue.getValue() instanceof Mergeable) {
        Mergeable mergeable = (Mergeable) newValue.getValue();
        if (mergeable.isMergeEnabled()) {
            newValue.setValue(mergeable.merge(currentValue.getValue()));
        }
    }
    this.indexedArgumentValues.put(key, newValue);
}
项目:class-guard    文件:MockMvc.java   
/**
 * Perform a request and return a type that allows chaining further
 * actions, such as asserting expectations, on the result.
 *
 * @param requestBuilder used to prepare the request to execute;
 * see static factory methods in
 * {@link org.springframework.test.web.servlet.request.MockMvcRequestBuilders}
 *
 * @return an instance of {@link ResultActions}; never {@code null}
 *
 * @see org.springframework.test.web.servlet.request.MockMvcRequestBuilders
 * @see org.springframework.test.web.servlet.result.MockMvcResultMatchers
 */
public ResultActions perform(RequestBuilder requestBuilder) throws Exception {

    if (this.defaultRequestBuilder != null) {
        if (requestBuilder instanceof Mergeable) {
            requestBuilder = (RequestBuilder) ((Mergeable) requestBuilder).merge(this.defaultRequestBuilder);
        }
    }

    MockHttpServletRequest request = requestBuilder.buildRequest(this.servletContext);
    MockHttpServletResponse response = new MockHttpServletResponse();

    final MvcResult mvcResult = new DefaultMvcResult(request, response);
    request.setAttribute(MVC_RESULT_ATTRIBUTE, mvcResult);

    MockFilterChain filterChain = new MockFilterChain(this.servlet, this.filters);
    filterChain.doFilter(request, response);

    applyDefaultResultActions(mvcResult);

    return new ResultActions() {

        public ResultActions andExpect(ResultMatcher matcher) throws Exception {
            matcher.match(mvcResult);
            return this;
        }

        public ResultActions andDo(ResultHandler printer) throws Exception {
            printer.handle(mvcResult);
            return this;
        }

        public MvcResult andReturn() {
            return mvcResult;
        }
    };
}
项目:class-guard    文件:ConstructorArgumentValues.java   
/**
 * Add an argument value for the given index in the constructor argument list,
 * merging the new value (typically a collection) with the current value
 * if demanded: see {@link org.springframework.beans.Mergeable}.
 * @param key the index in the constructor argument list
 * @param newValue the argument value in the form of a ValueHolder
 */
private void addOrMergeIndexedArgumentValue(Integer key, ValueHolder newValue) {
    ValueHolder currentValue = this.indexedArgumentValues.get(key);
    if (currentValue != null && newValue.getValue() instanceof Mergeable) {
        Mergeable mergeable = (Mergeable) newValue.getValue();
        if (mergeable.isMergeEnabled()) {
            newValue.setValue(mergeable.merge(currentValue.getValue()));
        }
    }
    this.indexedArgumentValues.put(key, newValue);
}
项目:spring4-understanding    文件:MockMvc.java   
/**
 * Perform a request and return a type that allows chaining further
 * actions, such as asserting expectations, on the result.
 *
 * @param requestBuilder used to prepare the request to execute;
 * see static factory methods in
 * {@link org.springframework.test.web.servlet.request.MockMvcRequestBuilders}
 *
 * @return an instance of {@link ResultActions}; never {@code null}
 *
 * @see org.springframework.test.web.servlet.request.MockMvcRequestBuilders
 * @see org.springframework.test.web.servlet.result.MockMvcResultMatchers
 */
public ResultActions perform(RequestBuilder requestBuilder) throws Exception {

    if (this.defaultRequestBuilder != null) {
        if (requestBuilder instanceof Mergeable) {
            requestBuilder = (RequestBuilder) ((Mergeable) requestBuilder).merge(this.defaultRequestBuilder);
        }
    }

    MockHttpServletRequest request = requestBuilder.buildRequest(this.servletContext);
    MockHttpServletResponse response = new MockHttpServletResponse();

    if (requestBuilder instanceof SmartRequestBuilder) {
        request = ((SmartRequestBuilder) requestBuilder).postProcessRequest(request);
    }

    final MvcResult mvcResult = new DefaultMvcResult(request, response);
    request.setAttribute(MVC_RESULT_ATTRIBUTE, mvcResult);

    RequestAttributes previousAttributes = RequestContextHolder.getRequestAttributes();
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request, response));

    MockFilterChain filterChain = new MockFilterChain(this.servlet, this.filters);
    filterChain.doFilter(request, response);

    if (DispatcherType.ASYNC.equals(request.getDispatcherType()) &&
            request.getAsyncContext() != null & !request.isAsyncStarted()) {

        request.getAsyncContext().complete();
    }

    applyDefaultResultActions(mvcResult);

    RequestContextHolder.setRequestAttributes(previousAttributes);

    return new ResultActions() {

        @Override
        public ResultActions andExpect(ResultMatcher matcher) throws Exception {
            matcher.match(mvcResult);
            return this;
        }

        @Override
        public ResultActions andDo(ResultHandler handler) throws Exception {
            handler.handle(mvcResult);
            return this;
        }

        @Override
        public MvcResult andReturn() {
            return mvcResult;
        }
    };
}