Prefer Collections.addAll call with array over Set.addAll(Arrays.asList)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +18,7 @@ package org.springframework.context.annotation;
|
|||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -114,7 +114,7 @@ class ComponentScanAnnotationParser {
|
|||||||
for (String pkg : basePackagesArray) {
|
for (String pkg : basePackagesArray) {
|
||||||
String[] tokenized = StringUtils.tokenizeToStringArray(this.environment.resolvePlaceholders(pkg),
|
String[] tokenized = StringUtils.tokenizeToStringArray(this.environment.resolvePlaceholders(pkg),
|
||||||
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
|
ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
|
||||||
basePackages.addAll(Arrays.asList(tokenized));
|
Collections.addAll(basePackages, tokenized);
|
||||||
}
|
}
|
||||||
for (Class<?> clazz : componentScan.getClassArray("basePackageClasses")) {
|
for (Class<?> clazz : componentScan.getClassArray("basePackageClasses")) {
|
||||||
basePackages.add(ClassUtils.getPackageName(clazz));
|
basePackages.add(ClassUtils.getPackageName(clazz));
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package org.springframework.jmx.export;
|
package org.springframework.jmx.export;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -321,7 +321,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
|||||||
*/
|
*/
|
||||||
public void setExcludedBeans(String... excludedBeans) {
|
public void setExcludedBeans(String... excludedBeans) {
|
||||||
this.excludedBeans.clear();
|
this.excludedBeans.clear();
|
||||||
this.excludedBeans.addAll(Arrays.asList(excludedBeans));
|
Collections.addAll(this.excludedBeans, excludedBeans);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -868,9 +868,9 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
|||||||
private void autodetect(Map<String, Object> beans, AutodetectCallback callback) {
|
private void autodetect(Map<String, Object> beans, AutodetectCallback callback) {
|
||||||
Assert.state(this.beanFactory != null, "No BeanFactory set");
|
Assert.state(this.beanFactory != null, "No BeanFactory set");
|
||||||
Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
|
Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
|
||||||
beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
|
Collections.addAll(beanNames, this.beanFactory.getBeanDefinitionNames());
|
||||||
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
||||||
beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
|
Collections.addAll(beanNames, ((ConfigurableBeanFactory) this.beanFactory).getSingletonNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String beanName : beanNames) {
|
for (String beanName : beanNames) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.jndi.support;
|
package org.springframework.jndi.support;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -92,7 +92,7 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
|||||||
* (typically within the "java:comp/env/" namespace)
|
* (typically within the "java:comp/env/" namespace)
|
||||||
*/
|
*/
|
||||||
public void setShareableResources(String... shareableResources) {
|
public void setShareableResources(String... shareableResources) {
|
||||||
this.shareableResources.addAll(Arrays.asList(shareableResources));
|
Collections.addAll(this.shareableResources, shareableResources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +18,7 @@ package org.springframework.core;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -61,7 +61,7 @@ public abstract class MethodIntrospector {
|
|||||||
handlerTypes.add(targetType);
|
handlerTypes.add(targetType);
|
||||||
specificHandlerType = targetType;
|
specificHandlerType = targetType;
|
||||||
}
|
}
|
||||||
handlerTypes.addAll(Arrays.asList(targetType.getInterfaces()));
|
Collections.addAll(handlerTypes, targetType.getInterfaces());
|
||||||
|
|
||||||
for (Class<?> currentHandlerType : handlerTypes) {
|
for (Class<?> currentHandlerType : handlerTypes) {
|
||||||
final Class<?> targetClass = (specificHandlerType != null ? specificHandlerType : currentHandlerType);
|
final Class<?> targetClass = (specificHandlerType != null ? specificHandlerType : currentHandlerType);
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ public abstract class ClassUtils {
|
|||||||
|
|
||||||
Set<Class<?>> primitiveTypes = new HashSet<>(32);
|
Set<Class<?>> primitiveTypes = new HashSet<>(32);
|
||||||
primitiveTypes.addAll(primitiveWrapperTypeMap.values());
|
primitiveTypes.addAll(primitiveWrapperTypeMap.values());
|
||||||
primitiveTypes.addAll(Arrays.asList(boolean[].class, byte[].class, char[].class,
|
Collections.addAll(primitiveTypes, boolean[].class, byte[].class, char[].class,
|
||||||
double[].class, float[].class, int[].class, long[].class, short[].class));
|
double[].class, float[].class, int[].class, long[].class, short[].class);
|
||||||
primitiveTypes.add(void.class);
|
primitiveTypes.add(void.class);
|
||||||
for (Class<?> primitiveType : primitiveTypes) {
|
for (Class<?> primitiveType : primitiveTypes) {
|
||||||
primitiveTypeNameMap.put(primitiveType.getName(), primitiveType);
|
primitiveTypeNameMap.put(primitiveType.getName(), primitiveType);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -22,6 +22,7 @@ import java.lang.reflect.Proxy;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -137,7 +138,7 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (m1pl < m2pl ? -1 : (m1pl > m2pl ? 1 : 0));
|
return Integer.compare(m1pl, m2pl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,14 +229,14 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Also expose methods from java.lang.Class itself
|
// Also expose methods from java.lang.Class itself
|
||||||
result.addAll(Arrays.asList(getMethods(Class.class)));
|
Collections.addAll(result, getMethods(Class.class));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (Proxy.isProxyClass(type)) {
|
else if (Proxy.isProxyClass(type)) {
|
||||||
Set<Method> result = new LinkedHashSet<>();
|
Set<Method> result = new LinkedHashSet<>();
|
||||||
// Expose interface methods (not proxy-declared overrides) for proper vararg introspection
|
// Expose interface methods (not proxy-declared overrides) for proper vararg introspection
|
||||||
for (Class<?> ifc : type.getInterfaces()) {
|
for (Class<?> ifc : type.getInterfaces()) {
|
||||||
result.addAll(Arrays.asList(getMethods(ifc)));
|
Collections.addAll(result, getMethods(ifc));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.test.context.support;
|
package org.springframework.test.context.support;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ import org.springframework.test.context.ContextConfigurationAttributes;
|
|||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods for working with {@link ApplicationContextInitializer
|
* Utility methods for working with
|
||||||
* ApplicationContextInitializers}.
|
* {@link ApplicationContextInitializer ApplicationContextInitializers}.
|
||||||
*
|
*
|
||||||
* <p>Although {@code ApplicationContextInitializerUtils} was first introduced
|
* <p>Although {@code ApplicationContextInitializerUtils} was first introduced
|
||||||
* in Spring Framework 4.1, the initial implementations of methods in this class
|
* in Spring Framework 4.1, the initial implementations of methods in this class
|
||||||
@@ -46,21 +46,15 @@ abstract class ApplicationContextInitializerUtils {
|
|||||||
private static final Log logger = LogFactory.getLog(ApplicationContextInitializerUtils.class);
|
private static final Log logger = LogFactory.getLog(ApplicationContextInitializerUtils.class);
|
||||||
|
|
||||||
|
|
||||||
private ApplicationContextInitializerUtils() {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve the set of merged {@code ApplicationContextInitializer} classes for the
|
* Resolve the set of merged {@code ApplicationContextInitializer} classes for the
|
||||||
* supplied list of {@code ContextConfigurationAttributes}.
|
* supplied list of {@code ContextConfigurationAttributes}.
|
||||||
*
|
|
||||||
* <p>Note that the {@link ContextConfiguration#inheritInitializers inheritInitializers}
|
* <p>Note that the {@link ContextConfiguration#inheritInitializers inheritInitializers}
|
||||||
* flag of {@link ContextConfiguration @ContextConfiguration} will be taken into
|
* flag of {@link ContextConfiguration @ContextConfiguration} will be taken into
|
||||||
* consideration. Specifically, if the {@code inheritInitializers} flag is set to
|
* consideration. Specifically, if the {@code inheritInitializers} flag is set to
|
||||||
* {@code true} for a given level in the class hierarchy represented by the provided
|
* {@code true} for a given level in the class hierarchy represented by the provided
|
||||||
* configuration attributes, context initializer classes defined at the given level
|
* configuration attributes, context initializer classes defined at the given level
|
||||||
* will be merged with those defined in higher levels of the class hierarchy.
|
* will be merged with those defined in higher levels of the class hierarchy.
|
||||||
*
|
|
||||||
* @param configAttributesList the list of configuration attributes to process; must
|
* @param configAttributesList the list of configuration attributes to process; must
|
||||||
* not be {@code null} or <em>empty</em>; must be ordered <em>bottom-up</em>
|
* not be {@code null} or <em>empty</em>; must be ordered <em>bottom-up</em>
|
||||||
* (i.e., as if we were traversing up the class hierarchy)
|
* (i.e., as if we were traversing up the class hierarchy)
|
||||||
@@ -70,19 +64,15 @@ abstract class ApplicationContextInitializerUtils {
|
|||||||
*/
|
*/
|
||||||
static Set<Class<? extends ApplicationContextInitializer<?>>> resolveInitializerClasses(
|
static Set<Class<? extends ApplicationContextInitializer<?>>> resolveInitializerClasses(
|
||||||
List<ContextConfigurationAttributes> configAttributesList) {
|
List<ContextConfigurationAttributes> configAttributesList) {
|
||||||
Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be empty");
|
|
||||||
|
|
||||||
final Set<Class<? extends ApplicationContextInitializer<?>>> initializerClasses = //
|
Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes List must not be empty");
|
||||||
new HashSet<>();
|
Set<Class<? extends ApplicationContextInitializer<?>>> initializerClasses = new LinkedHashSet<>();
|
||||||
|
|
||||||
for (ContextConfigurationAttributes configAttributes : configAttributesList) {
|
for (ContextConfigurationAttributes configAttributes : configAttributesList) {
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace(String.format("Processing context initializers for context configuration attributes %s",
|
logger.trace("Processing context initializers for configuration attributes " + configAttributes);
|
||||||
configAttributes));
|
|
||||||
}
|
}
|
||||||
|
Collections.addAll(initializerClasses, configAttributes.getInitializers());
|
||||||
initializerClasses.addAll(Arrays.asList(configAttributes.getInitializers()));
|
|
||||||
|
|
||||||
if (!configAttributes.isInheritInitializers()) {
|
if (!configAttributes.isInheritInitializers()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
package org.springframework.test.web.servlet.htmlunit;
|
package org.springframework.test.web.servlet.htmlunit;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -65,9 +65,10 @@ public final class HostRequestMatcher implements WebRequestMatcher {
|
|||||||
* @param hosts the hosts to match on
|
* @param hosts the hosts to match on
|
||||||
*/
|
*/
|
||||||
public HostRequestMatcher(String... hosts) {
|
public HostRequestMatcher(String... hosts) {
|
||||||
this.hosts.addAll(Arrays.asList(hosts));
|
Collections.addAll(this.hosts, hosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(WebRequest request) {
|
public boolean matches(WebRequest request) {
|
||||||
URL url = request.getUrl();
|
URL url = request.getUrl();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.remoting.jaxws;
|
package org.springframework.remoting.jaxws;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -137,9 +137,9 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware,
|
|||||||
Assert.state(this.beanFactory != null, "No BeanFactory set");
|
Assert.state(this.beanFactory != null, "No BeanFactory set");
|
||||||
|
|
||||||
Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
|
Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
|
||||||
beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
|
Collections.addAll(beanNames, this.beanFactory.getBeanDefinitionNames());
|
||||||
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
if (this.beanFactory instanceof ConfigurableBeanFactory) {
|
||||||
beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
|
Collections.addAll(beanNames, ((ConfigurableBeanFactory) this.beanFactory).getSingletonNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String beanName : beanNames) {
|
for (String beanName : beanNames) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -118,7 +118,7 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me
|
|||||||
* @param resolvers the resolvers to add
|
* @param resolvers the resolvers to add
|
||||||
*/
|
*/
|
||||||
public void addFileExtensionResolvers(MediaTypeFileExtensionResolver... resolvers) {
|
public void addFileExtensionResolvers(MediaTypeFileExtensionResolver... resolvers) {
|
||||||
this.resolvers.addAll(Arrays.asList(resolvers));
|
Collections.addAll(this.resolvers, resolvers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.web.context.support;
|
package org.springframework.web.context.support;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
|||||||
*/
|
*/
|
||||||
public void register(Class<?>... annotatedClasses) {
|
public void register(Class<?>... annotatedClasses) {
|
||||||
Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified");
|
Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified");
|
||||||
this.annotatedClasses.addAll(Arrays.asList(annotatedClasses));
|
Collections.addAll(this.annotatedClasses, annotatedClasses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +164,7 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
|||||||
*/
|
*/
|
||||||
public void scan(String... basePackages) {
|
public void scan(String... basePackages) {
|
||||||
Assert.notEmpty(basePackages, "At least one base package must be specified");
|
Assert.notEmpty(basePackages, "At least one base package must be specified");
|
||||||
this.basePackages.addAll(Arrays.asList(basePackages));
|
Collections.addAll(this.basePackages, basePackages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.springframework.web.method.annotation;
|
package org.springframework.web.method.annotation;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -59,9 +58,9 @@ public class SessionAttributesHandler {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance for a controller type. Session attribute names and
|
* Create a new session attributes handler. Session attribute names and types
|
||||||
* types are extracted from the {@code @SessionAttributes} annotation, if
|
* are extracted from the {@code @SessionAttributes} annotation, if present,
|
||||||
* present, on the given type.
|
* on the given type.
|
||||||
* @param handlerType the controller type
|
* @param handlerType the controller type
|
||||||
* @param sessionAttributeStore used for session access
|
* @param sessionAttributeStore used for session access
|
||||||
*/
|
*/
|
||||||
@@ -69,15 +68,15 @@ public class SessionAttributesHandler {
|
|||||||
Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null");
|
Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null");
|
||||||
this.sessionAttributeStore = sessionAttributeStore;
|
this.sessionAttributeStore = sessionAttributeStore;
|
||||||
|
|
||||||
SessionAttributes annotation =
|
SessionAttributes ann = AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class);
|
||||||
AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class);
|
if (ann != null) {
|
||||||
if (annotation != null) {
|
Collections.addAll(this.attributeNames, ann.names());
|
||||||
this.attributeNames.addAll(Arrays.asList(annotation.names()));
|
Collections.addAll(this.attributeTypes, ann.types());
|
||||||
this.attributeTypes.addAll(Arrays.asList(annotation.types()));
|
|
||||||
}
|
}
|
||||||
this.knownAttributeNames.addAll(this.attributeNames);
|
this.knownAttributeNames.addAll(this.attributeNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the controller represented by this instance has declared any
|
* Whether the controller represented by this instance has declared any
|
||||||
* session attributes through an {@link SessionAttributes} annotation.
|
* session attributes through an {@link SessionAttributes} annotation.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.web.reactive.result.method.annotation;
|
package org.springframework.web.reactive.result.method.annotation;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -46,17 +45,16 @@ class SessionAttributesHandler {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance for a controller type. Session attribute names and
|
* Create a new session attributes handler. Session attribute names and types
|
||||||
* types are extracted from the {@code @SessionAttributes} annotation, if
|
* are extracted from the {@code @SessionAttributes} annotation, if present,
|
||||||
* present, on the given type.
|
* on the given type.
|
||||||
* @param handlerType the controller type
|
* @param handlerType the controller type
|
||||||
*/
|
*/
|
||||||
public SessionAttributesHandler(Class<?> handlerType) {
|
public SessionAttributesHandler(Class<?> handlerType) {
|
||||||
SessionAttributes annotation =
|
SessionAttributes ann = AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class);
|
||||||
AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class);
|
if (ann != null) {
|
||||||
if (annotation != null) {
|
Collections.addAll(this.attributeNames, ann.names());
|
||||||
this.attributeNames.addAll(Arrays.asList(annotation.names()));
|
Collections.addAll(this.attributeTypes, ann.types());
|
||||||
this.attributeTypes.addAll(Arrays.asList(annotation.types()));
|
|
||||||
}
|
}
|
||||||
this.knownAttributeNames.addAll(this.attributeNames);
|
this.knownAttributeNames.addAll(this.attributeNames);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user