diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java index c7575168899..4eb2ea9571e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -461,7 +461,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence } private void bindExplicitArguments(int numArgumentsLeftToBind) { - this.argumentBindings = new HashMap(); + this.argumentBindings = new HashMap<>(); int numExpectedArgumentNames = this.aspectJAdviceMethod.getParameterTypes().length; if (this.argumentNames.length != numExpectedArgumentNames) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java index 671951324b2..fbb8febba98 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,8 +130,8 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov private static final int STEP_REFERENCE_PCUT_BINDING = 7; private static final int STEP_FINISHED = 8; - private static final Set singleValuedAnnotationPcds = new HashSet(); - private static final Set nonReferencePointcutTokens = new HashSet(); + private static final Set singleValuedAnnotationPcds = new HashSet<>(); + private static final Set nonReferencePointcutTokens = new HashSet<>(); static { @@ -414,7 +414,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov *

Some more support from AspectJ in doing this exercise would be nice... :) */ private void maybeBindAnnotationsFromPointcutExpression() { - List varNames = new ArrayList(); + List varNames = new ArrayList<>(); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); for (int i = 0; i < tokens.length; i++) { String toMatch = tokens[i]; @@ -520,7 +520,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov + " unbound args at this(),target(),args() binding stage, with no way to determine between them"); } - List varNames = new ArrayList(); + List varNames = new ArrayList<>(); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); for (int i = 0; i < tokens.length; i++) { if (tokens[i].equals("this") || @@ -537,7 +537,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov else if (tokens[i].equals("args") || tokens[i].startsWith("args(")) { PointcutBody body = getPointcutBody(tokens, i); i += body.numTokensConsumed; - List candidateVarNames = new ArrayList(); + List candidateVarNames = new ArrayList<>(); maybeExtractVariableNamesFromArgs(body.text, candidateVarNames); // we may have found some var names that were bound in previous primitive args binding step, // filter them out... @@ -571,7 +571,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov + " unbound args at reference pointcut binding stage, with no way to determine between them"); } - List varNames = new ArrayList(); + List varNames = new ArrayList<>(); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); for (int i = 0; i < tokens.length; i++) { String toMatch = tokens[i]; @@ -683,7 +683,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov } if (numUnboundPrimitives == 1) { // Look for arg variable and bind it if we find exactly one... - List varNames = new ArrayList(); + List varNames = new ArrayList<>(); String[] tokens = StringUtils.tokenizeToStringArray(this.pointcutExpression, " "); for (int i = 0; i < tokens.length; i++) { if (tokens[i].equals("args") || tokens[i].startsWith("args(")) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java index 3cb26136890..eb2c0692c66 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ import org.springframework.util.StringUtils; public class AspectJExpressionPointcut extends AbstractExpressionPointcut implements ClassFilter, IntroductionAwareMethodMatcher, BeanFactoryAware { - private static final Set SUPPORTED_PRIMITIVES = new HashSet(); + private static final Set SUPPORTED_PRIMITIVES = new HashSet<>(); static { SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); @@ -112,7 +112,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut private transient PointcutExpression pointcutExpression; - private transient Map shadowMatchCache = new ConcurrentHashMap(32); + private transient Map shadowMatchCache = new ConcurrentHashMap<>(32); /** @@ -628,7 +628,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut // Initialize transient fields. // pointcutExpression will be initialized lazily by checkReadyToMatch() - this.shadowMatchCache = new ConcurrentHashMap(32); + this.shadowMatchCache = new ConcurrentHashMap<>(32); } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java index 98c74f7ad04..ab73caedb18 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -184,7 +184,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac private static AspectJAnnotation findAnnotation(Method method, Class toLookFor) { A result = AnnotationUtils.findAnnotation(method, toLookFor); if (result != null) { - return new AspectJAnnotation(result); + return new AspectJAnnotation<>(result); } else { return null; @@ -212,7 +212,7 @@ public abstract class AbstractAspectJAdvisorFactory implements AspectJAdvisorFac private static final String[] EXPRESSION_PROPERTIES = new String[] {"value", "pointcut"}; private static Map, AspectJAnnotationType> annotationTypes = - new HashMap, AspectJAnnotationType>(); + new HashMap<>(); static { annotationTypes.put(Pointcut.class,AspectJAnnotationType.AtPointcut); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java index dce613ef5df..8d0fd175ccb 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AnnotationAwareAspectJAutoProxyCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class AnnotationAwareAspectJAutoProxyCreator extends AspectJAwareAdvisorA *

Default is to consider all @AspectJ beans as eligible. */ public void setIncludePatterns(List patterns) { - this.includePatterns = new ArrayList(patterns.size()); + this.includePatterns = new ArrayList<>(patterns.size()); for (String patternText : patterns) { this.includePatterns.add(Pattern.compile(patternText)); } diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java index 4431dad0502..a485bcbc504 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ import org.springframework.util.ClassUtils; public class AspectJProxyFactory extends ProxyCreatorSupport { /** Cache for singleton aspect instances */ - private static final Map, Object> aspectCache = new HashMap, Object>(); + private static final Map, Object> aspectCache = new HashMap<>(); private final AspectJAdvisorFactory aspectFactory = new ReflectiveAspectJAdvisorFactory(); diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java index 5c9a7e7448b..665eb648fe7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/BeanFactoryAspectJAdvisorsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,10 +45,10 @@ public class BeanFactoryAspectJAdvisorsBuilder { private List aspectBeanNames; - private final Map> advisorsCache = new HashMap>(); + private final Map> advisorsCache = new HashMap<>(); private final Map aspectFactoryCache = - new HashMap(); + new HashMap<>(); /** @@ -85,8 +85,8 @@ public class BeanFactoryAspectJAdvisorsBuilder { synchronized (this) { aspectNames = this.aspectBeanNames; if (aspectNames == null) { - List advisors = new LinkedList(); - aspectNames = new LinkedList(); + List advisors = new LinkedList<>(); + aspectNames = new LinkedList<>(); String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, Object.class, true, false); for (String beanName : beanNames) { @@ -136,7 +136,7 @@ public class BeanFactoryAspectJAdvisorsBuilder { if (aspectNames.isEmpty()) { return Collections.emptyList(); } - List advisors = new LinkedList(); + List advisors = new LinkedList<>(); for (String aspectName : aspectNames) { List cachedAdvisors = this.advisorsCache.get(aspectName); if (cachedAdvisors != null) { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java index ce139f710df..49aaaababd7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,9 +72,9 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto private static final Comparator METHOD_COMPARATOR; static { - CompoundComparator comparator = new CompoundComparator(); - comparator.addComparator(new ConvertingComparator( - new InstanceComparator( + CompoundComparator comparator = new CompoundComparator<>(); + comparator.addComparator(new ConvertingComparator<>( + new InstanceComparator<>( Around.class, Before.class, After.class, AfterReturning.class, AfterThrowing.class), new Converter() { @Override @@ -84,7 +84,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto return (annotation != null ? annotation.getAnnotation() : null); } })); - comparator.addComparator(new ConvertingComparator( + comparator.addComparator(new ConvertingComparator<>( new Converter() { @Override public String convert(Method method) { @@ -106,7 +106,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto MetadataAwareAspectInstanceFactory lazySingletonAspectInstanceFactory = new LazySingletonAspectInstanceFactoryDecorator(aspectInstanceFactory); - List advisors = new LinkedList(); + List advisors = new LinkedList<>(); for (Method method : getAdvisorMethods(aspectClass)) { Advisor advisor = getAdvisor(method, lazySingletonAspectInstanceFactory, advisors.size(), aspectName); if (advisor != null) { @@ -132,7 +132,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto } private List getAdvisorMethods(Class aspectClass) { - final List methods = new LinkedList(); + final List methods = new LinkedList<>(); ReflectionUtils.doWithMethods(aspectClass, new ReflectionUtils.MethodCallback() { @Override public void doWith(Method method) throws IllegalArgumentException { diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java index edf729eb623..fbfaaa00220 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/autoproxy/AspectJAwareAdvisorAutoProxyCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx @SuppressWarnings("unchecked") protected List sortAdvisors(List advisors) { List partiallyComparableAdvisors = - new ArrayList(advisors.size()); + new ArrayList<>(advisors.size()); for (Advisor element : advisors) { partiallyComparableAdvisors.add( new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR)); @@ -76,7 +76,7 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx List sorted = PartialOrder.sort(partiallyComparableAdvisors); if (sorted != null) { - List result = new ArrayList(advisors.size()); + List result = new ArrayList<>(advisors.size()); for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) { result.add(pcAdvisor.getAdvisor()); } diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java b/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java index c2271500600..2088ada2b48 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AopConfigUtils.java @@ -54,7 +54,7 @@ public abstract class AopConfigUtils { /** * Stores the auto proxy creator classes in escalation order. */ - private static final List> APC_PRIORITY_LIST = new ArrayList>(); + private static final List> APC_PRIORITY_LIST = new ArrayList<>(); /** * Setup the escalation list. diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java b/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java index 95371f59b79..e84ecea24ec 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AspectJAutoProxyBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ class AspectJAutoProxyBeanDefinitionParser implements BeanDefinitionParser { } private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) { - ManagedList includePatterns = new ManagedList(); + ManagedList includePatterns = new ManagedList<>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); diff --git a/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java b/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java index 216fcbb448c..b929d9f4a9c 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/ConfigBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -199,8 +199,8 @@ class ConfigBeanDefinitionParser implements BeanDefinitionParser { try { this.parseState.push(new AspectEntry(aspectId, aspectName)); - List beanDefinitions = new ArrayList(); - List beanReferences = new ArrayList(); + List beanDefinitions = new ArrayList<>(); + List beanReferences = new ArrayList<>(); List declareParents = DomUtils.getChildElementsByTagName(aspectElement, DECLARE_PARENTS); for (int i = METHOD_INDEX; i < declareParents.size(); i++) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java index 7f366d56029..c267feca14a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public abstract class AbstractAdvisingBeanPostProcessor extends ProxyProcessorSu protected boolean beforeExistingAdvisors = false; - private final Map, Boolean> eligibleBeans = new ConcurrentHashMap, Boolean>(256); + private final Map, Boolean> eligibleBeans = new ConcurrentHashMap<>(256); /** diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java index 40940374d8d..77d08740d42 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java @@ -87,13 +87,13 @@ public class AdvisedSupport extends ProxyConfig implements Advised { * Interfaces to be implemented by the proxy. Held in List to keep the order * of registration, to create JDK proxy with specified order of interfaces. */ - private List> interfaces = new ArrayList>(); + private List> interfaces = new ArrayList<>(); /** * List of Advisors. If an Advice is added, it will be wrapped * in an Advisor before being added to this List. */ - private List advisors = new LinkedList(); + private List advisors = new LinkedList<>(); /** * Array updated on changes to the advisors list, which is easier @@ -122,7 +122,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { * Initialize the method cache. */ private void initMethodCache() { - this.methodCache = new ConcurrentHashMap>(32); + this.methodCache = new ConcurrentHashMap<>(32); } @@ -506,7 +506,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { * @param other the AdvisedSupport object to copy configuration from */ protected void copyConfigurationFrom(AdvisedSupport other) { - copyConfigurationFrom(other, other.targetSource, new ArrayList(other.advisors)); + copyConfigurationFrom(other, other.targetSource, new ArrayList<>(other.advisors)); } /** @@ -520,7 +520,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised { copyFrom(other); this.targetSource = targetSource; this.advisorChainFactory = other.advisorChainFactory; - this.interfaces = new ArrayList>(other.interfaces); + this.interfaces = new ArrayList<>(other.interfaces); for (Advisor advisor : advisors) { if (advisor instanceof IntroductionAdvisor) { validateIntroductionAdvisor((IntroductionAdvisor) advisor); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java index 13a86ecb899..06884dbd2f7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public abstract class AopContext { * the controlling proxy configuration has been set to "true". * @see ProxyConfig#setExposeProxy */ - private static final ThreadLocal currentProxy = new NamedThreadLocal("Current AOP proxy"); + private static final ThreadLocal currentProxy = new NamedThreadLocal<>("Current AOP proxy"); /** diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java index 7e60723e031..3fb3d20b9a7 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -97,7 +97,7 @@ class CglibAopProxy implements AopProxy, Serializable { protected static final Log logger = LogFactory.getLog(CglibAopProxy.class); /** Keeps track of the Classes that we have validated for final methods */ - private static final Map, Boolean> validatedClasses = new WeakHashMap, Boolean>(); + private static final Map, Boolean> validatedClasses = new WeakHashMap<>(); /** The configuration used to configure this proxy */ @@ -322,7 +322,7 @@ class CglibAopProxy implements AopProxy, Serializable { if (isStatic && isFrozen) { Method[] methods = rootClass.getMethods(); Callback[] fixedCallbacks = new Callback[methods.length]; - this.fixedInterceptorMap = new HashMap(methods.length); + this.fixedInterceptorMap = new HashMap<>(methods.length); // TODO: small memory optimisation here (can skip creation for methods with no advice) for (int x = 0; x < methods.length; x++) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java b/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java index 740a7bb8ff2..e629b7b6f93 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/DefaultAdvisorChainFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializ // This is somewhat tricky... We have to process introductions first, // but we need to preserve order in the ultimate list. - List interceptorList = new ArrayList(config.getAdvisors().length); + List interceptorList = new ArrayList<>(config.getAdvisors().length); Class actualClass = (targetClass != null ? targetClass : method.getDeclaringClass()); boolean hasIntroductions = hasMatchingIntroductions(config, actualClass); AdvisorAdapterRegistry registry = GlobalAdvisorAdapterRegistry.getInstance(); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java index e1867efd7e3..a0852f23dfa 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyCreatorSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public class ProxyCreatorSupport extends AdvisedSupport { private AopProxyFactory aopProxyFactory; - private List listeners = new LinkedList(); + private List listeners = new LinkedList<>(); /** Set to true when the first AOP proxy has been created */ private boolean active = false; diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java index d24c5259094..af59b8147b9 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -480,7 +480,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport */ private List freshAdvisorChain() { Advisor[] advisors = getAdvisors(); - List freshAdvisors = new ArrayList(advisors.length); + List freshAdvisors = new ArrayList<>(advisors.length); for (Advisor advisor : advisors) { if (advisor instanceof PrototypePlaceholderAdvisor) { PrototypePlaceholderAdvisor pa = (PrototypePlaceholderAdvisor) advisor; @@ -513,8 +513,8 @@ public class ProxyFactoryBean extends ProxyCreatorSupport BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, Advisor.class); String[] globalInterceptorNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, Interceptor.class); - List beans = new ArrayList(globalAdvisorNames.length + globalInterceptorNames.length); - Map names = new HashMap(beans.size()); + List beans = new ArrayList<>(globalAdvisorNames.length + globalInterceptorNames.length); + Map names = new HashMap<>(beans.size()); for (String name : globalAdvisorNames) { Object bean = beanFactory.getBean(name); beans.add(bean); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java index 4a223afe27c..a555d021685 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/ReflectiveMethodInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -223,7 +223,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea // Force initialization of the user attributes Map, // for having a shared Map reference in the clone. if (this.userAttributes == null) { - this.userAttributes = new HashMap(); + this.userAttributes = new HashMap<>(); } // Create the MethodInvocation clone. @@ -243,7 +243,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea public void setUserAttribute(String key, Object value) { if (value != null) { if (this.userAttributes == null) { - this.userAttributes = new HashMap(); + this.userAttributes = new HashMap<>(); } this.userAttributes.put(key, value); } @@ -268,7 +268,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea */ public Map getUserAttributes() { if (this.userAttributes == null) { - this.userAttributes = new HashMap(); + this.userAttributes = new HashMap<>(); } return this.userAttributes; } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java index 0925b818afb..a11c40b8f8a 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/DefaultAdvisorAdapterRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import org.springframework.aop.support.DefaultPointcutAdvisor; @SuppressWarnings("serial") public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable { - private final List adapters = new ArrayList(3); + private final List adapters = new ArrayList<>(3); /** @@ -77,7 +77,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se @Override public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdviceTypeException { - List interceptors = new ArrayList(3); + List interceptors = new ArrayList<>(3); Advice advice = advisor.getAdvice(); if (advice instanceof MethodInterceptor) { interceptors.add((MethodInterceptor) advice); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java index 5b2ec8f00ee..1b0a803f077 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice { private final Object throwsAdvice; /** Methods on throws advice, keyed by exception class */ - private final Map, Method> exceptionHandlerMap = new HashMap, Method>(); + private final Map, Method> exceptionHandlerMap = new HashMap<>(); /** diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java index 729343083bb..ea83f8768be 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java @@ -132,11 +132,11 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport Collections.newSetFromMap(new ConcurrentHashMap(16)); private final Set earlyProxyReferences = - Collections.newSetFromMap(new ConcurrentHashMap(16)); + Collections.newSetFromMap(new ConcurrentHashMap<>(16)); - private final Map> proxyTypes = new ConcurrentHashMap>(16); + private final Map> proxyTypes = new ConcurrentHashMap<>(16); - private final Map advisedBeans = new ConcurrentHashMap(256); + private final Map advisedBeans = new ConcurrentHashMap<>(256); /** @@ -510,7 +510,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport // Handle prototypes correctly... Advisor[] commonInterceptors = resolveInterceptorNames(); - List allInterceptors = new ArrayList(); + List allInterceptors = new ArrayList<>(); if (specificInterceptors != null) { allInterceptors.addAll(Arrays.asList(specificInterceptors)); if (commonInterceptors.length > 0) { @@ -543,7 +543,7 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport private Advisor[] resolveInterceptorNames() { ConfigurableBeanFactory cbf = (this.beanFactory instanceof ConfigurableBeanFactory ? (ConfigurableBeanFactory) this.beanFactory : null); - List advisors = new ArrayList(); + List advisors = new ArrayList<>(); for (String beanName : this.interceptorNames) { if (cbf == null || !cbf.isCurrentlyInCreation(beanName)) { Object next = this.beanFactory.getBean(beanName); diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java index c484520b89b..ebb92c84c53 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanFactoryAdvisorRetrievalHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,10 +76,10 @@ public class BeanFactoryAdvisorRetrievalHelper { } } if (advisorNames.length == 0) { - return new LinkedList(); + return new LinkedList<>(); } - List advisors = new LinkedList(); + List advisors = new LinkedList<>(); for (String name : advisorNames) { if (isEligibleBean(name)) { if (this.beanFactory.isCurrentlyInCreation(name)) { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java index 5ae853dc365..97a1e27b279 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator { */ public void setBeanNames(String... beanNames) { Assert.notEmpty(beanNames, "'beanNames' must not be empty"); - this.beanNames = new ArrayList(beanNames.length); + this.beanNames = new ArrayList<>(beanNames.length); for (String mappedName : beanNames) { this.beanNames.add(StringUtils.trimWhitespace(mappedName)); } diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java index ce350d651b5..0ba7a1ac45f 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/ProxyCreationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public class ProxyCreationContext { /** ThreadLocal holding the current proxied bean name during Advisor matching */ private static final ThreadLocal currentProxiedBeanName = - new NamedThreadLocal("Name of currently proxied bean"); + new NamedThreadLocal<>("Name of currently proxied bean"); /** diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java index 3735ba06e7e..48fd1c738cc 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator /** Internally used DefaultListableBeanFactory instances, keyed by bean name */ private final Map internalBeanFactories = - new HashMap(); + new HashMap<>(); @Override diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java index a0ee6279763..51f2afba3b6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java @@ -70,7 +70,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware { protected final Log logger = LogFactory.getLog(getClass()); - private final Map executors = new ConcurrentHashMap(16); + private final Map executors = new ConcurrentHashMap<>(16); private volatile Executor defaultExecutor; diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java index 9d7b2600ea1..d4368f0ee87 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ExposeInvocationInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class ExposeInvocationInterceptor implements MethodInterceptor, PriorityO }; private static final ThreadLocal invocation = - new NamedThreadLocal("Current AOP method invocation"); + new NamedThreadLocal<>("Current AOP method invocation"); /** diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java index 4c8273ec39e..d3855db9f0d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java @@ -232,7 +232,7 @@ public abstract class AopUtils { introductionAwareMethodMatcher = (IntroductionAwareMethodMatcher) methodMatcher; } - Set> classes = new LinkedHashSet>(ClassUtils.getAllInterfacesForClassAsSet(targetClass)); + Set> classes = new LinkedHashSet<>(ClassUtils.getAllInterfacesForClassAsSet(targetClass)); classes.add(targetClass); for (Class clazz : classes) { Method[] methods = ReflectionUtils.getAllDeclaredMethods(clazz); @@ -296,7 +296,7 @@ public abstract class AopUtils { if (candidateAdvisors.isEmpty()) { return candidateAdvisors; } - List eligibleAdvisors = new LinkedList(); + List eligibleAdvisors = new LinkedList<>(); for (Advisor candidate : candidateAdvisors) { if (candidate instanceof IntroductionAdvisor && canApply(candidate, clazz)) { eligibleAdvisors.add(candidate); diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java index 32af73dc7bc..bb192d4b5da 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil private final Advice advice; - private final Set> interfaces = new LinkedHashSet>(); + private final Set> interfaces = new LinkedHashSet<>(); private int order = Integer.MAX_VALUE; diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java index b5ef59b3dc7..5bbb37e6f6e 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/DelegatePerTargetObjectIntroductionInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction /** * Hold weak references to keys as we don't want to interfere with garbage collection.. */ - private final Map delegateMap = new WeakHashMap(); + private final Map delegateMap = new WeakHashMap<>(); private Class defaultImplType; diff --git a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java index b91c8975028..d74bd23a1d6 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,9 +43,9 @@ import org.springframework.util.ClassUtils; @SuppressWarnings("serial") public class IntroductionInfoSupport implements IntroductionInfo, Serializable { - protected final Set> publishedInterfaces = new LinkedHashSet>(); + protected final Set> publishedInterfaces = new LinkedHashSet<>(); - private transient Map rememberedMethods = new ConcurrentHashMap(32); + private transient Map rememberedMethods = new ConcurrentHashMap<>(32); /** @@ -118,7 +118,7 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable { // Rely on default serialization; just initialize state after deserialization. ois.defaultReadObject(); // Initialize transient fields. - this.rememberedMethods = new ConcurrentHashMap(32); + this.rememberedMethods = new ConcurrentHashMap<>(32); } } diff --git a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java index 7ef41f0a3fd..c5fda7e2c43 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/NameMatchMethodPointcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.util.PatternMatchUtils; @SuppressWarnings("serial") public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut implements Serializable { - private List mappedNames = new LinkedList(); + private List mappedNames = new LinkedList<>(); /** @@ -56,7 +56,7 @@ public class NameMatchMethodPointcut extends StaticMethodMatcherPointcut impleme * the pointcut matches. */ public void setMappedNames(String... mappedNames) { - this.mappedNames = new LinkedList(); + this.mappedNames = new LinkedList<>(); if (mappedNames != null) { this.mappedNames.addAll(Arrays.asList(mappedNames)); } diff --git a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java index bc489cca478..67748223213 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -265,7 +265,7 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem @Override public PooledObject makeObject() throws Exception { - return new DefaultPooledObject(newPrototypeInstance()); + return new DefaultPooledObject<>(newPrototypeInstance()); } @Override diff --git a/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java index eae3199356b..9b0231dab20 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/ThreadLocalTargetSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,12 +58,12 @@ public class ThreadLocalTargetSource extends AbstractPrototypeBasedTargetSource * is meant to be per thread per instance of the ThreadLocalTargetSource class. */ private final ThreadLocal targetInThread = - new NamedThreadLocal("Thread-local instance of bean '" + getTargetBeanName() + "'"); + new NamedThreadLocal<>("Thread-local instance of bean '" + getTargetBeanName() + "'"); /** * Set of managed targets, enabling us to keep track of the targets we've created. */ - private final Set targetSet = new HashSet(); + private final Set targetSet = new HashSet<>(); private int invocationCount; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java index ddb7c1afe28..5ef2bc75feb 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public class TigerAspectJExpressionPointcutTests { // TODO factor into static in AspectJExpressionPointcut private Method getAge; - private Map methodsOnHasGeneric = new HashMap(); + private Map methodsOnHasGeneric = new HashMap<>(); @Before diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java index 554be1ae81e..64b484f7a4c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java @@ -138,7 +138,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { int realAge = 65; target.setAge(realAge); - List advisors = new LinkedList(); + List advisors = new LinkedList<>(); PerTargetAspect aspect1 = new PerTargetAspect(); aspect1.count = 100; aspect1.setOrder(10); @@ -166,7 +166,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { int realAge = 65; target.setAge(realAge); - List advisors = new LinkedList(); + List advisors = new LinkedList<>(); PerTargetAspectWithOrderAnnotation10 aspect1 = new PerTargetAspectWithOrderAnnotation10(); aspect1.count = 100; advisors.addAll( @@ -402,7 +402,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { @Test public void testIntroductionOnTargetExcludedByTypePattern() { - LinkedList target = new LinkedList(); + LinkedList target = new LinkedList<>(); List proxy = (List) createProxy(target, AopUtils.findAdvisorsThatCanApply( getFixture().getAdvisors(new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(), "someBean")), diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index 87caedd021f..348e619b0db 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -172,7 +172,7 @@ public final class AopNamespaceHandlerEventTests { BeanReference[] beanReferences = acd.getBeanReferences(); assertEquals(6, beanReferences.length); - Set expectedReferences = new HashSet(); + Set expectedReferences = new HashSet<>(); expectedReferences.add("pc"); expectedReferences.add("countingAdvice"); for (int i = 0; i < beanReferences.length; i++) { diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java index 2a7f726fb71..9293d087d51 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public final class MethodInvocationTests { Method m = Object.class.getMethod("hashCode"); Object proxy = new Object(); final Object returnValue = new Object(); - List is = new LinkedList(); + List is = new LinkedList<>(); is.add(new MethodInterceptor() { @Override public Object invoke(MethodInvocation invocation) throws Throwable { @@ -65,7 +65,7 @@ public final class MethodInvocationTests { throw new UnsupportedOperationException("toString"); } }; - List is = new LinkedList(); + List is = new LinkedList<>(); Method m = Object.class.getMethod("hashCode"); Object proxy = new Object(); diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index b01b9b80666..e434d4ffb10 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -345,7 +345,7 @@ public class ProxyFactoryTests { public void testInterfaceProxiesCanBeOrderedThroughAnnotations() { Object proxy1 = new ProxyFactory(new A()).getProxy(); Object proxy2 = new ProxyFactory(new B()).getProxy(); - List list = new ArrayList(2); + List list = new ArrayList<>(2); list.add(proxy1); list.add(proxy2); AnnotationAwareOrderComparator.sort(list); @@ -361,7 +361,7 @@ public class ProxyFactoryTests { pf2.setProxyTargetClass(true); Object proxy1 = pf1.getProxy(); Object proxy2 = pf2.getProxy(); - List list = new ArrayList(2); + List list = new ArrayList<>(2); list.add(proxy1); list.add(proxy2); AnnotationAwareOrderComparator.sort(list); diff --git a/spring-aop/src/test/java/org/springframework/tests/aop/advice/MethodCounter.java b/spring-aop/src/test/java/org/springframework/tests/aop/advice/MethodCounter.java index ce7ac5da4a2..5b31b6bfadc 100644 --- a/spring-aop/src/test/java/org/springframework/tests/aop/advice/MethodCounter.java +++ b/spring-aop/src/test/java/org/springframework/tests/aop/advice/MethodCounter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import java.util.HashMap; public class MethodCounter implements Serializable { /** Method name --> count, does not understand overloading */ - private HashMap map = new HashMap(); + private HashMap map = new HashMap<>(); private int allCount; diff --git a/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java b/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java index 43d68233319..4852230013a 100644 --- a/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java +++ b/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -143,9 +143,9 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp */ private final XmlBeanDefinitionReader groovyDslXmlBeanDefinitionReader; - private final Map namespaces = new HashMap(); + private final Map namespaces = new HashMap<>(); - private final Map deferredProperties = new HashMap(); + private final Map deferredProperties = new HashMap<>(); private MetaClass metaClass = GroovySystem.getMetaClassRegistry().getMetaClass(getClass()); @@ -568,7 +568,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp } } if (containsRuntimeRefs) { - Map managedMap = new ManagedMap(); + Map managedMap = new ManagedMap<>(); managedMap.putAll(map); return managedMap; } @@ -590,7 +590,7 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp } } if (containsRuntimeRefs) { - List managedList = new ManagedList(); + List managedList = new ManagedList<>(); managedList.addAll(list); return managedList; } diff --git a/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java b/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java index 4a70a42c6d2..5ef8059eb68 100644 --- a/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java +++ b/spring-beans-groovy/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport { private static final String DESTROY_METHOD = "destroyMethod"; private static final String SINGLETON = "singleton"; - private static final List dynamicProperties = new ArrayList(8); + private static final List dynamicProperties = new ArrayList<>(8); static { dynamicProperties.add(PARENT); diff --git a/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java b/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java index ff59001b875..5067883c5e2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java @@ -808,7 +808,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA */ private AbstractNestablePropertyAccessor getNestedPropertyAccessor(String nestedProperty) { if (this.nestedPropertyAccessors == null) { - this.nestedPropertyAccessors = new HashMap(); + this.nestedPropertyAccessors = new HashMap<>(); } // Get value of bean property. PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty); @@ -909,7 +909,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA private PropertyTokenHolder getPropertyNameTokens(String propertyName) { PropertyTokenHolder tokens = new PropertyTokenHolder(); String actualName = null; - List keys = new ArrayList(2); + List keys = new ArrayList<>(2); int searchIndex = 0; while (searchIndex != -1) { int keyStart = propertyName.indexOf(PROPERTY_KEY_PREFIX, searchIndex); diff --git a/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java b/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java index 078712179a1..b645cd90173 100644 --- a/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/AbstractPropertyAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,7 +108,7 @@ public abstract class AbstractPropertyAccessor extends TypeConverterSupport impl } catch (PropertyAccessException ex) { if (propertyAccessExceptions == null) { - propertyAccessExceptions = new LinkedList(); + propertyAccessExceptions = new LinkedList<>(); } propertyAccessExceptions.add(ex); } diff --git a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java index 2efe9dabeb1..fc1d75f5fa4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java +++ b/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java @@ -114,14 +114,14 @@ public class CachedIntrospectionResults { * This variant is being used for cache-safe bean classes. */ static final ConcurrentMap, CachedIntrospectionResults> strongClassCache = - new ConcurrentHashMap, CachedIntrospectionResults>(64); + new ConcurrentHashMap<>(64); /** * Map keyed by Class containing CachedIntrospectionResults, softly held. * This variant is being used for non-cache-safe bean classes. */ static final ConcurrentMap, CachedIntrospectionResults> softClassCache = - new ConcurrentReferenceHashMap, CachedIntrospectionResults>(64); + new ConcurrentReferenceHashMap<>(64); /** @@ -283,7 +283,7 @@ public class CachedIntrospectionResults { if (logger.isTraceEnabled()) { logger.trace("Caching PropertyDescriptors for class [" + beanClass.getName() + "]"); } - this.propertyDescriptorCache = new LinkedHashMap(); + this.propertyDescriptorCache = new LinkedHashMap<>(); // This call is slow so we do it once. PropertyDescriptor[] pds = this.beanInfo.getPropertyDescriptors(); @@ -321,7 +321,7 @@ public class CachedIntrospectionResults { clazz = clazz.getSuperclass(); } - this.typeDescriptorCache = new ConcurrentReferenceHashMap(); + this.typeDescriptorCache = new ConcurrentReferenceHashMap<>(); } catch (IntrospectionException ex) { throw new FatalBeanException("Failed to obtain BeanInfo for class [" + beanClass.getName() + "]", ex); diff --git a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java index 356231132d2..0c98a343ea5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/DirectFieldAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ import org.springframework.util.ReflectionUtils; */ public class DirectFieldAccessor extends AbstractNestablePropertyAccessor { - private final Map fieldMap = new HashMap(); + private final Map fieldMap = new HashMap<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 1411f5569b3..e8a9ad6bb10 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ class ExtendedBeanInfo implements BeanInfo { private final BeanInfo delegate; private final Set propertyDescriptors = - new TreeSet(new PropertyDescriptorComparator()); + new TreeSet<>(new PropertyDescriptorComparator()); /** @@ -128,7 +128,7 @@ class ExtendedBeanInfo implements BeanInfo { private List findCandidateWriteMethods(MethodDescriptor[] methodDescriptors) { - List matches = new ArrayList(); + List matches = new ArrayList<>(); for (MethodDescriptor methodDescriptor : methodDescriptors) { Method method = methodDescriptor.getMethod(); if (isCandidateWriteMethod(method)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java b/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java index ffe31bd854a..2d10197d98f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java +++ b/spring-beans/src/main/java/org/springframework/beans/GenericTypeAwarePropertyDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ final class GenericTypeAwarePropertyDescriptor extends PropertyDescriptor { // Write method not matched against read method: potentially ambiguous through // several overloaded variants, in which case an arbitrary winner has been chosen // by the JDK's JavaBeans Introspector... - Set ambiguousCandidates = new HashSet(); + Set ambiguousCandidates = new HashSet<>(); for (Method method : beanClass.getMethods()) { if (method.getName().equals(writeMethodToUse.getName()) && !method.equals(writeMethodToUse) && !method.isBridge() && diff --git a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java index efb4ae9bbd8..43136433d80 100644 --- a/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/MutablePropertyValues.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { * @see #add(String, Object) */ public MutablePropertyValues() { - this.propertyValueList = new ArrayList(0); + this.propertyValueList = new ArrayList<>(0); } /** @@ -66,13 +66,13 @@ public class MutablePropertyValues implements PropertyValues, Serializable { // There is no replacement of existing property values. if (original != null) { PropertyValue[] pvs = original.getPropertyValues(); - this.propertyValueList = new ArrayList(pvs.length); + this.propertyValueList = new ArrayList<>(pvs.length); for (PropertyValue pv : pvs) { this.propertyValueList.add(new PropertyValue(pv)); } } else { - this.propertyValueList = new ArrayList(0); + this.propertyValueList = new ArrayList<>(0); } } @@ -85,13 +85,13 @@ public class MutablePropertyValues implements PropertyValues, Serializable { // We can optimize this because it's all new: // There is no replacement of existing property values. if (original != null) { - this.propertyValueList = new ArrayList(original.size()); + this.propertyValueList = new ArrayList<>(original.size()); for (Map.Entry entry : original.entrySet()) { this.propertyValueList.add(new PropertyValue(entry.getKey().toString(), entry.getValue())); } } else { - this.propertyValueList = new ArrayList(0); + this.propertyValueList = new ArrayList<>(0); } } @@ -104,7 +104,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { */ public MutablePropertyValues(List propertyValueList) { this.propertyValueList = - (propertyValueList != null ? propertyValueList : new ArrayList()); + (propertyValueList != null ? propertyValueList : new ArrayList<>()); } @@ -316,7 +316,7 @@ public class MutablePropertyValues implements PropertyValues, Serializable { */ public void registerProcessedProperty(String propertyName) { if (this.processedProperties == null) { - this.processedProperties = new HashSet(); + this.processedProperties = new HashSet<>(); } this.processedProperties.add(propertyName); } diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java index f42d6c332ec..112a4753790 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyEditorRegistrySupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -167,7 +167,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { */ public void overrideDefaultEditor(Class requiredType, PropertyEditor propertyEditor) { if (this.overriddenDefaultEditors == null) { - this.overriddenDefaultEditors = new HashMap, PropertyEditor>(); + this.overriddenDefaultEditors = new HashMap<>(); } this.overriddenDefaultEditors.put(requiredType, propertyEditor); } @@ -199,7 +199,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { * Actually register the default editors for this registry instance. */ private void createDefaultEditors() { - this.defaultEditors = new HashMap, PropertyEditor>(64); + this.defaultEditors = new HashMap<>(64); // Simple editors, without parameterization capabilities. // The JDK does not contain a default editor for any of these target types. @@ -298,13 +298,13 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { } if (propertyPath != null) { if (this.customEditorsForPath == null) { - this.customEditorsForPath = new LinkedHashMap(16); + this.customEditorsForPath = new LinkedHashMap<>(16); } this.customEditorsForPath.put(propertyPath, new CustomEditorHolder(propertyEditor, requiredType)); } else { if (this.customEditors == null) { - this.customEditors = new LinkedHashMap, PropertyEditor>(16); + this.customEditors = new LinkedHashMap<>(16); } this.customEditors.put(requiredType, propertyEditor); this.customEditorCache = null; @@ -319,7 +319,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { // Check property-specific editor first. PropertyEditor editor = getCustomEditor(propertyPath, requiredType); if (editor == null) { - List strippedPaths = new LinkedList(); + List strippedPaths = new LinkedList<>(); addStrippedPropertyPaths(strippedPaths, "", propertyPath); for (Iterator it = strippedPaths.iterator(); it.hasNext() && editor == null;) { String strippedPath = it.next(); @@ -415,7 +415,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { // Cache editor for search type, to avoid the overhead // of repeated assignable-from checks. if (this.customEditorCache == null) { - this.customEditorCache = new HashMap, PropertyEditor>(); + this.customEditorCache = new HashMap<>(); } this.customEditorCache.put(requiredType, editor); } @@ -435,7 +435,7 @@ public class PropertyEditorRegistrySupport implements PropertyEditorRegistry { if (this.customEditorsForPath != null) { CustomEditorHolder editorHolder = this.customEditorsForPath.get(propertyName); if (editorHolder == null) { - List strippedPaths = new LinkedList(); + List strippedPaths = new LinkedList<>(); addStrippedPropertyPaths(strippedPaths, "", propertyName); for (Iterator it = strippedPaths.iterator(); it.hasNext() && editorHolder == null;) { String strippedName = it.next(); diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java b/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java index 87cea928305..c7fa7b690db 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyMatches.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -200,7 +200,7 @@ public abstract class PropertyMatches { * @param maxDistance the maximum distance to accept */ private static String[] calculateMatches(String propertyName, PropertyDescriptor[] propertyDescriptors, int maxDistance) { - List candidates = new ArrayList(); + List candidates = new ArrayList<>(); for (PropertyDescriptor pd : propertyDescriptors) { if (pd.getWriteMethod() != null) { String possibleAlternative = pd.getName(); @@ -241,7 +241,7 @@ public abstract class PropertyMatches { } private static String[] calculateMatches(final String propertyName, Class beanClass, final int maxDistance) { - final List candidates = new ArrayList(); + final List candidates = new ArrayList<>(); ReflectionUtils.doWithFields(beanClass, new ReflectionUtils.FieldCallback() { @Override public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { diff --git a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java index bf0ba7149de..55dca06c302 100644 --- a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public abstract class AnnotationBeanUtils { * @see org.springframework.beans.BeanWrapper */ public static void copyPropertiesToBean(Annotation ann, Object bean, StringValueResolver valueResolver, String... excludedProperties) { - Set excluded = new HashSet(Arrays.asList(excludedProperties)); + Set excluded = new HashSet<>(Arrays.asList(excludedProperties)); Method[] annotationProperties = ann.annotationType().getDeclaredMethods(); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(bean); for (Method annotationProperty : annotationProperties) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java index dc60afb4622..27b28f841a8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanCreationException.java @@ -129,7 +129,7 @@ public class BeanCreationException extends FatalBeanException { */ public void addRelatedCause(Throwable ex) { if (this.relatedCauses == null) { - this.relatedCauses = new LinkedList(); + this.relatedCauses = new LinkedList<>(); } this.relatedCauses.add(ex); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java index 42b749e6fa2..4a54aff5fc1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/BeanFactoryUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -147,7 +147,7 @@ public abstract class BeanFactoryUtils { if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) { String[] parentResult = beanNamesForTypeIncludingAncestors( (ListableBeanFactory) hbf.getParentBeanFactory(), type); - List resultList = new ArrayList(); + List resultList = new ArrayList<>(); resultList.addAll(Arrays.asList(result)); for (String beanName : parentResult) { if (!resultList.contains(beanName) && !hbf.containsLocalBean(beanName)) { @@ -180,7 +180,7 @@ public abstract class BeanFactoryUtils { if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) { String[] parentResult = beanNamesForTypeIncludingAncestors( (ListableBeanFactory) hbf.getParentBeanFactory(), type); - List resultList = new ArrayList(); + List resultList = new ArrayList<>(); resultList.addAll(Arrays.asList(result)); for (String beanName : parentResult) { if (!resultList.contains(beanName) && !hbf.containsLocalBean(beanName)) { @@ -223,7 +223,7 @@ public abstract class BeanFactoryUtils { if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) { String[] parentResult = beanNamesForTypeIncludingAncestors( (ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit); - List resultList = new ArrayList(); + List resultList = new ArrayList<>(); resultList.addAll(Arrays.asList(result)); for (String beanName : parentResult) { if (!resultList.contains(beanName) && !hbf.containsLocalBean(beanName)) { @@ -257,7 +257,7 @@ public abstract class BeanFactoryUtils { throws BeansException { Assert.notNull(lbf, "ListableBeanFactory must not be null"); - Map result = new LinkedHashMap(4); + Map result = new LinkedHashMap<>(4); result.putAll(lbf.getBeansOfType(type)); if (lbf instanceof HierarchicalBeanFactory) { HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf; @@ -306,7 +306,7 @@ public abstract class BeanFactoryUtils { throws BeansException { Assert.notNull(lbf, "ListableBeanFactory must not be null"); - Map result = new LinkedHashMap(4); + Map result = new LinkedHashMap<>(4); result.putAll(lbf.getBeansOfType(type, includeNonSingletons, allowEagerInit)); if (lbf instanceof HierarchicalBeanFactory) { HierarchicalBeanFactory hbf = (HierarchicalBeanFactory) lbf; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java b/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java index 45be73287e4..5a521039273 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -275,7 +275,7 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { protected static final Log logger = LogFactory.getLog(SingletonBeanFactoryLocator.class); /** The keyed BeanFactory instances */ - private static final Map instances = new HashMap(); + private static final Map instances = new HashMap<>(); /** @@ -333,9 +333,9 @@ public class SingletonBeanFactoryLocator implements BeanFactoryLocator { // We map BeanFactoryGroup objects by String keys, and by the definition object. - private final Map bfgInstancesByKey = new HashMap(); + private final Map bfgInstancesByKey = new HashMap<>(); - private final Map bfgInstancesByObj = new HashMap(); + private final Map bfgInstancesByObj = new HashMap<>(); private final String resourceLocation; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 3848510f98f..18dd5a77565 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -120,7 +120,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean protected final Log logger = LogFactory.getLog(getClass()); private final Set> autowiredAnnotationTypes = - new LinkedHashSet>(); + new LinkedHashSet<>(); private String requiredParameterName = "required"; @@ -134,10 +134,10 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean Collections.newSetFromMap(new ConcurrentHashMap(256)); private final Map, Constructor[]> candidateConstructorsCache = - new ConcurrentHashMap, Constructor[]>(256); + new ConcurrentHashMap<>(256); private final Map injectionMetadataCache = - new ConcurrentHashMap(256); + new ConcurrentHashMap<>(256); /** @@ -267,7 +267,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean candidateConstructors = this.candidateConstructorsCache.get(beanClass); if (candidateConstructors == null) { Constructor[] rawCandidates = beanClass.getDeclaredConstructors(); - List> candidates = new ArrayList>(rawCandidates.length); + List> candidates = new ArrayList<>(rawCandidates.length); Constructor requiredConstructor = null; Constructor defaultConstructor = null; for (Constructor candidate : rawCandidates) { @@ -405,12 +405,12 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean } private InjectionMetadata buildAutowiringMetadata(final Class clazz) { - LinkedList elements = new LinkedList(); + LinkedList elements = new LinkedList<>(); Class targetClass = clazz; do { final LinkedList currElements = - new LinkedList(); + new LinkedList<>(); ReflectionUtils.doWithLocalFields(targetClass, new ReflectionUtils.FieldCallback() { @Override @@ -560,7 +560,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean else { DependencyDescriptor desc = new DependencyDescriptor(field, this.required); desc.setContainingClass(bean.getClass()); - Set autowiredBeanNames = new LinkedHashSet(1); + Set autowiredBeanNames = new LinkedHashSet<>(1); TypeConverter typeConverter = beanFactory.getTypeConverter(); try { value = beanFactory.resolveDependency(desc, beanName, autowiredBeanNames, typeConverter); @@ -628,7 +628,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean Class[] paramTypes = method.getParameterTypes(); arguments = new Object[paramTypes.length]; DependencyDescriptor[] descriptors = new DependencyDescriptor[paramTypes.length]; - Set autowiredBeanNames = new LinkedHashSet(paramTypes.length); + Set autowiredBeanNames = new LinkedHashSet<>(paramTypes.length); TypeConverter typeConverter = beanFactory.getTypeConverter(); for (int i = 0; i < arguments.length; i++) { MethodParameter methodParam = new MethodParameter(method, i); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java index 374332395c7..114df51f8e3 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InitDestroyAnnotationBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ public class InitDestroyAnnotationBeanPostProcessor private int order = Ordered.LOWEST_PRECEDENCE; private transient final Map, LifecycleMetadata> lifecycleMetadataCache = - new ConcurrentHashMap, LifecycleMetadata>(256); + new ConcurrentHashMap<>(256); /** @@ -194,13 +194,13 @@ public class InitDestroyAnnotationBeanPostProcessor private LifecycleMetadata buildLifecycleMetadata(final Class clazz) { final boolean debug = logger.isDebugEnabled(); - LinkedList initMethods = new LinkedList(); - LinkedList destroyMethods = new LinkedList(); + LinkedList initMethods = new LinkedList<>(); + LinkedList destroyMethods = new LinkedList<>(); Class targetClass = clazz; do { - final LinkedList currInitMethods = new LinkedList(); - final LinkedList currDestroyMethods = new LinkedList(); + final LinkedList currInitMethods = new LinkedList<>(); + final LinkedList currDestroyMethods = new LinkedList<>(); ReflectionUtils.doWithLocalMethods(targetClass, new ReflectionUtils.MethodCallback() { @Override @@ -272,7 +272,7 @@ public class InitDestroyAnnotationBeanPostProcessor } public void checkConfigMembers(RootBeanDefinition beanDefinition) { - Set checkedInitMethods = new LinkedHashSet(this.initMethods.size()); + Set checkedInitMethods = new LinkedHashSet<>(this.initMethods.size()); for (LifecycleElement element : this.initMethods) { String methodIdentifier = element.getIdentifier(); if (!beanDefinition.isExternallyManagedInitMethod(methodIdentifier)) { @@ -283,7 +283,7 @@ public class InitDestroyAnnotationBeanPostProcessor } } } - Set checkedDestroyMethods = new LinkedHashSet(this.destroyMethods.size()); + Set checkedDestroyMethods = new LinkedHashSet<>(this.destroyMethods.size()); for (LifecycleElement element : this.destroyMethods) { String methodIdentifier = element.getIdentifier(); if (!beanDefinition.isExternallyManagedDestroyMethod(methodIdentifier)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java index af64331ce9c..f60e7e6f2df 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class InjectionMetadata { public void checkConfigMembers(RootBeanDefinition beanDefinition) { - Set checkedElements = new LinkedHashSet(this.injectedElements.size()); + Set checkedElements = new LinkedHashSet<>(this.injectedElements.size()); for (InjectedElement element : this.injectedElements) { Member member = element.getMember(); if (!beanDefinition.isExternallyManagedConfigMember(member)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java index 0f6d10216ca..03fbb2218ed 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/QualifierAnnotationAutowireCandidateResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ import org.springframework.util.StringUtils; */ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwareAutowireCandidateResolver { - private final Set> qualifierTypes = new LinkedHashSet>(2); + private final Set> qualifierTypes = new LinkedHashSet<>(2); private Class valueAnnotationType = Value.class; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java index ebc3cbf53c3..e0f3f81f753 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,7 +146,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP if (!this.validatedBeanNames.contains(beanName)) { if (!shouldSkip(this.beanFactory, beanName)) { - List invalidProperties = new ArrayList(); + List invalidProperties = new ArrayList<>(); for (PropertyDescriptor pd : pds) { if (isRequiredProperty(pd) && !pvs.contains(pd.getName())) { invalidProperties.add(pd.getName()); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java index 6f7d2d904ac..dfffe28e36a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java @@ -42,9 +42,9 @@ import org.springframework.util.ObjectUtils; */ public class ConstructorArgumentValues { - private final Map indexedArgumentValues = new LinkedHashMap(0); + private final Map indexedArgumentValues = new LinkedHashMap<>(0); - private final List genericArgumentValues = new LinkedList(); + private final List genericArgumentValues = new LinkedList<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java index dc1516ab026..aab69b17506 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/CustomScopeConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ public class CustomScopeConfigurer implements BeanFactoryPostProcessor, BeanClas */ public void addScope(String scopeName, Scope scope) { if (this.scopes == null) { - this.scopes = new LinkedHashMap(1); + this.scopes = new LinkedHashMap<>(1); } this.scopes.put(scopeName, scope); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java index fb251c4243b..c2cb65d2976 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/ListFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class ListFactoryBean extends AbstractFactoryBean> { result = BeanUtils.instantiateClass(this.targetListClass); } else { - result = new ArrayList(this.sourceList.size()); + result = new ArrayList<>(this.sourceList.size()); } Class valueType = null; if (this.targetListClass != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/MapFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/MapFactoryBean.java index f1ba9cfd451..8e37987c371 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/MapFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/MapFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class MapFactoryBean extends AbstractFactoryBean> { result = BeanUtils.instantiateClass(this.targetMapClass); } else { - result = new LinkedHashMap(this.sourceMap.size()); + result = new LinkedHashMap<>(this.sourceMap.size()); } Class keyType = null; Class valueType = null; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/SetFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/SetFactoryBean.java index c6b573d3dbe..9ab8703f7e7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/SetFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/SetFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class SetFactoryBean extends AbstractFactoryBean> { result = BeanUtils.instantiateClass(this.targetSetClass); } else { - result = new LinkedHashSet(this.sourceSet.size()); + result = new LinkedHashSet<>(this.sourceSet.size()); } Class valueType = null; if (this.targetSetClass != null) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java index 7428f997f93..89c2a9d2162 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean createMap() { - final Map result = new LinkedHashMap(); + final Map result = new LinkedHashMap<>(); process(new MatchCallback() { @Override public void process(Properties properties, Map map) { @@ -129,7 +129,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean result = new LinkedHashMap((Map) existing); + Map result = new LinkedHashMap<>((Map) existing); merge(result, (Map) value); output.put(key, result); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java index ac01eb74b7a..210f37b4658 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -191,7 +191,7 @@ public abstract class YamlProcessor { @SuppressWarnings("unchecked") private Map asMap(Object object) { // YAML can have numbers as keys - Map result = new LinkedHashMap(); + Map result = new LinkedHashMap<>(); if (!(object instanceof Map)) { // A document can be a text literal result.put("document", object); @@ -265,7 +265,7 @@ public abstract class YamlProcessor { * @since 4.1.3 */ protected final Map getFlattenedMap(Map source) { - Map result = new LinkedHashMap(); + Map result = new LinkedHashMap<>(); buildFlattenedMap(result, source, null); return result; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java index 2b88d827657..fe309eeb3c5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanComponentDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,8 +73,8 @@ public class BeanComponentDefinition extends BeanDefinitionHolder implements Com private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefinition) { - List innerBeans = new ArrayList(); - List references = new ArrayList(); + List innerBeans = new ArrayList<>(); + List references = new ArrayList<>(); PropertyValues propertyValues = beanDefinition.getPropertyValues(); for (int i = 0; i < propertyValues.getPropertyValues().length; i++) { PropertyValue propertyValue = propertyValues.getPropertyValues()[i]; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java index 550ae761c22..53b857274c2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/CompositeComponentDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public class CompositeComponentDefinition extends AbstractComponentDefinition { private final Object source; - private final List nestedComponents = new LinkedList(); + private final List nestedComponents = new LinkedList<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java index 43b0c293323..2edb93890d7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public final class ParseState { * Create a new {@code ParseState} with an empty {@link Stack}. */ public ParseState() { - this.state = new Stack(); + this.state = new Stack<>(); } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/ServiceListFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/ServiceListFactoryBean.java index 01f46e0d316..da111307239 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/ServiceListFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/serviceloader/ServiceListFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class ServiceListFactoryBean extends AbstractServiceLoaderBasedFactoryBea @Override protected Object getObjectToExpose(ServiceLoader serviceLoader) { - List result = new LinkedList(); + List result = new LinkedList<>(); for (Object loaderObject : serviceLoader) { result.add(loaderObject); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index cf25cd5b9a3..677d529bd39 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,21 +136,21 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * Dependency types to ignore on dependency check and autowire, as Set of * Class objects: for example, String. Default is none. */ - private final Set> ignoredDependencyTypes = new HashSet>(); + private final Set> ignoredDependencyTypes = new HashSet<>(); /** * Dependency interfaces to ignore on dependency check and autowire, as Set of * Class objects. By default, only the BeanFactory interface is ignored. */ - private final Set> ignoredDependencyInterfaces = new HashSet>(); + private final Set> ignoredDependencyInterfaces = new HashSet<>(); /** Cache of unfinished FactoryBean instances: FactoryBean name --> BeanWrapper */ private final Map factoryBeanInstanceCache = - new ConcurrentHashMap(16); + new ConcurrentHashMap<>(16); /** Cache of filtered PropertyDescriptors: bean Class -> PropertyDescriptor array */ private final ConcurrentMap, PropertyDescriptor[]> filteredPropertyDescriptorsCache = - new ConcurrentHashMap, PropertyDescriptor[]>(256); + new ConcurrentHashMap<>(256); /** @@ -562,7 +562,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac } else if (!this.allowRawInjectionDespiteWrapping && hasDependentBean(beanName)) { String[] dependentBeans = getDependentBeans(beanName); - Set actualDependentBeans = new LinkedHashSet(dependentBeans.length); + Set actualDependentBeans = new LinkedHashSet<>(dependentBeans.length); for (String dependentBean : dependentBeans) { if (!removeSingletonIfCreatedForTypeCheckOnly(dependentBean)) { actualDependentBeans.add(dependentBean); @@ -697,7 +697,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac } ConstructorArgumentValues cav = mbd.getConstructorArgumentValues(); Set usedValueHolders = - new HashSet(paramTypes.length); + new HashSet<>(paramTypes.length); Object[] args = new Object[paramTypes.length]; for (int i = 0; i < args.length; i++) { ConstructorArgumentValues.ValueHolder valueHolder = cav.getArgumentValue( @@ -1277,7 +1277,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac converter = bw; } - Set autowiredBeanNames = new LinkedHashSet(4); + Set autowiredBeanNames = new LinkedHashSet<>(4); String[] propertyNames = unsatisfiedNonSimpleProperties(mbd, bw); for (String propertyName : propertyNames) { try { @@ -1320,7 +1320,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @see org.springframework.beans.BeanUtils#isSimpleProperty */ protected String[] unsatisfiedNonSimpleProperties(AbstractBeanDefinition mbd, BeanWrapper bw) { - Set result = new TreeSet(); + Set result = new TreeSet<>(); PropertyValues pvs = mbd.getPropertyValues(); PropertyDescriptor[] pds = bw.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { @@ -1365,7 +1365,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac */ protected PropertyDescriptor[] filterPropertyDescriptorsForDependencyCheck(BeanWrapper bw) { List pds = - new LinkedList(Arrays.asList(bw.getPropertyDescriptors())); + new LinkedList<>(Arrays.asList(bw.getPropertyDescriptors())); for (Iterator it = pds.iterator(); it.hasNext();) { PropertyDescriptor pd = it.next(); if (isExcludedFromDependencyCheck(pd)) { @@ -1469,7 +1469,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac BeanDefinitionValueResolver valueResolver = new BeanDefinitionValueResolver(this, beanName, mbd, converter); // Create a deep copy, resolving any references for values. - List deepCopy = new ArrayList(original.size()); + List deepCopy = new ArrayList<>(original.size()); boolean resolveNecessary = false; for (PropertyValue pv : original) { if (pv.isConverted()) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index a0d7dc21dd2..a338dfe6c1c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -153,7 +153,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess private boolean primary = false; private final Map qualifiers = - new LinkedHashMap(0); + new LinkedHashMap<>(0); private boolean nonPublicAccessAllowed = true; @@ -631,7 +631,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess * @return the Set of {@link AutowireCandidateQualifier} objects. */ public Set getQualifiers() { - return new LinkedHashSet(this.qualifiers.values()); + return new LinkedHashSet<>(this.qualifiers.values()); } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 62dfa38e42e..82870c2c2ba 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -132,20 +132,20 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** Custom PropertyEditorRegistrars to apply to the beans of this factory */ private final Set propertyEditorRegistrars = - new LinkedHashSet(4); + new LinkedHashSet<>(4); /** A custom TypeConverter to use, overriding the default PropertyEditor mechanism */ private TypeConverter typeConverter; /** Custom PropertyEditors to apply to the beans of this factory */ private final Map, Class> customEditors = - new HashMap, Class>(4); + new HashMap<>(4); /** String resolvers to apply e.g. to annotation attribute values */ - private final List embeddedValueResolvers = new LinkedList(); + private final List embeddedValueResolvers = new LinkedList<>(); /** BeanPostProcessors to apply in createBean */ - private final List beanPostProcessors = new ArrayList(); + private final List beanPostProcessors = new ArrayList<>(); /** Indicates whether any InstantiationAwareBeanPostProcessors have been registered */ private boolean hasInstantiationAwareBeanPostProcessors; @@ -154,14 +154,14 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp private boolean hasDestructionAwareBeanPostProcessors; /** Map from scope identifier String to corresponding Scope */ - private final Map scopes = new LinkedHashMap(8); + private final Map scopes = new LinkedHashMap<>(8); /** Security context used when running with a SecurityManager */ private SecurityContextProvider securityContextProvider; /** Map from bean name to merged RootBeanDefinition */ private final Map mergedBeanDefinitions = - new ConcurrentHashMap(256); + new ConcurrentHashMap<>(256); /** Names of beans that have already been created at least once */ private final Set alreadyCreated = @@ -169,7 +169,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** Names of beans that are currently in creation */ private final ThreadLocal prototypesCurrentlyInCreation = - new NamedThreadLocal("Prototype beans currently in creation"); + new NamedThreadLocal<>("Prototype beans currently in creation"); /** @@ -627,7 +627,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp @Override public String[] getAliases(String name) { String beanName = transformedBeanName(name); - List aliases = new ArrayList(); + List aliases = new ArrayList<>(); boolean factoryPrefix = name.startsWith(FACTORY_BEAN_PREFIX); String fullBeanName = beanName; if (factoryPrefix) { @@ -1009,7 +1009,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp this.prototypesCurrentlyInCreation.set(beanName); } else if (curVal instanceof String) { - Set beanNameSet = new HashSet(2); + Set beanNameSet = new HashSet<>(2); beanNameSet.add((String) curVal); beanNameSet.add(beanName); this.prototypesCurrentlyInCreation.set(beanNameSet); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java index 81a9862a1c2..29acd9c9d8f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -376,7 +376,7 @@ class BeanDefinitionValueResolver { * For each element in the managed list, resolve reference if necessary. */ private List resolveManagedList(Object argName, List ml) { - List resolved = new ArrayList(ml.size()); + List resolved = new ArrayList<>(ml.size()); for (int i = 0; i < ml.size(); i++) { resolved.add( resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i))); @@ -388,7 +388,7 @@ class BeanDefinitionValueResolver { * For each element in the managed set, resolve reference if necessary. */ private Set resolveManagedSet(Object argName, Set ms) { - Set resolved = new LinkedHashSet(ms.size()); + Set resolved = new LinkedHashSet<>(ms.size()); int i = 0; for (Object m : ms) { resolved.add(resolveValueIfNecessary(new KeyedArgName(argName, i), m)); @@ -401,7 +401,7 @@ class BeanDefinitionValueResolver { * For each element in the managed map, resolve reference if necessary. */ private Map resolveManagedMap(Object argName, Map mm) { - Map resolved = new LinkedHashMap(mm.size()); + Map resolved = new LinkedHashMap<>(mm.size()); for (Map.Entry entry : mm.entrySet()) { Object resolvedKey = resolveValueIfNecessary(argName, entry.getKey()); Object resolvedValue = resolveValueIfNecessary( diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index 157bb1cd9e8..9d1455c814a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -71,7 +71,7 @@ import org.springframework.util.StringUtils; class ConstructorResolver { private static final NamedThreadLocal currentInjectionPoint = - new NamedThreadLocal("Current injection point"); + new NamedThreadLocal<>("Current injection point"); private final AbstractAutowireCapableBeanFactory beanFactory; @@ -196,7 +196,7 @@ class ConstructorResolver { } // Swallow and try next constructor. if (causes == null) { - causes = new LinkedList(); + causes = new LinkedList<>(); } causes.add(ex); continue; @@ -222,7 +222,7 @@ class ConstructorResolver { } else if (constructorToUse != null && typeDiffWeight == minTypeDiffWeight) { if (ambiguousConstructors == null) { - ambiguousConstructors = new LinkedHashSet>(); + ambiguousConstructors = new LinkedHashSet<>(); ambiguousConstructors.add(constructorToUse); } ambiguousConstructors.add(candidate); @@ -422,7 +422,7 @@ class ConstructorResolver { factoryClass = ClassUtils.getUserClass(factoryClass); Method[] rawCandidates = getCandidateMethods(factoryClass, mbd); - List candidateSet = new ArrayList(); + List candidateSet = new ArrayList<>(); for (Method candidate : rawCandidates) { if (Modifier.isStatic(candidate.getModifiers()) == isStatic && mbd.isFactoryMethod(candidate)) { candidateSet.add(candidate); @@ -474,7 +474,7 @@ class ConstructorResolver { } // Swallow and try next overloaded factory method. if (causes == null) { - causes = new LinkedList(); + causes = new LinkedList<>(); } causes.add(ex); continue; @@ -509,7 +509,7 @@ class ConstructorResolver { paramTypes.length == factoryMethodToUse.getParameterTypes().length && !Arrays.equals(paramTypes, factoryMethodToUse.getParameterTypes())) { if (ambiguousFactoryMethods == null) { - ambiguousFactoryMethods = new LinkedHashSet(); + ambiguousFactoryMethods = new LinkedHashSet<>(); ambiguousFactoryMethods.add(factoryMethodToUse); } ambiguousFactoryMethods.add(candidate); @@ -525,14 +525,14 @@ class ConstructorResolver { } throw ex; } - List argTypes = new ArrayList(minNrOfArgs); + List argTypes = new ArrayList<>(minNrOfArgs); if (explicitArgs != null) { for (Object arg : explicitArgs) { argTypes.add(arg != null ? arg.getClass().getSimpleName() : "null"); } } else { - Set valueHolders = new LinkedHashSet(resolvedValues.getArgumentCount()); + Set valueHolders = new LinkedHashSet<>(resolvedValues.getArgumentCount()); valueHolders.addAll(resolvedValues.getIndexedArgumentValues().values()); valueHolders.addAll(resolvedValues.getGenericArgumentValues()); for (ValueHolder value : valueHolders) { @@ -670,8 +670,8 @@ class ConstructorResolver { ArgumentsHolder args = new ArgumentsHolder(paramTypes.length); Set usedValueHolders = - new HashSet(paramTypes.length); - Set autowiredBeanNames = new LinkedHashSet(4); + new HashSet<>(paramTypes.length); + Set autowiredBeanNames = new LinkedHashSet<>(4); for (int paramIndex = 0; paramIndex < paramTypes.length; paramIndex++) { Class paramType = paramTypes[paramIndex]; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 557407e0f79..7b8b9a8df6a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -128,7 +128,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto /** Map from serialized id to factory instance */ private static final Map> serializableFactories = - new ConcurrentHashMap>(8); + new ConcurrentHashMap<>(8); /** Optional id for this factory, for serialization purposes */ private String serializationId; @@ -146,22 +146,22 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto private AutowireCandidateResolver autowireCandidateResolver = new SimpleAutowireCandidateResolver(); /** Map from dependency type to corresponding autowired value */ - private final Map, Object> resolvableDependencies = new ConcurrentHashMap, Object>(16); + private final Map, Object> resolvableDependencies = new ConcurrentHashMap<>(16); /** Map of bean definition objects, keyed by bean name */ - private final Map beanDefinitionMap = new ConcurrentHashMap(256); + private final Map beanDefinitionMap = new ConcurrentHashMap<>(256); /** Map of singleton and non-singleton bean names, keyed by dependency type */ - private final Map, String[]> allBeanNamesByType = new ConcurrentHashMap, String[]>(64); + private final Map, String[]> allBeanNamesByType = new ConcurrentHashMap<>(64); /** Map of singleton-only bean names, keyed by dependency type */ - private final Map, String[]> singletonBeanNamesByType = new ConcurrentHashMap, String[]>(64); + private final Map, String[]> singletonBeanNamesByType = new ConcurrentHashMap<>(64); /** List of bean definition names, in registration order */ - private volatile List beanDefinitionNames = new ArrayList(256); + private volatile List beanDefinitionNames = new ArrayList<>(256); /** List of names of manually registered singletons, in registration order */ - private volatile Set manualSingletonNames = new LinkedHashSet(16); + private volatile Set manualSingletonNames = new LinkedHashSet<>(16); /** Cached array of bean definition names in case of frozen configuration */ private volatile String[] frozenBeanDefinitionNames; @@ -192,7 +192,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto */ public void setSerializationId(String serializationId) { if (serializationId != null) { - serializableFactories.put(serializationId, new WeakReference(this)); + serializableFactories.put(serializationId, new WeakReference<>(this)); } else if (this.serializationId != null) { serializableFactories.remove(this.serializationId); @@ -328,7 +328,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto Assert.notNull(requiredType, "Required type must not be null"); String[] beanNames = getBeanNamesForType(requiredType); if (beanNames.length > 1) { - ArrayList autowireCandidates = new ArrayList(); + ArrayList autowireCandidates = new ArrayList<>(); for (String beanName : beanNames) { if (!containsBeanDefinition(beanName) || getBeanDefinition(beanName).isAutowireCandidate()) { autowireCandidates.add(beanName); @@ -342,7 +342,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return getBean(beanNames[0], requiredType, args); } else if (beanNames.length > 1) { - Map candidates = new HashMap(); + Map candidates = new HashMap<>(); for (String beanName : beanNames) { candidates.put(beanName, getBean(beanName, requiredType, args)); } @@ -419,7 +419,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit) { - List result = new ArrayList(); + List result = new ArrayList<>(); // Check all bean definitions. for (String beanName : this.beanDefinitionNames) { @@ -519,7 +519,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto throws BeansException { String[] beanNames = getBeanNamesForType(type, includeNonSingletons, allowEagerInit); - Map result = new LinkedHashMap(beanNames.length); + Map result = new LinkedHashMap<>(beanNames.length); for (String beanName : beanNames) { try { result.put(beanName, getBean(beanName, type)); @@ -547,7 +547,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @Override public String[] getBeanNamesForAnnotation(Class annotationType) { - List results = new ArrayList(); + List results = new ArrayList<>(); for (String beanName : this.beanDefinitionNames) { BeanDefinition beanDefinition = getBeanDefinition(beanName); if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) { @@ -565,7 +565,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @Override public Map getBeansWithAnnotation(Class annotationType) { String[] beanNames = getBeanNamesForAnnotation(annotationType); - Map results = new LinkedHashMap(beanNames.length); + Map results = new LinkedHashMap<>(beanNames.length); for (String beanName : beanNames) { results.put(beanName, getBean(beanName)); } @@ -695,7 +695,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @Override public Iterator getBeanNamesIterator() { - CompositeIterator iterator = new CompositeIterator(); + CompositeIterator iterator = new CompositeIterator<>(); iterator.add(this.beanDefinitionNames.iterator()); iterator.add(this.manualSingletonNames.iterator()); return iterator; @@ -736,7 +736,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto // Iterate over a copy to allow for init methods which in turn register new bean definitions. // While this may not be part of the regular factory bootstrap, it does otherwise work fine. - List beanNames = new ArrayList(this.beanDefinitionNames); + List beanNames = new ArrayList<>(this.beanDefinitionNames); // Trigger initialization of all non-lazy singleton beans... for (String beanName : beanNames) { @@ -848,12 +848,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto // Cannot modify startup-time collection elements anymore (for stable iteration) synchronized (this.beanDefinitionMap) { this.beanDefinitionMap.put(beanName, beanDefinition); - List updatedDefinitions = new ArrayList(this.beanDefinitionNames.size() + 1); + List updatedDefinitions = new ArrayList<>(this.beanDefinitionNames.size() + 1); updatedDefinitions.addAll(this.beanDefinitionNames); updatedDefinitions.add(beanName); this.beanDefinitionNames = updatedDefinitions; if (this.manualSingletonNames.contains(beanName)) { - Set updatedSingletons = new LinkedHashSet(this.manualSingletonNames); + Set updatedSingletons = new LinkedHashSet<>(this.manualSingletonNames); updatedSingletons.remove(beanName); this.manualSingletonNames = updatedSingletons; } @@ -888,7 +888,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (hasBeanCreationStarted()) { // Cannot modify startup-time collection elements anymore (for stable iteration) synchronized (this.beanDefinitionMap) { - List updatedDefinitions = new ArrayList(this.beanDefinitionNames); + List updatedDefinitions = new ArrayList<>(this.beanDefinitionNames); updatedDefinitions.remove(beanName); this.beanDefinitionNames = updatedDefinitions; } @@ -943,7 +943,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto // Cannot modify startup-time collection elements anymore (for stable iteration) synchronized (this.beanDefinitionMap) { if (!this.beanDefinitionMap.containsKey(beanName)) { - Set updatedSingletons = new LinkedHashSet(this.manualSingletonNames.size() + 1); + Set updatedSingletons = new LinkedHashSet<>(this.manualSingletonNames.size() + 1); updatedSingletons.addAll(this.manualSingletonNames); updatedSingletons.add(beanName); this.manualSingletonNames = updatedSingletons; @@ -1162,7 +1162,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } private FactoryAwareOrderSourceProvider createFactoryAwareOrderSourceProvider(Map beans) { - IdentityHashMap instancesToBeanNames = new IdentityHashMap(); + IdentityHashMap instancesToBeanNames = new IdentityHashMap<>(); for (Map.Entry entry : beans.entrySet()) { instancesToBeanNames.put(entry.getValue(), entry.getKey()); } @@ -1187,7 +1187,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto String[] candidateNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors( this, requiredType, true, descriptor.isEager()); - Map result = new LinkedHashMap(candidateNames.length); + Map result = new LinkedHashMap<>(candidateNames.length); for (Class autowiringType : this.resolvableDependencies.keySet()) { if (autowiringType.isAssignableFrom(requiredType)) { Object autowiringValue = this.resolvableDependencies.get(autowiringType); @@ -1603,7 +1603,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (beanDefinition == null) { return null; } - List sources = new ArrayList(); + List sources = new ArrayList<>(); Method factoryMethod = beanDefinition.getResolvedFactoryMethod(); if (factoryMethod != null) { sources.add(factoryMethod); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java index 9042bad5cbf..facd5434220 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,16 +83,16 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements protected final Log logger = LogFactory.getLog(getClass()); /** Cache of singleton objects: bean name --> bean instance */ - private final Map singletonObjects = new ConcurrentHashMap(256); + private final Map singletonObjects = new ConcurrentHashMap<>(256); /** Cache of singleton factories: bean name --> ObjectFactory */ - private final Map> singletonFactories = new HashMap>(16); + private final Map> singletonFactories = new HashMap<>(16); /** Cache of early singleton objects: bean name --> bean instance */ - private final Map earlySingletonObjects = new HashMap(16); + private final Map earlySingletonObjects = new HashMap<>(16); /** Set of registered singletons, containing the bean names in registration order */ - private final Set registeredSingletons = new LinkedHashSet(256); + private final Set registeredSingletons = new LinkedHashSet<>(256); /** Names of beans that are currently in creation */ private final Set singletonsCurrentlyInCreation = @@ -109,16 +109,16 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements private boolean singletonsCurrentlyInDestruction = false; /** Disposable bean instances: bean name --> disposable instance */ - private final Map disposableBeans = new LinkedHashMap(); + private final Map disposableBeans = new LinkedHashMap<>(); /** Map between containing bean names: bean name --> Set of bean names that the bean contains */ - private final Map> containedBeanMap = new ConcurrentHashMap>(16); + private final Map> containedBeanMap = new ConcurrentHashMap<>(16); /** Map between dependent bean names: bean name --> Set of dependent bean names */ - private final Map> dependentBeanMap = new ConcurrentHashMap>(64); + private final Map> dependentBeanMap = new ConcurrentHashMap<>(64); /** Map between depending bean names: bean name --> Set of bean names for the bean's dependencies */ - private final Map> dependenciesForBeanMap = new ConcurrentHashMap>(64); + private final Map> dependenciesForBeanMap = new ConcurrentHashMap<>(64); @Override @@ -224,7 +224,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements boolean newSingleton = false; boolean recordSuppressedExceptions = (this.suppressedExceptions == null); if (recordSuppressedExceptions) { - this.suppressedExceptions = new LinkedHashSet(); + this.suppressedExceptions = new LinkedHashSet<>(); } try { singletonObject = singletonFactory.getObject(); @@ -396,7 +396,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements synchronized (this.containedBeanMap) { containedBeans = this.containedBeanMap.get(containingBeanName); if (containedBeans == null) { - containedBeans = new LinkedHashSet(8); + containedBeans = new LinkedHashSet<>(8); this.containedBeanMap.put(containingBeanName, containedBeans); } containedBeans.add(containedBeanName); @@ -422,7 +422,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements synchronized (this.dependentBeanMap) { dependentBeans = this.dependentBeanMap.get(canonicalName); if (dependentBeans == null) { - dependentBeans = new LinkedHashSet(8); + dependentBeans = new LinkedHashSet<>(8); this.dependentBeanMap.put(canonicalName, dependentBeans); } dependentBeans.add(dependentBeanName); @@ -430,7 +430,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements synchronized (this.dependenciesForBeanMap) { Set dependenciesForBean = this.dependenciesForBeanMap.get(dependentBeanName); if (dependenciesForBean == null) { - dependenciesForBean = new LinkedHashSet(8); + dependenciesForBean = new LinkedHashSet<>(8); this.dependenciesForBeanMap.put(dependentBeanName, dependenciesForBean); } dependenciesForBean.add(canonicalName); @@ -462,7 +462,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements } for (String transitiveDependency : dependentBeans) { if (alreadySeen == null) { - alreadySeen = new HashSet(); + alreadySeen = new HashSet<>(); } alreadySeen.add(beanName); if (isDependent(transitiveDependency, dependentBeanName, alreadySeen)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java index b79403d640c..343516a8640 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java @@ -220,7 +220,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { private List filterPostProcessors(List processors, Object bean) { List filteredPostProcessors = null; if (!CollectionUtils.isEmpty(processors)) { - filteredPostProcessors = new ArrayList(processors.size()); + filteredPostProcessors = new ArrayList<>(processors.size()); for (BeanPostProcessor processor : processors) { if (processor instanceof DestructionAwareBeanPostProcessor) { DestructionAwareBeanPostProcessor dabpp = (DestructionAwareBeanPostProcessor) processor; @@ -388,7 +388,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { protected Object writeReplace() { List serializablePostProcessors = null; if (this.beanPostProcessors != null) { - serializablePostProcessors = new ArrayList(); + serializablePostProcessors = new ArrayList<>(); for (DestructionAwareBeanPostProcessor postProcessor : this.beanPostProcessors) { if (postProcessor instanceof Serializable) { serializablePostProcessors.add(postProcessor); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java index 53dc17657e6..e83bec36336 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import org.springframework.beans.factory.FactoryBeanNotInitializedException; public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanRegistry { /** Cache of singleton objects created by FactoryBeans: FactoryBean name --> object */ - private final Map factoryBeanObjectCache = new ConcurrentHashMap(16); + private final Map factoryBeanObjectCache = new ConcurrentHashMap<>(16); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java index 2a25830eb4f..1d9e7450762 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedList.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ public class ManagedList extends ArrayList implements Mergeable, BeanMetad if (!(parent instanceof List)) { throw new IllegalArgumentException("Cannot merge with object of type [" + parent.getClass() + "]"); } - List merged = new ManagedList(); + List merged = new ManagedList<>(); merged.addAll((List) parent); merged.addAll(this); return merged; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java index 3cc4b986484..444fe4fec61 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ public class ManagedMap extends LinkedHashMap implements Mergeable, if (!(parent instanceof Map)) { throw new IllegalArgumentException("Cannot merge with object of type [" + parent.getClass() + "]"); } - Map merged = new ManagedMap(); + Map merged = new ManagedMap<>(); merged.putAll((Map) parent); merged.putAll(this); return merged; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java index dc6f0e0c1af..c50b70810c4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ManagedSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,7 +100,7 @@ public class ManagedSet extends LinkedHashSet implements Mergeable, BeanMe if (!(parent instanceof Set)) { throw new IllegalArgumentException("Cannot merge with object of type [" + parent.getClass() + "]"); } - Set merged = new ManagedSet(); + Set merged = new ManagedSet<>(); merged.addAll((Set) parent); merged.addAll(this); return merged; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java index 454b2c35b5f..8797b54afd7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -289,7 +289,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader */ public int registerBeanDefinitions(ResourceBundle rb, String prefix) throws BeanDefinitionStoreException { // Simply create a map and call overloaded method. - Map map = new HashMap(); + Map map = new HashMap<>(); Enumeration keys = rb.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java index b3eb9b9e64d..c68e7e09509 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class ReplaceOverride extends MethodOverride { private final String methodReplacerBeanName; - private List typeIdentifiers = new LinkedList(); + private List typeIdentifiers = new LinkedList<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java index d2ac971cbc9..14220eb3c57 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/RootBeanDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -258,7 +258,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { public void registerExternallyManagedConfigMember(Member configMember) { synchronized (this.postProcessingLock) { if (this.externallyManagedConfigMembers == null) { - this.externallyManagedConfigMembers = new HashSet(1); + this.externallyManagedConfigMembers = new HashSet<>(1); } this.externallyManagedConfigMembers.add(configMember); } @@ -274,7 +274,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { public void registerExternallyManagedInitMethod(String initMethod) { synchronized (this.postProcessingLock) { if (this.externallyManagedInitMethods == null) { - this.externallyManagedInitMethods = new HashSet(1); + this.externallyManagedInitMethods = new HashSet<>(1); } this.externallyManagedInitMethods.add(initMethod); } @@ -290,7 +290,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition { public void registerExternallyManagedDestroyMethod(String destroyMethod) { synchronized (this.postProcessingLock) { if (this.externallyManagedDestroyMethods == null) { - this.externallyManagedDestroyMethods = new HashSet(1); + this.externallyManagedDestroyMethods = new HashSet<>(1); } this.externallyManagedDestroyMethods.add(destroyMethod); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java index b792c6cda89..6bcde141a74 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleBeanDefinitionRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import org.springframework.util.StringUtils; public class SimpleBeanDefinitionRegistry extends SimpleAliasRegistry implements BeanDefinitionRegistry { /** Map of bean definition objects, keyed by bean name */ - private final Map beanDefinitionMap = new ConcurrentHashMap(64); + private final Map beanDefinitionMap = new ConcurrentHashMap<>(64); @Override diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java index 74acbd2fee1..449e503f640 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java @@ -42,7 +42,7 @@ import org.springframework.util.StringUtils; */ public class SimpleInstantiationStrategy implements InstantiationStrategy { - private static final ThreadLocal currentlyInvokedFactoryMethod = new ThreadLocal(); + private static final ThreadLocal currentlyInvokedFactoryMethod = new ThreadLocal<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java index 32866846dee..2825121d8af 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java @@ -67,7 +67,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { * with singleton bean instances through {@link #addBean} calls. */ public StaticListableBeanFactory() { - this.beans = new LinkedHashMap(); + this.beans = new LinkedHashMap<>(); } /** @@ -249,7 +249,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { @Override public String[] getBeanNamesForType(ResolvableType type) { boolean isFactoryType = (type != null && FactoryBean.class.isAssignableFrom(type.getRawClass())); - List matches = new ArrayList(); + List matches = new ArrayList<>(); for (Map.Entry entry : this.beans.entrySet()) { String name = entry.getKey(); Object beanInstance = entry.getValue(); @@ -289,7 +289,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { throws BeansException { boolean isFactoryType = (type != null && FactoryBean.class.isAssignableFrom(type)); - Map matches = new LinkedHashMap(); + Map matches = new LinkedHashMap<>(); for (Map.Entry entry : this.beans.entrySet()) { String beanName = entry.getKey(); @@ -320,7 +320,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { @Override public String[] getBeanNamesForAnnotation(Class annotationType) { - List results = new ArrayList(); + List results = new ArrayList<>(); for (String beanName : this.beans.keySet()) { if (findAnnotationOnBean(beanName, annotationType) != null) { results.add(beanName); @@ -333,7 +333,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { public Map getBeansWithAnnotation(Class annotationType) throws BeansException { - Map results = new LinkedHashMap(); + Map results = new LinkedHashMap<>(); for (String beanName : this.beans.keySet()) { if (findAnnotationOnBean(beanName, annotationType) != null) { results.put(beanName, getBean(beanName)); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java index fae76ac581d..e3b3e083915 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -250,7 +250,7 @@ public class BeanDefinitionParserDelegate { * beans-element basis. Duplicate bean ids/names may not exist within the * same level of beans element nesting, but may be duplicated across levels. */ - private final Set usedNames = new HashSet(); + private final Set usedNames = new HashSet<>(); /** @@ -429,7 +429,7 @@ public class BeanDefinitionParserDelegate { String id = ele.getAttribute(ID_ATTRIBUTE); String nameAttr = ele.getAttribute(NAME_ATTRIBUTE); - List aliases = new ArrayList(); + List aliases = new ArrayList<>(); if (StringUtils.hasLength(nameAttr)) { String[] nameArr = StringUtils.tokenizeToStringArray(nameAttr, MULTI_VALUE_ATTRIBUTE_DELIMITERS); aliases.addAll(Arrays.asList(nameArr)); @@ -1162,7 +1162,7 @@ public class BeanDefinitionParserDelegate { public List parseListElement(Element collectionEle, BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); - ManagedList target = new ManagedList(nl.getLength()); + ManagedList target = new ManagedList<>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); @@ -1176,7 +1176,7 @@ public class BeanDefinitionParserDelegate { public Set parseSetElement(Element collectionEle, BeanDefinition bd) { String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE); NodeList nl = collectionEle.getChildNodes(); - ManagedSet target = new ManagedSet(nl.getLength()); + ManagedSet target = new ManagedSet<>(nl.getLength()); target.setSource(extractSource(collectionEle)); target.setElementTypeName(defaultElementType); target.setMergeEnabled(parseMergeAttribute(collectionEle)); @@ -1203,7 +1203,7 @@ public class BeanDefinitionParserDelegate { String defaultValueType = mapEle.getAttribute(VALUE_TYPE_ATTRIBUTE); List entryEles = DomUtils.getChildElementsByTagName(mapEle, ENTRY_ELEMENT); - ManagedMap map = new ManagedMap(entryEles.size()); + ManagedMap map = new ManagedMap<>(entryEles.size()); map.setSource(extractSource(mapEle)); map.setKeyTypeName(defaultKeyType); map.setValueTypeName(defaultValueType); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java index 6e2f6ad905a..1f3382c93b7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java @@ -209,7 +209,7 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume // Resolve system properties: e.g. "${user.dir}" location = getReaderContext().getEnvironment().resolveRequiredPlaceholders(location); - Set actualResources = new LinkedHashSet(4); + Set actualResources = new LinkedHashSet<>(4); // Discover whether the location is an absolute or relative URI boolean absoluteLocation = false; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java index fd7d64cc8cd..36cda2df717 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,7 +156,7 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver if (logger.isDebugEnabled()) { logger.debug("Loaded NamespaceHandler mappings: " + mappings); } - Map handlerMappings = new ConcurrentHashMap(mappings.size()); + Map handlerMappings = new ConcurrentHashMap<>(mappings.size()); CollectionUtils.mergePropertiesIntoMap(mappings, handlerMappings); this.handlerMappings = handlerMappings; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java index b9f89b2369f..ec838885395 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/NamespaceHandlerSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,21 +48,21 @@ public abstract class NamespaceHandlerSupport implements NamespaceHandler { * local name of the {@link Element Elements} they handle. */ private final Map parsers = - new HashMap(); + new HashMap<>(); /** * Stores the {@link BeanDefinitionDecorator} implementations keyed by the * local name of the {@link Element Elements} they handle. */ private final Map decorators = - new HashMap(); + new HashMap<>(); /** * Stores the {@link BeanDefinitionDecorator} implementations keyed by the local * name of the {@link Attr Attrs} they handle. */ private final Map attributeDecorators = - new HashMap(); + new HashMap<>(); /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/ParserContext.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/ParserContext.java index c36314c0d14..006d8bc7f95 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/ParserContext.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/ParserContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public final class ParserContext { private BeanDefinition containingBeanDefinition; - private final Stack containingComponents = new Stack(); + private final Stack containingComponents = new Stack<>(); public ParserContext(XmlReaderContext readerContext, BeanDefinitionParserDelegate delegate) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java index 6cfefe7559b..ebad84b995e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,7 +146,7 @@ public class PluggableSchemaResolver implements EntityResolver { if (logger.isDebugEnabled()) { logger.debug("Loaded schema mappings: " + mappings); } - Map schemaMappings = new ConcurrentHashMap(mappings.size()); + Map schemaMappings = new ConcurrentHashMap<>(mappings.size()); CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings); this.schemaMappings = schemaMappings; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java index 0f7091ade4b..dbefa35e40e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -123,7 +123,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { private final XmlValidationModeDetector validationModeDetector = new XmlValidationModeDetector(); private final ThreadLocal> resourcesCurrentlyBeingLoaded = - new NamedThreadLocal>("XML bean definition resources currently being loaded"); + new NamedThreadLocal<>("XML bean definition resources currently being loaded"); /** @@ -319,7 +319,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { Set currentResources = this.resourcesCurrentlyBeingLoaded.get(); if (currentResources == null) { - currentResources = new HashSet(4); + currentResources = new HashSet<>(4); this.resourcesCurrentlyBeingLoaded.set(currentResources); } if (!currentResources.add(encodedResource)) { diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java index 607a99afcf9..1cc067706c6 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomCollectionEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -160,13 +160,13 @@ public class CustomCollectionEditor extends PropertyEditorSupport { } } else if (List.class == collectionType) { - return new ArrayList(initialCapacity); + return new ArrayList<>(initialCapacity); } else if (SortedSet.class == collectionType) { - return new TreeSet(); + return new TreeSet<>(); } else { - return new LinkedHashSet(initialCapacity); + return new LinkedHashSet<>(initialCapacity); } } diff --git a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java index 85865e546ff..e242b78c67d 100644 --- a/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java +++ b/spring-beans/src/main/java/org/springframework/beans/propertyeditors/CustomMapEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,10 +138,10 @@ public class CustomMapEditor extends PropertyEditorSupport { } } else if (SortedMap.class == mapType) { - return new TreeMap(); + return new TreeMap<>(); } else { - return new LinkedHashMap(initialCapacity); + return new LinkedHashMap<>(initialCapacity); } } diff --git a/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java b/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java index 4d7ff960135..cf7481a78dd 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/PagedListHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ public class PagedListHolder implements Serializable { * @see #setSource */ public PagedListHolder() { - this(new ArrayList(0)); + this(new ArrayList<>(0)); } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java index 585ff167cdc..c50251174ed 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/PropertyComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -147,7 +147,7 @@ public class PropertyComparator implements Comparator { */ public static void sort(Object[] source, SortDefinition sortDefinition) throws BeansException { if (StringUtils.hasText(sortDefinition.getProperty())) { - Arrays.sort(source, new PropertyComparator(sortDefinition)); + Arrays.sort(source, new PropertyComparator<>(sortDefinition)); } } diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java index d801c377f96..b19c29419f1 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java @@ -440,7 +440,7 @@ public abstract class AbstractPropertyAccessorTests { AbstractPropertyAccessor accessor = createAccessor(target); accessor.setConversionService(new DefaultConversionService()); accessor.setAutoGrowNestedPaths(true); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("favoriteNumber", "9"); accessor.setPropertyValue("list[0]", map); assertEquals(map, target.list.get(0)); @@ -820,7 +820,7 @@ public abstract class AbstractPropertyAccessorTests { assertTrue("correct values", target.stringArray[0].equals("foo") && target.stringArray[1].equals("fi") && target.stringArray[2].equals("fi") && target.stringArray[3].equals("fum")); - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("foo"); list.add("fi"); list.add("fi"); @@ -830,7 +830,7 @@ public abstract class AbstractPropertyAccessorTests { assertTrue("correct values", target.stringArray[0].equals("foo") && target.stringArray[1].equals("fi") && target.stringArray[2].equals("fi") && target.stringArray[3].equals("fum")); - Set set = new HashSet(); + Set set = new HashSet<>(); set.add("foo"); set.add("fi"); set.add("fum"); @@ -863,7 +863,7 @@ public abstract class AbstractPropertyAccessorTests { assertTrue("correct values", target.stringArray[0].equals("foo") && target.stringArray[1].equals("fi") && target.stringArray[2].equals("fi") && target.stringArray[3].equals("fum")); - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("4foo"); list.add("7fi"); list.add("6fi"); @@ -873,7 +873,7 @@ public abstract class AbstractPropertyAccessorTests { assertTrue("correct values", target.stringArray[0].equals("foo") && target.stringArray[1].equals("fi") && target.stringArray[2].equals("fi") && target.stringArray[3].equals("fum")); - Set set = new HashSet(); + Set set = new HashSet<>(); set.add("4foo"); set.add("7fi"); set.add("6fum"); @@ -1142,7 +1142,7 @@ public abstract class AbstractPropertyAccessorTests { public void setGenericArrayProperty() { SkipReaderStub target = new SkipReaderStub(); AbstractPropertyAccessor accessor = createAccessor(target); - List values = new LinkedList(); + List values = new LinkedList<>(); values.add("1"); values.add("2"); values.add("3"); @@ -1175,16 +1175,16 @@ public abstract class AbstractPropertyAccessorTests { public void setCollectionProperty() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - Collection coll = new HashSet(); + Collection coll = new HashSet<>(); coll.add("coll1"); accessor.setPropertyValue("collection", coll); - Set set = new HashSet(); + Set set = new HashSet<>(); set.add("set1"); accessor.setPropertyValue("set", set); - SortedSet sortedSet = new TreeSet(); + SortedSet sortedSet = new TreeSet<>(); sortedSet.add("sortedSet1"); accessor.setPropertyValue("sortedSet", sortedSet); - List list = new LinkedList(); + List list = new LinkedList<>(); list.add("list1"); accessor.setPropertyValue("list", list); assertSame(coll, target.getCollection()); @@ -1198,16 +1198,16 @@ public abstract class AbstractPropertyAccessorTests { public void setCollectionPropertyNonMatchingType() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - Collection coll = new ArrayList(); + Collection coll = new ArrayList<>(); coll.add("coll1"); accessor.setPropertyValue("collection", coll); - List set = new LinkedList(); + List set = new LinkedList<>(); set.add("set1"); accessor.setPropertyValue("set", set); - List sortedSet = new ArrayList(); + List sortedSet = new ArrayList<>(); sortedSet.add("sortedSet1"); accessor.setPropertyValue("sortedSet", sortedSet); - Set list = new HashSet(); + Set list = new HashSet<>(); list.add("list1"); accessor.setPropertyValue("list", list); assertEquals(1, target.getCollection().size()); @@ -1225,16 +1225,16 @@ public abstract class AbstractPropertyAccessorTests { public void setCollectionPropertyWithArrayValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - Collection coll = new HashSet(); + Collection coll = new HashSet<>(); coll.add("coll1"); accessor.setPropertyValue("collection", coll.toArray()); - List set = new LinkedList(); + List set = new LinkedList<>(); set.add("set1"); accessor.setPropertyValue("set", set.toArray()); - List sortedSet = new ArrayList(); + List sortedSet = new ArrayList<>(); sortedSet.add("sortedSet1"); accessor.setPropertyValue("sortedSet", sortedSet.toArray()); - Set list = new HashSet(); + Set list = new HashSet<>(); list.add("list1"); accessor.setPropertyValue("list", list.toArray()); assertEquals(1, target.getCollection().size()); @@ -1252,16 +1252,16 @@ public abstract class AbstractPropertyAccessorTests { public void setCollectionPropertyWithIntArrayValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - Collection coll = new HashSet(); + Collection coll = new HashSet<>(); coll.add(0); accessor.setPropertyValue("collection", new int[] {0}); - List set = new LinkedList(); + List set = new LinkedList<>(); set.add(1); accessor.setPropertyValue("set", new int[] {1}); - List sortedSet = new ArrayList(); + List sortedSet = new ArrayList<>(); sortedSet.add(2); accessor.setPropertyValue("sortedSet", new int[] {2}); - Set list = new HashSet(); + Set list = new HashSet<>(); list.add(3); accessor.setPropertyValue("list", new int[] {3}); assertEquals(1, target.getCollection().size()); @@ -1279,16 +1279,16 @@ public abstract class AbstractPropertyAccessorTests { public void setCollectionPropertyWithIntegerValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - Collection coll = new HashSet(); + Collection coll = new HashSet<>(); coll.add(0); accessor.setPropertyValue("collection", new Integer(0)); - List set = new LinkedList(); + List set = new LinkedList<>(); set.add(1); accessor.setPropertyValue("set", new Integer(1)); - List sortedSet = new ArrayList(); + List sortedSet = new ArrayList<>(); sortedSet.add(2); accessor.setPropertyValue("sortedSet", new Integer(2)); - Set list = new HashSet(); + Set list = new HashSet<>(); list.add(3); accessor.setPropertyValue("list", new Integer(3)); assertEquals(1, target.getCollection().size()); @@ -1306,13 +1306,13 @@ public abstract class AbstractPropertyAccessorTests { public void setCollectionPropertyWithStringValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - List set = new LinkedList(); + List set = new LinkedList<>(); set.add("set1"); accessor.setPropertyValue("set", "set1"); - List sortedSet = new ArrayList(); + List sortedSet = new ArrayList<>(); sortedSet.add("sortedSet1"); accessor.setPropertyValue("sortedSet", "sortedSet1"); - Set list = new HashSet(); + Set list = new HashSet<>(); list.add("list1"); accessor.setPropertyValue("list", "list1"); assertEquals(1, target.getSet().size()); @@ -1348,7 +1348,7 @@ public abstract class AbstractPropertyAccessorTests { public void setMapProperty() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key", "value"); accessor.setPropertyValue("map", map); SortedMap sortedMap = new TreeMap<>(); @@ -1362,10 +1362,10 @@ public abstract class AbstractPropertyAccessorTests { public void setMapPropertyNonMatchingType() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); - Map map = new TreeMap(); + Map map = new TreeMap<>(); map.put("key", "value"); accessor.setPropertyValue("map", map); - Map sortedMap = new TreeMap(); + Map sortedMap = new TreeMap<>(); sortedMap.put("sortedKey", "sortedValue"); accessor.setPropertyValue("sortedMap", sortedMap); assertEquals(1, target.getMap().size()); @@ -1422,7 +1422,7 @@ public abstract class AbstractPropertyAccessorTests { } }); - Map inputMap = new HashMap(); + Map inputMap = new HashMap<>(); inputMap.put(1, "rod"); inputMap.put(2, "rob"); MutablePropertyValues pvs = new MutablePropertyValues(); @@ -1446,7 +1446,7 @@ public abstract class AbstractPropertyAccessorTests { } }); - Map inputMap = new HashMap(); + Map inputMap = new HashMap<>(); inputMap.put(1, "rod"); inputMap.put(2, "rob"); MutablePropertyValues pvs = new MutablePropertyValues(); diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java index 69f3ac28871..22cf6675666 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyValuesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public abstract class AbstractPropertyValuesTests { assertTrue("Doesn't contain tory", !pvs.contains("tory")); PropertyValue[] ps = pvs.getPropertyValues(); - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("forname", "Tony"); m.put("surname", "Blair"); m.put("age", "50"); diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java index f97ec8f7497..e6633f0d185 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnum() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnum", "VALUE_1"); assertEquals(CustomEnum.VALUE_1, gb.getCustomEnum()); @@ -43,7 +43,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumWithNull() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnum", null); assertEquals(null, gb.getCustomEnum()); @@ -51,7 +51,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumWithEmptyString() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnum", ""); assertEquals(null, gb.getCustomEnum()); @@ -59,7 +59,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumArrayWithSingleValue() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumArray", "VALUE_1"); assertEquals(1, gb.getCustomEnumArray().length); @@ -68,7 +68,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumArrayWithMultipleValues() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumArray", new String[] {"VALUE_1", "VALUE_2"}); assertEquals(2, gb.getCustomEnumArray().length); @@ -78,7 +78,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumArrayWithMultipleValuesAsCsv() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumArray", "VALUE_1,VALUE_2"); assertEquals(2, gb.getCustomEnumArray().length); @@ -88,7 +88,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumSetWithSingleValue() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumSet", "VALUE_1"); assertEquals(1, gb.getCustomEnumSet().size()); @@ -97,7 +97,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumSetWithMultipleValues() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumSet", new String[] {"VALUE_1", "VALUE_2"}); assertEquals(2, gb.getCustomEnumSet().size()); @@ -107,7 +107,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumSetWithMultipleValuesAsCsv() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumSet", "VALUE_1,VALUE_2"); assertEquals(2, gb.getCustomEnumSet().size()); @@ -117,7 +117,7 @@ public final class BeanWrapperEnumTests { @Test public void testCustomEnumSetWithGetterSetterMismatch() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumSetMismatch", new String[] {"VALUE_1", "VALUE_2"}); assertEquals(2, gb.getCustomEnumSet().size()); @@ -127,7 +127,7 @@ public final class BeanWrapperEnumTests { @Test public void testStandardEnumSetWithMultipleValues() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setConversionService(new DefaultConversionService()); assertNull(gb.getStandardEnumSet()); @@ -139,7 +139,7 @@ public final class BeanWrapperEnumTests { @Test public void testStandardEnumSetWithAutoGrowing() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setAutoGrowNestedPaths(true); assertNull(gb.getStandardEnumSet()); @@ -149,11 +149,11 @@ public final class BeanWrapperEnumTests { @Test public void testStandardEnumMapWithMultipleValues() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setConversionService(new DefaultConversionService()); assertNull(gb.getStandardEnumMap()); - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); map.put("VALUE_1", 1); map.put("VALUE_2", 2); bw.setPropertyValue("standardEnumMap", map); @@ -164,7 +164,7 @@ public final class BeanWrapperEnumTests { @Test public void testStandardEnumMapWithAutoGrowing() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setAutoGrowNestedPaths(true); assertNull(gb.getStandardEnumMap()); diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java index 4a5edf35754..ac48dbf371b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,9 +51,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericSet() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); bw.setPropertyValue("integerSet", input); @@ -63,10 +63,10 @@ public class BeanWrapperGenericsTests { @Test public void testGenericLowerBoundedSet() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, true)); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); bw.setPropertyValue("numberSet", input); @@ -76,9 +76,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericSetWithConversionFailure() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add(new TestBean()); try { bw.setPropertyValue("integerSet", input); @@ -91,9 +91,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericList() throws MalformedURLException { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); - List input = new ArrayList(); + List input = new ArrayList<>(); input.add("http://localhost:8080"); input.add("http://localhost:9090"); bw.setPropertyValue("resourceList", input); @@ -103,8 +103,8 @@ public class BeanWrapperGenericsTests { @Test public void testGenericListElement() throws MalformedURLException { - GenericBean gb = new GenericBean(); - gb.setResourceList(new ArrayList()); + GenericBean gb = new GenericBean<>(); + gb.setResourceList(new ArrayList<>()); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("resourceList[0]", "http://localhost:8080"); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); @@ -112,9 +112,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMap() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); bw.setPropertyValue("shortMap", input); @@ -124,8 +124,8 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapElement() { - GenericBean gb = new GenericBean(); - gb.setShortMap(new HashMap()); + GenericBean gb = new GenericBean<>(); + gb.setShortMap(new HashMap<>()); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("shortMap[4]", "5"); assertEquals(new Integer(5), bw.getPropertyValue("shortMap[4]")); @@ -134,9 +134,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapWithKeyType() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); bw.setPropertyValue("longMap", input); @@ -146,7 +146,7 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapElementWithKeyType() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); gb.setLongMap(new HashMap()); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("longMap[4]", "5"); @@ -156,14 +156,14 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapWithCollectionValue() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false)); - Map input = new HashMap(); - HashSet value1 = new HashSet(); + Map input = new HashMap<>(); + HashSet value1 = new HashSet<>(); value1.add(new Integer(1)); input.put("1", value1); - ArrayList value2 = new ArrayList(); + ArrayList value2 = new ArrayList<>(); value2.add(Boolean.TRUE); input.put("2", value2); bw.setPropertyValue("collectionMap", input); @@ -173,11 +173,11 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapElementWithCollectionValue() { - GenericBean gb = new GenericBean(); - gb.setCollectionMap(new HashMap>()); + GenericBean gb = new GenericBean<>(); + gb.setCollectionMap(new HashMap<>()); BeanWrapper bw = new BeanWrapperImpl(gb); bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false)); - HashSet value1 = new HashSet(); + HashSet value1 = new HashSet<>(); value1.add(new Integer(1)); bw.setPropertyValue("collectionMap[1]", value1); assertTrue(gb.getCollectionMap().get(new Integer(1)) instanceof HashSet); @@ -185,7 +185,7 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapFromProperties() { - GenericBean gb = new GenericBean(); + GenericBean gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); Properties input = new Properties(); input.setProperty("4", "5"); @@ -197,9 +197,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericListOfLists() throws MalformedURLException { - GenericBean gb = new GenericBean(); - List> list = new LinkedList>(); - list.add(new LinkedList()); + GenericBean gb = new GenericBean<>(); + List> list = new LinkedList<>(); + list.add(new LinkedList<>()); gb.setListOfLists(list); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("listOfLists[0][0]", new Integer(5)); @@ -209,9 +209,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericListOfListsWithElementConversion() throws MalformedURLException { - GenericBean gb = new GenericBean(); - List> list = new LinkedList>(); - list.add(new LinkedList()); + GenericBean gb = new GenericBean<>(); + List> list = new LinkedList<>(); + list.add(new LinkedList<>()); gb.setListOfLists(list); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("listOfLists[0][0]", "5"); @@ -221,8 +221,8 @@ public class BeanWrapperGenericsTests { @Test public void testGenericListOfArrays() throws MalformedURLException { - GenericBean gb = new GenericBean(); - ArrayList list = new ArrayList(); + GenericBean gb = new GenericBean<>(); + ArrayList list = new ArrayList<>(); list.add(new String[] {"str1", "str2"}); gb.setListOfArrays(list); BeanWrapper bw = new BeanWrapperImpl(gb); @@ -233,8 +233,8 @@ public class BeanWrapperGenericsTests { @Test public void testGenericListOfArraysWithElementConversion() throws MalformedURLException { - GenericBean gb = new GenericBean(); - ArrayList list = new ArrayList(); + GenericBean gb = new GenericBean<>(); + ArrayList list = new ArrayList<>(); list.add(new String[] {"str1", "str2"}); gb.setListOfArrays(list); BeanWrapper bw = new BeanWrapperImpl(gb); @@ -246,9 +246,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericListOfMaps() throws MalformedURLException { - GenericBean gb = new GenericBean(); - List> list = new LinkedList>(); - list.add(new HashMap()); + GenericBean gb = new GenericBean<>(); + List> list = new LinkedList<>(); + list.add(new HashMap<>()); gb.setListOfMaps(list); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("listOfMaps[0][10]", new Long(5)); @@ -258,9 +258,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericListOfMapsWithElementConversion() throws MalformedURLException { - GenericBean gb = new GenericBean(); - List> list = new LinkedList>(); - list.add(new HashMap()); + GenericBean gb = new GenericBean<>(); + List> list = new LinkedList<>(); + list.add(new HashMap<>()); gb.setListOfMaps(list); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("listOfMaps[0][10]", "5"); @@ -270,9 +270,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapOfMaps() throws MalformedURLException { - GenericBean gb = new GenericBean(); - Map> map = new HashMap>(); - map.put("mykey", new HashMap()); + GenericBean gb = new GenericBean<>(); + Map> map = new HashMap<>(); + map.put("mykey", new HashMap<>()); gb.setMapOfMaps(map); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("mapOfMaps[mykey][10]", new Long(5)); @@ -282,9 +282,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapOfMapsWithElementConversion() throws MalformedURLException { - GenericBean gb = new GenericBean(); - Map> map = new HashMap>(); - map.put("mykey", new HashMap()); + GenericBean gb = new GenericBean<>(); + Map> map = new HashMap<>(); + map.put("mykey", new HashMap<>()); gb.setMapOfMaps(map); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("mapOfMaps[mykey][10]", "5"); @@ -294,9 +294,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapOfLists() throws MalformedURLException { - GenericBean gb = new GenericBean(); - Map> map = new HashMap>(); - map.put(new Integer(1), new LinkedList()); + GenericBean gb = new GenericBean<>(); + Map> map = new HashMap<>(); + map.put(new Integer(1), new LinkedList<>()); gb.setMapOfLists(map); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("mapOfLists[1][0]", new Integer(5)); @@ -306,9 +306,9 @@ public class BeanWrapperGenericsTests { @Test public void testGenericMapOfListsWithElementConversion() throws MalformedURLException { - GenericBean gb = new GenericBean(); - Map> map = new HashMap>(); - map.put(new Integer(1), new LinkedList()); + GenericBean gb = new GenericBean<>(); + Map> map = new HashMap<>(); + map.put(new Integer(1), new LinkedList<>()); gb.setMapOfLists(map); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("mapOfLists[1][0]", "5"); @@ -318,7 +318,7 @@ public class BeanWrapperGenericsTests { @Test public void testGenericTypeNestingMapOfInteger() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("testKey", "100"); NestedGenericCollectionBean gb = new NestedGenericCollectionBean(); @@ -331,7 +331,7 @@ public class BeanWrapperGenericsTests { @Test public void testGenericTypeNestingMapOfListOfInteger() throws Exception { - Map> map = new HashMap>(); + Map> map = new HashMap<>(); List list = Arrays.asList(new String[] {"1", "2", "3"}); map.put("testKey", list); @@ -346,8 +346,8 @@ public class BeanWrapperGenericsTests { @Test public void testGenericTypeNestingListOfMapOfInteger() throws Exception { - List> list = new LinkedList>(); - Map map = new HashMap(); + List> list = new LinkedList<>(); + Map map = new HashMap<>(); map.put("testKey", "5"); list.add(map); @@ -362,7 +362,7 @@ public class BeanWrapperGenericsTests { @Test public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception { - Map>> map = new HashMap>>(); + Map>> map = new HashMap<>(); List list = Arrays.asList(new String[] {"1", "2", "3"}); map.put("testKey", Collections.singletonList(list)); @@ -377,10 +377,10 @@ public class BeanWrapperGenericsTests { @Test public void testComplexGenericMap() { - Map, List> inputMap = new HashMap, List>(); - List inputKey = new LinkedList(); + Map, List> inputMap = new HashMap<>(); + List inputKey = new LinkedList<>(); inputKey.add("1"); - List inputValue = new LinkedList(); + List inputValue = new LinkedList<>(); inputValue.add("10"); inputMap.put(inputKey, inputValue); @@ -394,10 +394,10 @@ public class BeanWrapperGenericsTests { @Test public void testComplexGenericMapWithCollectionConversion() { - Map, Set> inputMap = new HashMap, Set>(); - Set inputKey = new HashSet(); + Map, Set> inputMap = new HashMap<>(); + Set inputKey = new HashSet<>(); inputKey.add("1"); - Set inputValue = new HashSet(); + Set inputValue = new HashSet<>(); inputValue.add("10"); inputMap.put(inputKey, inputValue); @@ -411,7 +411,7 @@ public class BeanWrapperGenericsTests { @Test public void testComplexGenericIndexedMapEntry() { - List inputValue = new LinkedList(); + List inputValue = new LinkedList<>(); inputValue.add("10"); ComplexMapHolder holder = new ComplexMapHolder(); @@ -424,7 +424,7 @@ public class BeanWrapperGenericsTests { @Test public void testComplexGenericIndexedMapEntryWithCollectionConversion() { - Set inputValue = new HashSet(); + Set inputValue = new HashSet<>(); inputValue.add("10"); ComplexMapHolder holder = new ComplexMapHolder(); @@ -437,7 +437,7 @@ public class BeanWrapperGenericsTests { @Test public void testComplexDerivedIndexedMapEntry() { - List inputValue = new LinkedList(); + List inputValue = new LinkedList<>(); inputValue.add("10"); ComplexMapHolder holder = new ComplexMapHolder(); @@ -450,7 +450,7 @@ public class BeanWrapperGenericsTests { @Test public void testComplexDerivedIndexedMapEntryWithCollectionConversion() { - Set inputValue = new HashSet(); + Set inputValue = new HashSet<>(); inputValue.add("10"); ComplexMapHolder holder = new ComplexMapHolder(); @@ -511,9 +511,9 @@ public class BeanWrapperGenericsTests { } } - Map data = new HashMap(); + Map data = new HashMap<>(); data.put("x", "y"); - Holder> context = new Holder>(data); + Holder> context = new Holder<>(data); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(context); assertEquals("y", bw.getPropertyValue("data['x']")); @@ -586,7 +586,7 @@ public class BeanWrapperGenericsTests { private Map, List> genericMap; - private Map> genericIndexedMap = new HashMap>(); + private Map> genericIndexedMap = new HashMap<>(); private DerivedMap derivedIndexedMap = new DerivedMap(); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java index e93c47ab620..444b16c853b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ public final class ConcurrentBeanFactoryTests { run.setDaemon(true); set.add(run); } - for (Iterator it = new HashSet(set).iterator(); it.hasNext();) { + for (Iterator it = new HashSet<>(set).iterator(); it.hasNext();) { TestRun run = it.next(); run.start(); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index 00e41497aae..5664ba006be 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -2216,7 +2216,7 @@ public class DefaultListableBeanFactoryTests { @Test public void testPrototypeWithArrayConversionForConstructor() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); - List list = new ManagedList(); + List list = new ManagedList<>(); list.add("myName"); list.add("myBeanName"); RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class); @@ -2235,7 +2235,7 @@ public class DefaultListableBeanFactoryTests { @Test public void testPrototypeWithArrayConversionForFactoryMethod() { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); - List list = new ManagedList(); + List list = new ManagedList<>(); list.add("myName"); list.add("myBeanName"); RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java index c731260f652..d954534829f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -272,7 +272,7 @@ public class FactoryBeanTests { public static class CountingPostProcessor implements BeanPostProcessor { - private final Map count = new HashMap(); + private final Map count = new HashMap<>(); @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index 2a4afd0a9d0..c437650945c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -918,7 +918,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { RootBeanDefinition tbm = new RootBeanDefinition(CollectionFactoryMethods.class); tbm.setUniqueFactoryMethodName("testBeanMap"); bf.registerBeanDefinition("myTestBeanMap", tbm); - bf.registerSingleton("otherMap", new HashMap()); + bf.registerSingleton("otherMap", new HashMap<>()); MapConstructorInjectionBean bean = (MapConstructorInjectionBean) bf.getBean("annotatedBean"); assertSame(bf.getBean("myTestBeanMap"), bean.getTestBeanMap()); @@ -940,7 +940,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { tbs.add(new TestBean("tb1")); tbs.add(new TestBean("tb2")); bf.registerSingleton("testBeans", tbs); - bf.registerSingleton("otherSet", new HashSet()); + bf.registerSingleton("otherSet", new HashSet<>()); SetConstructorInjectionBean bean = (SetConstructorInjectionBean) bf.getBean("annotatedBean"); assertSame(tbs, bean.getTestBeanSet()); @@ -961,7 +961,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { RootBeanDefinition tbs = new RootBeanDefinition(CollectionFactoryMethods.class); tbs.setUniqueFactoryMethodName("testBeanSet"); bf.registerBeanDefinition("myTestBeanSet", tbs); - bf.registerSingleton("otherSet", new HashSet()); + bf.registerSingleton("otherSet", new HashSet<>()); SetConstructorInjectionBean bean = (SetConstructorInjectionBean) bf.getBean("annotatedBean"); assertSame(bf.getBean("myTestBeanSet"), bean.getTestBeanSet()); @@ -3101,7 +3101,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { } public static GenericInterface1 createErased() { - return new GenericInterface1Impl(); + return new GenericInterface1Impl<>(); } @SuppressWarnings("rawtypes") @@ -3257,14 +3257,14 @@ public class AutowiredAnnotationBeanPostProcessorTests { public static class CollectionFactoryMethods { public static Map testBeanMap() { - Map tbm = new LinkedHashMap(); + Map tbm = new LinkedHashMap<>(); tbm.put("testBean1", new TestBean("tb1")); tbm.put("testBean2", new TestBean("tb2")); return tbm; } public static Set testBeanSet() { - Set tbs = new LinkedHashSet(); + Set tbs = new LinkedHashSet<>(); tbs.add(new TestBean("tb1")); tbs.add(new TestBean("tb2")); return tbs; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java index 90e08e99ed7..c85d7b2850c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ public final class CustomEditorConfigurerTests { public void testCustomEditorConfigurerWithEditorAsClass() throws ParseException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CustomEditorConfigurer cec = new CustomEditorConfigurer(); - Map, Class> editors = new HashMap, Class>(); + Map, Class> editors = new HashMap<>(); editors.put(Date.class, MyDateEditor.class); cec.setCustomEditors(editors); cec.postProcessBeanFactory(bf); @@ -99,7 +99,7 @@ public final class CustomEditorConfigurerTests { public void testCustomEditorConfigurerWithRequiredTypeArray() throws ParseException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CustomEditorConfigurer cec = new CustomEditorConfigurer(); - Map, Class> editors = new HashMap, Class>(); + Map, Class> editors = new HashMap<>(); editors.put(String[].class, MyTestEditor.class); cec.setCustomEditors(editors); cec.postProcessBeanFactory(bf); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java index 25a9a14a381..62a93b9c4f6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public final class CustomScopeConfigurerTests { public void testSunnyDayWithBonaFideScopeInstance() throws Exception { Scope scope = mock(Scope.class); factory.registerScope(FOO_SCOPE, scope); - Map scopes = new HashMap(); + Map scopes = new HashMap<>(); scopes.put(FOO_SCOPE, scope); CustomScopeConfigurer figurer = new CustomScopeConfigurer(); figurer.setScopes(scopes); @@ -63,7 +63,7 @@ public final class CustomScopeConfigurerTests { @Test public void testSunnyDayWithBonaFideScopeClass() throws Exception { - Map scopes = new HashMap(); + Map scopes = new HashMap<>(); scopes.put(FOO_SCOPE, NoOpScope.class); CustomScopeConfigurer figurer = new CustomScopeConfigurer(); figurer.setScopes(scopes); @@ -73,7 +73,7 @@ public final class CustomScopeConfigurerTests { @Test public void testSunnyDayWithBonaFideScopeClassname() throws Exception { - Map scopes = new HashMap(); + Map scopes = new HashMap<>(); scopes.put(FOO_SCOPE, NoOpScope.class.getName()); CustomScopeConfigurer figurer = new CustomScopeConfigurer(); figurer.setScopes(scopes); @@ -83,7 +83,7 @@ public final class CustomScopeConfigurerTests { @Test(expected=IllegalArgumentException.class) public void testWhereScopeMapHasNullScopeValueInEntrySet() throws Exception { - Map scopes = new HashMap(); + Map scopes = new HashMap<>(); scopes.put(FOO_SCOPE, null); CustomScopeConfigurer figurer = new CustomScopeConfigurer(); figurer.setScopes(scopes); @@ -92,7 +92,7 @@ public final class CustomScopeConfigurerTests { @Test(expected=IllegalArgumentException.class) public void testWhereScopeMapHasNonScopeInstanceInEntrySet() throws Exception { - Map scopes = new HashMap(); + Map scopes = new HashMap<>(); scopes.put(FOO_SCOPE, this); // <-- not a valid value... CustomScopeConfigurer figurer = new CustomScopeConfigurer(); figurer.setScopes(scopes); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java index 4d5b39e569e..980b5f6697f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -148,7 +148,7 @@ public class MethodInvokingFactoryBeanTests { mcfb = new MethodInvokingFactoryBean(); mcfb.setTargetClass(TestClass1.class); mcfb.setTargetMethod("supertypes"); - mcfb.setArguments(new Object[] {new ArrayList(), new ArrayList(), "hello"}); + mcfb.setArguments(new Object[] {new ArrayList<>(), new ArrayList(), "hello"}); mcfb.afterPropertiesSet(); mcfb.getObjectType(); @@ -225,7 +225,7 @@ public class MethodInvokingFactoryBeanTests { mcfb = new MethodInvokingFactoryBean(); mcfb.setTargetClass(TestClass1.class); mcfb.setTargetMethod("supertypes"); - mcfb.setArguments(new Object[] {new ArrayList(), new ArrayList(), "hello"}); + mcfb.setArguments(new Object[] {new ArrayList<>(), new ArrayList(), "hello"}); // should pass mcfb.afterPropertiesSet(); } @@ -235,7 +235,7 @@ public class MethodInvokingFactoryBeanTests { MethodInvokingFactoryBean mcfb = new MethodInvokingFactoryBean(); mcfb.setTargetClass(TestClass1.class); mcfb.setTargetMethod("supertypes"); - mcfb.setArguments(new Object[] {new ArrayList(), new ArrayList(), "hello", "bogus"}); + mcfb.setArguments(new Object[] {new ArrayList<>(), new ArrayList(), "hello", "bogus"}); try { mcfb.afterPropertiesSet(); fail("Matched method with wrong number of args"); @@ -260,14 +260,14 @@ public class MethodInvokingFactoryBeanTests { mcfb = new MethodInvokingFactoryBean(); mcfb.setTargetClass(TestClass1.class); mcfb.setTargetMethod("supertypes2"); - mcfb.setArguments(new Object[] {new ArrayList(), new ArrayList(), "hello", "bogus"}); + mcfb.setArguments(new Object[] {new ArrayList<>(), new ArrayList(), "hello", "bogus"}); mcfb.afterPropertiesSet(); assertEquals("hello", mcfb.getObject()); mcfb = new MethodInvokingFactoryBean(); mcfb.setTargetClass(TestClass1.class); mcfb.setTargetMethod("supertypes2"); - mcfb.setArguments(new Object[] {new ArrayList(), new ArrayList(), new Object()}); + mcfb.setArguments(new Object[] {new ArrayList<>(), new ArrayList(), new Object()}); try { mcfb.afterPropertiesSet(); fail("Matched method when shouldn't have matched"); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index 6cccbc6d015..9a02e5f5b36 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -354,18 +354,18 @@ public class PropertyResourceConfigurerTests { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("stringArray", new String[] {"${os.name}", "${age}"}); - List friends = new ManagedList(); + List friends = new ManagedList<>(); friends.add("na${age}me"); friends.add(new RuntimeBeanReference("${ref}")); pvs.add("friends", friends); - Set someSet = new ManagedSet(); + Set someSet = new ManagedSet<>(); someSet.add("na${age}me"); someSet.add(new RuntimeBeanReference("${ref}")); someSet.add(new TypedStringValue("${age}", Integer.class)); pvs.add("someSet", someSet); - Map someMap = new ManagedMap(); + Map someMap = new ManagedMap<>(); someMap.put(new TypedStringValue("key${age}"), new TypedStringValue("${age}")); someMap.put(new TypedStringValue("key${age}ref"), new RuntimeBeanReference("${ref}")); someMap.put("key1", new RuntimeBeanReference("${ref}")); @@ -805,9 +805,9 @@ public class PropertyResourceConfigurerTests { */ public static class MockPreferences extends AbstractPreferences { - private static Map values = new HashMap(); + private static Map values = new HashMap<>(); - private static Map children = new HashMap(); + private static Map children = new HashMap<>(); public MockPreferences() { super(null, ""); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java index a3ac63a3090..64405f25a19 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public final class SimpleScopeTests { beanFactory = new DefaultListableBeanFactory(); Scope scope = new NoOpScope() { private int index; - private List objects = new LinkedList(); { + private List objects = new LinkedList<>(); { objects.add(new TestBean()); objects.add(new TestBean()); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java index 17455d785ce..65bfd42962c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,9 +66,9 @@ public final class CustomProblemReporterTests { private static class CollatingProblemReporter implements ProblemReporter { - private List errors = new ArrayList(); + private List errors = new ArrayList<>(); - private List warnings = new ArrayList(); + private List warnings = new ArrayList<>(); @Override diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java index 56fcde6ec9c..de645447199 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ public class AutowireUtilsTests { // Ideally we would expect Boolean.class instead of Object.class, but this // information is not available at run-time due to type erasure. - Map map = new HashMap(); + Map map = new HashMap<>(); map.put(0, false); map.put(1, true); Method extractMagicValue = ReflectionUtils.findMethod(MyTypeWithMethods.class, "extractMagicValue", new Class[] { Map.class }); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index ed1b506b7a7..efef1b0ac68 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); rbd.getPropertyValues().add("integerSet", input); @@ -82,7 +82,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - List input = new ArrayList(); + List input = new ArrayList<>(); input.add("http://localhost:8080"); input.add("http://localhost:9090"); rbd.getPropertyValues().add("resourceList", input); @@ -114,7 +114,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class); - List input = new ArrayList(); + List input = new ArrayList<>(); input.add(1); rbd.getPropertyValues().add("testBeanList", input); @@ -146,7 +146,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getPropertyValues().add("shortMap", input); @@ -178,7 +178,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -222,10 +222,10 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); - List input2 = new ArrayList(); + List input2 = new ArrayList<>(); input2.add("http://localhost:8080"); input2.add("http://localhost:9090"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -279,10 +279,10 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); - Map input2 = new HashMap(); + Map input2 = new HashMap<>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -302,7 +302,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -321,10 +321,10 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("1", "0"); input.put("2", "3"); - Map input2 = new HashMap(); + Map input2 = new HashMap<>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -347,7 +347,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("1", "0"); input.put("2", "3"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -370,7 +370,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put(new Short((short) 1), new Integer(0)); input.put(new Short((short) 2), new Integer(3)); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -390,7 +390,7 @@ public class BeanFactoryGenericsTests { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -413,11 +413,11 @@ public class BeanFactoryGenericsTests { }); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); - Map> input = new HashMap>(); - HashSet value1 = new HashSet(); + Map> input = new HashMap<>(); + HashSet value1 = new HashSet<>(); value1.add(new Integer(1)); input.put("1", value1); - ArrayList value2 = new ArrayList(); + ArrayList value2 = new ArrayList<>(); value2.add(Boolean.TRUE); input.put("2", value2); rbd.getConstructorArgumentValues().addGenericArgumentValue(Boolean.TRUE); @@ -437,7 +437,7 @@ public class BeanFactoryGenericsTests { RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -455,10 +455,10 @@ public class BeanFactoryGenericsTests { RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); - List input2 = new ArrayList(); + List input2 = new ArrayList<>(); input2.add("http://localhost:8080"); input2.add("http://localhost:9090"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -479,10 +479,10 @@ public class BeanFactoryGenericsTests { RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); - Set input = new HashSet(); + Set input = new HashSet<>(); input.add("4"); input.add("5"); - Map input2 = new HashMap(); + Map input2 = new HashMap<>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -503,7 +503,7 @@ public class BeanFactoryGenericsTests { RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -523,10 +523,10 @@ public class BeanFactoryGenericsTests { RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("1", "0"); input.put("2", "3"); - Map input2 = new HashMap(); + Map input2 = new HashMap<>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -547,7 +547,7 @@ public class BeanFactoryGenericsTests { RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); - Map input = new HashMap(); + Map input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); @@ -571,11 +571,11 @@ public class BeanFactoryGenericsTests { RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); - Map> input = new HashMap>(); - HashSet value1 = new HashSet(); + Map> input = new HashMap<>(); + HashSet value1 = new HashSet<>(); value1.add(new Integer(1)); input.put("1", value1); - ArrayList value2 = new ArrayList(); + ArrayList value2 = new ArrayList<>(); value2.add(Boolean.TRUE); input.put("2", value2); rbd.getConstructorArgumentValues().addGenericArgumentValue(Boolean.TRUE); diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java index 806b6f3fa2f..0abe5ea491d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1362,7 +1362,7 @@ public class CustomEditorTests { bw.registerCustomEditor(List.class, "list", new PropertyEditorSupport() { @Override public void setAsText(String text) throws IllegalArgumentException { - List result = new ArrayList(); + List result = new ArrayList<>(); result.add(new TestBean("list" + text, 99)); setValue(result); } @@ -1397,7 +1397,7 @@ public class CustomEditorTests { PropertyEditor pe = new CustomNumberEditor(Integer.class, true); bw.registerCustomEditor(null, "list.age", pe); TestBean tb = new TestBean(); - bw.setPropertyValue("list", new ArrayList()); + bw.setPropertyValue("list", new ArrayList<>()); bw.setPropertyValue("list[0]", tb); assertEquals(tb, bean.getList().get(0)); assertEquals(pe, bw.findCustomEditor(int.class, "list.age")); diff --git a/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java b/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java index 09d74c73f4b..a217040d1df 100644 --- a/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class PropertyComparatorTests { @SuppressWarnings("unchecked") @Test public void testCompoundComparator() { - CompoundComparator c = new CompoundComparator(); + CompoundComparator c = new CompoundComparator<>(); c.addComparator(new PropertyComparator("lastName", false, true)); Dog dog1 = new Dog(); @@ -80,7 +80,7 @@ public class PropertyComparatorTests { @SuppressWarnings("unchecked") @Test public void testCompoundComparatorInvert() { - CompoundComparator c = new CompoundComparator(); + CompoundComparator c = new CompoundComparator<>(); c.addComparator(new PropertyComparator("lastName", false, true)); c.addComparator(new PropertyComparator("firstName", false, true)); Dog dog1 = new Dog(); diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericBean.java b/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericBean.java index e74e709cf60..3f63617c814 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericBean.java +++ b/spring-beans/src/test/java/org/springframework/tests/sample/beans/GenericBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -267,7 +267,7 @@ public class GenericBean { } public void setCustomEnumSetMismatch(Set customEnumSet) { - this.customEnumSet = new HashSet(customEnumSet.size()); + this.customEnumSet = new HashSet<>(customEnumSet.size()); for (Iterator iterator = customEnumSet.iterator(); iterator.hasNext(); ) { this.customEnumSet.add(CustomEnum.valueOf(iterator.next())); } diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IndexedTestBean.java b/spring-beans/src/test/java/org/springframework/tests/sample/beans/IndexedTestBean.java index d319bbd0eda..cc234cc1638 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IndexedTestBean.java +++ b/spring-beans/src/test/java/org/springframework/tests/sample/beans/IndexedTestBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,13 +69,13 @@ public class IndexedTestBean { TestBean tbX = new TestBean("nameX", 0); TestBean tbY = new TestBean("nameY", 0); this.array = new TestBean[] {tb0, tb1}; - this.list = new ArrayList(); + this.list = new ArrayList<>(); this.list.add(tb2); this.list.add(tb3); - this.set = new TreeSet(); + this.set = new TreeSet<>(); this.set.add(tb6); this.set.add(tb7); - this.map = new HashMap(); + this.map = new HashMap<>(); this.map.put("key1", tb4); this.map.put("key2", tb5); this.map.put("key.3", tb5); diff --git a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java index bedcff29e6b..15ebcb91acf 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/caffeine/CaffeineCacheManager.java @@ -54,7 +54,7 @@ import org.springframework.util.ObjectUtils; */ public class CaffeineCacheManager implements CacheManager { - private final ConcurrentMap cacheMap = new ConcurrentHashMap(16); + private final ConcurrentMap cacheMap = new ConcurrentHashMap<>(16); private boolean dynamic = true; diff --git a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java index 44ca01b25e2..dc4177f1475 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag } String[] names = getCacheManager().getCacheNames(); - Collection caches = new LinkedHashSet(names.length); + Collection caches = new LinkedHashSet<>(names.length); for (String name : names) { caches.add(new EhCacheCache(getCacheManager().getEhcache(name))); } diff --git a/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java index 26092ee3ead..b27f86def97 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ import org.springframework.util.ObjectUtils; */ public class GuavaCacheManager implements CacheManager { - private final ConcurrentMap cacheMap = new ConcurrentHashMap(16); + private final ConcurrentMap cacheMap = new ConcurrentHashMap<>(16); private boolean dynamic = true; diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java index 9c324efcddf..6b95a18c0a6 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,7 +100,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage @Override protected Collection loadCaches() { - Collection caches = new LinkedHashSet(); + Collection caches = new LinkedHashSet<>(); for (String cacheName : getCacheManager().getCacheNames()) { javax.cache.Cache jcache = getCacheManager().getCache(cacheName); caches.add(new JCacheCache(jcache, isAllowNullValues())); diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java index 73313d22c5f..875a55540d5 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractFallbackJCacheOperationSource.java @@ -51,7 +51,7 @@ public abstract class AbstractFallbackJCacheOperationSource implements JCacheOpe protected final Log logger = LogFactory.getLog(getClass()); - private final Map cache = new ConcurrentHashMap(1024); + private final Map cache = new ConcurrentHashMap<>(1024); @Override diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheKeyOperation.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheKeyOperation.java index e06ece9300f..40cb70e5f6a 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheKeyOperation.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheKeyOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ abstract class AbstractJCacheKeyOperation extends Abstract * used to compute the key */ public CacheInvocationParameter[] getKeyParameters(Object... values) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) { int parameterPosition = keyParameterDetail.getParameterPosition(); if (parameterPosition >= values.length) { @@ -87,8 +87,8 @@ abstract class AbstractJCacheKeyOperation extends Abstract private static List initializeKeyParameterDetails(List allParameters) { - List all = new ArrayList(); - List annotated = new ArrayList(); + List all = new ArrayList<>(); + List annotated = new ArrayList<>(); for (CacheParameterDetail allParameter : allParameters) { if (!allParameter.isValue()) { all.add(allParameter); diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheOperation.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheOperation.java index 6db0afb80ed..79b32dc4e6b 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheOperation.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ abstract class AbstractJCacheOperation implements JCacheOp throw new IllegalStateException("Values mismatch, operation has " + this.allParameterDetails.size() + " parameter(s) but got " + values.length + " value(s)"); } - List result = new ArrayList(); + List result = new ArrayList<>(); for (int i = 0; i < this.allParameterDetails.size(); i++) { result.add(this.allParameterDetails.get(i).toCacheInvocationParameter(values[i])); } @@ -138,7 +138,7 @@ abstract class AbstractJCacheOperation implements JCacheOp private static List initializeAllParameterDetails(Method method) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (int i = 0; i < method.getParameterTypes().length; i++) { CacheParameterDetail detail = new CacheParameterDetail(method, i); result.add(detail); @@ -161,7 +161,7 @@ abstract class AbstractJCacheOperation implements JCacheOp public CacheParameterDetail(Method method, int parameterPosition) { this.rawType = method.getParameterTypes()[parameterPosition]; - this.annotations = new LinkedHashSet(); + this.annotations = new LinkedHashSet<>(); boolean foundKeyAnnotation = false; boolean foundValueAnnotation = false; for (Annotation annotation : method.getParameterAnnotations()[parameterPosition]) { diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractKeyCacheInterceptor.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractKeyCacheInterceptor.java index b3870ed539c..b6d1d704505 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractKeyCacheInterceptor.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractKeyCacheInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ abstract class AbstractKeyCacheInterceptor createCacheKeyInvocationContext( CacheOperationInvocationContext context) { - return new DefaultCacheKeyInvocationContext(context.getOperation(), context.getTarget(), context.getArgs()); + return new DefaultCacheKeyInvocationContext<>(context.getOperation(), context.getTarget(), context.getArgs()); } } diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java index ffc199b81a4..9f75bce7c9d 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,7 +132,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC } private CacheMethodDetails createMethodDetails(Method method, A annotation, String cacheName) { - return new DefaultCacheMethodDetails(method, annotation, cacheName); + return new DefaultCacheMethodDetails<>(method, annotation, cacheName); } protected CacheResolver getCacheResolver(CacheResolverFactory factory, CacheMethodDetails details) { @@ -200,7 +200,7 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC */ protected String generateDefaultCacheName(Method method) { Class[] parameterTypes = method.getParameterTypes(); - List parameters = new ArrayList(parameterTypes.length); + List parameters = new ArrayList<>(parameterTypes.length); for (Class parameterType : parameterTypes) { parameters.add(parameterType.getName()); } diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheMethodDetails.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheMethodDetails.java index b60fb2a59de..5f7568a80ed 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheMethodDetails.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheMethodDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ class DefaultCacheMethodDetails implements CacheMethodDeta public DefaultCacheMethodDetails(Method method, A cacheAnnotation, String cacheName) { this.method = method; this.annotations = Collections.unmodifiableSet( - new LinkedHashSet(asList(method.getAnnotations()))); + new LinkedHashSet<>(asList(method.getAnnotations()))); this.cacheAnnotation = cacheAnnotation; this.cacheName = cacheName; } diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java index b20f7bbe25e..8ea51aaebc2 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheAspectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,7 +110,7 @@ public class JCacheAspectSupport extends AbstractCacheInvoker implements Initial private CacheOperationInvocationContext createCacheOperationInvocationContext( Object target, Object[] args, JCacheOperation operation) { - return new DefaultCacheInvocationContext( + return new DefaultCacheInvocationContext<>( (JCacheOperation) operation, target, args); } diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java index 42db86cefdb..706e157b720 100644 --- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java +++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cache.jcache.interceptor; import java.lang.annotation.Annotation; @@ -77,7 +93,7 @@ class KeyGeneratorAdapter implements KeyGenerator { @SuppressWarnings("unchecked") private static Object doGenerate(KeyGenerator keyGenerator, CacheKeyInvocationContext context) { - List parameters = new ArrayList(); + List parameters = new ArrayList<>(); for (CacheInvocationParameter param : context.getKeyParameters()) { Object value = param.getValue(); if (param.getParameterPosition() == context.getAllParameters().length - 1 && @@ -98,7 +114,7 @@ class KeyGeneratorAdapter implements KeyGenerator { private CacheKeyInvocationContext createCacheKeyInvocationContext(Object target, JCacheOperation operation, Object[] params) { AbstractJCacheKeyOperation keyCacheOperation = (AbstractJCacheKeyOperation) operation; - return new DefaultCacheKeyInvocationContext(keyCacheOperation, target, params); + return new DefaultCacheKeyInvocationContext<>(keyCacheOperation, target, params); } } diff --git a/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java b/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java index 4820c270a2d..dce65956d03 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java +++ b/spring-context-support/src/main/java/org/springframework/mail/MailSendException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class MailSendException extends MailException { */ public MailSendException(String msg, Throwable cause) { super(msg, cause); - this.failedMessages = new LinkedHashMap(); + this.failedMessages = new LinkedHashMap<>(); } /** @@ -68,7 +68,7 @@ public class MailSendException extends MailException { */ public MailSendException(String msg, Throwable cause, Map failedMessages) { super(msg, cause); - this.failedMessages = new LinkedHashMap(failedMessages); + this.failedMessages = new LinkedHashMap<>(failedMessages); this.messageExceptions = failedMessages.values().toArray(new Exception[failedMessages.size()]); } diff --git a/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java b/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java index 7d642be0016..7107f1f6c15 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java +++ b/spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -298,7 +298,7 @@ public class JavaMailSenderImpl implements JavaMailSender { @Override public void send(SimpleMailMessage... simpleMessages) throws MailException { - List mimeMessages = new ArrayList(simpleMessages.length); + List mimeMessages = new ArrayList<>(simpleMessages.length); for (SimpleMailMessage simpleMessage : simpleMessages) { MimeMailMessage message = new MimeMailMessage(createMimeMessage()); simpleMessage.copyTo(message); @@ -353,7 +353,7 @@ public class JavaMailSenderImpl implements JavaMailSender { @Override public void send(MimeMessagePreparator... mimeMessagePreparators) throws MailException { try { - List mimeMessages = new ArrayList(mimeMessagePreparators.length); + List mimeMessages = new ArrayList<>(mimeMessagePreparators.length); for (MimeMessagePreparator preparator : mimeMessagePreparators) { MimeMessage mimeMessage = createMimeMessage(); preparator.prepare(mimeMessage); @@ -400,7 +400,7 @@ public class JavaMailSenderImpl implements JavaMailSender { * in case of failure when sending a message */ protected void doSend(MimeMessage[] mimeMessages, Object[] originalMessages) throws MailException { - Map failedMessages = new LinkedHashMap(); + Map failedMessages = new LinkedHashMap<>(); Transport transport = null; try { diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java index 3b67a93f95a..cc3ade75e1c 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public class TimerManagerFactoryBean extends TimerManagerAccessor private ScheduledTimerListener[] scheduledTimerListeners; - private final List timers = new LinkedList(); + private final List timers = new LinkedList<>(); /** diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java index f39d7262928..90d30aa48a7 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java @@ -160,28 +160,28 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport @Override public Future submit(Runnable task) { - FutureTask future = new FutureTask(task, null); + FutureTask future = new FutureTask<>(task, null); execute(future); return future; } @Override public Future submit(Callable task) { - FutureTask future = new FutureTask(task); + FutureTask future = new FutureTask<>(task); execute(future); return future; } @Override public ListenableFuture submitListenable(Runnable task) { - ListenableFutureTask future = new ListenableFutureTask(task, null); + ListenableFutureTask future = new ListenableFutureTask<>(task, null); execute(future); return future; } @Override public ListenableFuture submitListenable(Callable task) { - ListenableFutureTask future = new ListenableFutureTask(task); + ListenableFutureTask future = new ListenableFutureTask<>(task); execute(future); return future; } diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java index f29ca069721..55036e3cc90 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,7 +125,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware { public void setJobDetails(JobDetail... jobDetails) { // Use modifiable ArrayList here, to allow for further adding of // JobDetail objects during autodetection of JobDetail-aware Triggers. - this.jobDetails = new ArrayList(Arrays.asList(jobDetails)); + this.jobDetails = new ArrayList<>(Arrays.asList(jobDetails)); } /** @@ -218,7 +218,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware { } else { // Create empty list for easier checks when registering triggers. - this.jobDetails = new LinkedList(); + this.jobDetails = new LinkedList<>(); } // Register Calendars. diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java index c3f85ae80c5..74a648f008f 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,16 +94,16 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe private static final ThreadLocal configTimeResourceLoaderHolder = - new ThreadLocal(); + new ThreadLocal<>(); private static final ThreadLocal configTimeTaskExecutorHolder = - new ThreadLocal(); + new ThreadLocal<>(); private static final ThreadLocal configTimeDataSourceHolder = - new ThreadLocal(); + new ThreadLocal<>(); private static final ThreadLocal configTimeNonTransactionalDataSourceHolder = - new ThreadLocal(); + new ThreadLocal<>(); /** * Return the ResourceLoader for the currently configured Quartz Scheduler, diff --git a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java index 0e7b7952528..458f5c3c137 100644 --- a/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java +++ b/spring-context-support/src/main/java/org/springframework/scheduling/quartz/SimpleThreadPoolTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,28 +83,28 @@ public class SimpleThreadPoolTaskExecutor extends SimpleThreadPool @Override public Future submit(Runnable task) { - FutureTask future = new FutureTask(task, null); + FutureTask future = new FutureTask<>(task, null); execute(future); return future; } @Override public Future submit(Callable task) { - FutureTask future = new FutureTask(task); + FutureTask future = new FutureTask<>(task); execute(future); return future; } @Override public ListenableFuture submitListenable(Runnable task) { - ListenableFutureTask future = new ListenableFutureTask(task, null); + ListenableFutureTask future = new ListenableFutureTask<>(task, null); execute(future); return future; } @Override public ListenableFuture submitListenable(Callable task) { - ListenableFutureTask future = new ListenableFutureTask(task); + ListenableFutureTask future = new ListenableFutureTask<>(task); execute(future); return future; } diff --git a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java index 9cb27d29794..ee6e7459a66 100644 --- a/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java +++ b/spring-context-support/src/main/java/org/springframework/ui/freemarker/FreeMarkerConfigurationFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class FreeMarkerConfigurationFactory { private String defaultEncoding; - private final List templateLoaders = new ArrayList(); + private final List templateLoaders = new ArrayList<>(); private List preTemplateLoaders; @@ -277,7 +277,7 @@ public class FreeMarkerConfigurationFactory { config.setDefaultEncoding(this.defaultEncoding); } - List templateLoaders = new LinkedList(this.templateLoaders); + List templateLoaders = new LinkedList<>(this.templateLoaders); // Register template loaders that are supposed to kick in early. if (this.preTemplateLoaders != null) { diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java index 19c65efca6d..ca587a9175f 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public abstract class AbstractJCacheTests { protected static CacheManager createSimpleCacheManager(String... cacheNames) { SimpleCacheManager result = new SimpleCacheManager(); - List caches = new ArrayList(); + List caches = new ArrayList<>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java index 734622672fd..e81fb50d682 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM private final CacheManager cacheManager; private CacheManagerMock() { - this.cacheNames = new ArrayList(); + this.cacheNames = new ArrayList<>(); this.cacheManager = mock(CacheManager.class); given(cacheManager.getCacheNames()).willReturn(cacheNames); } diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java index 8b207f0262f..caf28ca08d2 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,7 +93,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { @Bean public CacheManager jCacheManager() { CacheManager cacheManager = this.cachingProvider.getCacheManager(); - MutableConfiguration mutableConfiguration = new MutableConfiguration(); + MutableConfiguration mutableConfiguration = new MutableConfiguration<>(); mutableConfiguration.setStoreByValue(false); // otherwise value has to be Serializable cacheManager.createCache("testCache", mutableConfiguration); cacheManager.createCache("primary", mutableConfiguration); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java index e784ecb1cd9..d885d818271 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ public abstract class AbstractCacheOperationTests> Method method = ReflectionUtils.findMethod(targetType, methodName, parameterTypes); Assert.notNull(method, "requested method '" + methodName + "'does not exist"); A cacheAnnotation = method.getAnnotation(annotationType); - return new DefaultCacheMethodDetails(method, cacheAnnotation, getCacheName(cacheAnnotation)); + return new DefaultCacheMethodDetails<>(method, cacheAnnotation, getCacheName(cacheAnnotation)); } private static String getCacheName(Annotation annotation) { diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java index b15c215f7e8..8f9031c811f 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests { new DefaultCacheMethodDetails<>(method, cacheAnnotation, "test"); CacheResultOperation operation = new CacheResultOperation(methodDetails, defaultCacheResolver, defaultKeyGenerator, defaultExceptionCacheResolver); - return new DefaultCacheInvocationContext(operation, new Sample(), new Object[] {"id"}); + return new DefaultCacheInvocationContext<>(operation, new Sample(), new Object[] {"id"}); } diff --git a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java index 4c0d2a5da00..623831d7508 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -180,7 +180,7 @@ public class JavaMailSenderTests { sender.setUsername("username"); sender.setPassword("password"); - final List messages = new ArrayList(); + final List messages = new ArrayList<>(); MimeMessagePreparator preparator = new MimeMessagePreparator() { @Override @@ -206,7 +206,7 @@ public class JavaMailSenderTests { sender.setUsername("username"); sender.setPassword("password"); - final List messages = new ArrayList(); + final List messages = new ArrayList<>(); MimeMessagePreparator preparator1 = new MimeMessagePreparator() { @Override @@ -533,7 +533,7 @@ public class JavaMailSenderTests { private String connectedUsername = null; private String connectedPassword = null; private boolean closeCalled = false; - private List sentMessages = new ArrayList(); + private List sentMessages = new ArrayList<>(); private MockTransport(Session session, URLName urlName) { super(session, urlName); diff --git a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java index 3825918656d..29f278ec8cd 100644 --- a/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public class QuartzSupportTests { } }; schedulerFactoryBean.setJobFactory(null); - Map schedulerContextMap = new HashMap(); + Map schedulerContextMap = new HashMap<>(); schedulerContextMap.put("testBean", tb); schedulerFactoryBean.setSchedulerContextAsMap(schedulerContextMap); schedulerFactoryBean.setApplicationContext(ac); diff --git a/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java b/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java index 89f4614b89b..5810cf86683 100644 --- a/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java +++ b/spring-context-support/src/test/java/org/springframework/ui/jasperreports/JasperReportsUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class JasperReportsUtilsTests { @Test public void renderAsCsvWithExporterParameters() throws Exception { StringWriter writer = new StringWriter(); - Map exporterParameters = new HashMap(); + Map exporterParameters = new HashMap<>(); exporterParameters.put(JRCsvExporterParameter.FIELD_DELIMITER, "~"); JasperReportsUtils.renderAsCsv(getReport(), getParameters(), getData(), writer, exporterParameters); String output = writer.getBuffer().toString(); @@ -112,7 +112,7 @@ public class JasperReportsUtilsTests { @Test public void renderAsHtmlWithExporterParameters() throws Exception { StringWriter writer = new StringWriter(); - Map exporterParameters = new HashMap(); + Map exporterParameters = new HashMap<>(); String uri = "/my/uri"; exporterParameters.put(JRHtmlExporterParameter.IMAGES_URI, uri); JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getData(), writer, exporterParameters); @@ -140,7 +140,7 @@ public class JasperReportsUtilsTests { @Test public void renderAsPdfWithExporterParameters() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); - Map exporterParameters = new HashMap(); + Map exporterParameters = new HashMap<>(); exporterParameters.put(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_6.toString()); JasperReportsUtils.renderAsPdf(getReport(), getParameters(), getData(), os, exporterParameters); byte[] output = os.toByteArray(); @@ -167,7 +167,7 @@ public class JasperReportsUtilsTests { @Test public void renderAsXlsWithExporterParameters() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); - Map exporterParameters = new HashMap(); + Map exporterParameters = new HashMap<>(); SimpleProgressMonitor monitor = new SimpleProgressMonitor(); exporterParameters.put(JRXlsExporterParameter.PROGRESS_MONITOR, monitor); @@ -232,7 +232,7 @@ public class JasperReportsUtilsTests { } private Map getParameters() { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("ReportTitle", "Dear Lord!"); model.put(JRParameter.REPORT_LOCALE, Locale.GERMAN); model.put(JRParameter.REPORT_RESOURCE_BUNDLE, @@ -245,7 +245,7 @@ public class JasperReportsUtilsTests { } private List getData() { - List list = new ArrayList(); + List list = new ArrayList<>(); for (int x = 0; x < 10; x++) { PersonBean bean = new PersonBean(); bean.setId(x); diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java index 438c8e633fe..858bbbbc274 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/AnnotationCacheOperationSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati */ public AnnotationCacheOperationSource(boolean publicMethodsOnly) { this.publicMethodsOnly = publicMethodsOnly; - this.annotationParsers = new LinkedHashSet(1); + this.annotationParsers = new LinkedHashSet<>(1); this.annotationParsers.add(new SpringCacheAnnotationParser()); } @@ -89,7 +89,7 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati public AnnotationCacheOperationSource(CacheAnnotationParser... annotationParsers) { this.publicMethodsOnly = true; Assert.notEmpty(annotationParsers, "At least one CacheAnnotationParser needs to be specified"); - Set parsers = new LinkedHashSet(annotationParsers.length); + Set parsers = new LinkedHashSet<>(annotationParsers.length); Collections.addAll(parsers, annotationParsers); this.annotationParsers = parsers; } @@ -142,7 +142,7 @@ public class AnnotationCacheOperationSource extends AbstractFallbackCacheOperati Collection annOps = provider.getCacheOperations(annotationParser); if (annOps != null) { if (ops == null) { - ops = new ArrayList(); + ops = new ArrayList<>(); } ops.addAll(annOps); } diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java index f7f6fa4ec7c..bbe86bb7aa1 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/CachingConfigurationSelector.java @@ -78,7 +78,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelectorTake care of adding the necessary JSR-107 import if it is available. */ private String[] getProxyImports() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.add(AutoProxyRegistrar.class.getName()); result.add(ProxyCachingConfiguration.class.getName()); if (jsr107Present && jcacheImplPresent) { @@ -92,7 +92,7 @@ public class CachingConfigurationSelector extends AdviceModeImportSelectorTake care of adding the necessary JSR-107 import if it is available. */ private String[] getAspectJImports() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.add(CACHE_ASPECT_CONFIGURATION_CLASS_NAME); if (jsr107Present && jcacheImplPresent) { result.add(JCACHE_ASPECT_CONFIGURATION_CLASS_NAME); diff --git a/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java b/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java index d58bd1337fc..544710d0d0b 100644 --- a/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java +++ b/spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java @@ -98,7 +98,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria } private Collection lazyInit(Collection ops) { - return (ops != null ? ops : new ArrayList(1)); + return (ops != null ? ops : new ArrayList<>(1)); } CacheableOperation parseCacheableAnnotation(AnnotatedElement ae, DefaultCacheConfig defaultConfig, Cacheable cacheable) { diff --git a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java index cce957b3779..f8314a2ad45 100644 --- a/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/concurrent/ConcurrentMapCacheManager.java @@ -48,7 +48,7 @@ import org.springframework.core.serializer.support.SerializationDelegate; */ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderAware { - private final ConcurrentMap cacheMap = new ConcurrentHashMap(16); + private final ConcurrentMap cacheMap = new ConcurrentHashMap<>(16); private boolean dynamic = true; @@ -188,7 +188,7 @@ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderA */ protected Cache createConcurrentMapCache(String name) { SerializationDelegate actualSerialization = (isStoreByValue() ? this.serialization : null); - return new ConcurrentMapCache(name, new ConcurrentHashMap(256), + return new ConcurrentMapCache(name, new ConcurrentHashMap<>(256), isAllowNullValues(), actualSerialization); } diff --git a/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java b/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java index f4a626a7ecb..b8864b70054 100644 --- a/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java +++ b/spring-context/src/main/java/org/springframework/cache/config/CacheAdviceParser.java @@ -84,7 +84,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { } private List parseDefinitionsSources(List definitions, ParserContext parserContext) { - ManagedList defs = new ManagedList(definitions.size()); + ManagedList defs = new ManagedList<>(definitions.size()); // extract default param for the definition for (Element element : definitions) { @@ -98,7 +98,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { Props prop = new Props(definition); // add cacheable first - ManagedMap> cacheOpMap = new ManagedMap>(); + ManagedMap> cacheOpMap = new ManagedMap<>(); cacheOpMap.setSource(parserContext.extractSource(definition)); List cacheableCacheMethods = DomUtils.getChildElementsByTagName(definition, CACHEABLE_ELEMENT); @@ -114,7 +114,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { Collection col = cacheOpMap.get(nameHolder); if (col == null) { - col = new ArrayList(2); + col = new ArrayList<>(2); cacheOpMap.put(nameHolder, col); } col.add(builder.build()); @@ -141,7 +141,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { Collection col = cacheOpMap.get(nameHolder); if (col == null) { - col = new ArrayList(2); + col = new ArrayList<>(2); cacheOpMap.put(nameHolder, col); } col.add(builder.build()); @@ -159,7 +159,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser { Collection col = cacheOpMap.get(nameHolder); if (col == null) { - col = new ArrayList(2); + col = new ArrayList<>(2); cacheOpMap.put(nameHolder, col); } col.add(builder.build()); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java index 0ddb97460ac..3f018f46b6b 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractCacheResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi return Collections.emptyList(); } else { - Collection result = new ArrayList(); + Collection result = new ArrayList<>(); for (String cacheName : cacheNames) { Cache cache = this.cacheManager.getCache(cacheName); if (cache == null) { diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java index 88d0aec5f70..cee063acdb3 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java @@ -71,7 +71,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera * after serialization - provided that the concrete subclass is Serializable. */ private final Map> attributeCache = - new ConcurrentHashMap>(1024); + new ConcurrentHashMap<>(1024); /** diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java index 5da6ee095a0..078e3029ebd 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java @@ -83,7 +83,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker protected final Log logger = LogFactory.getLog(getClass()); private final Map metadataCache = - new ConcurrentHashMap(1024); + new ConcurrentHashMap<>(1024); private final CacheOperationExpressionEvaluator evaluator = new CacheOperationExpressionEvaluator(); @@ -368,7 +368,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker Cache.ValueWrapper cacheHit = findCachedItem(contexts.get(CacheableOperation.class)); // Collect puts from any @Cacheable miss, if no cached item is found - List cachePutRequests = new LinkedList(); + List cachePutRequests = new LinkedList<>(); if (cacheHit == null) { collectPutRequests(contexts.get(CacheableOperation.class), CacheOperationExpressionEvaluator.NO_RESULT, cachePutRequests); @@ -411,7 +411,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker private boolean hasCachePut(CacheOperationContexts contexts) { // Evaluate the conditions *without* the result object because we don't have it yet... Collection cachePutContexts = contexts.get(CachePutOperation.class); - Collection excluded = new ArrayList(); + Collection excluded = new ArrayList<>(); for (CacheOperationContext context : cachePutContexts) { try { if (!context.isConditionPassing(CacheOperationExpressionEvaluator.RESULT_UNAVAILABLE)) { @@ -540,7 +540,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker private class CacheOperationContexts { private final MultiValueMap, CacheOperationContext> contexts = - new LinkedMultiValueMap, CacheOperationContext>(); + new LinkedMultiValueMap<>(); private final boolean sync; @@ -728,7 +728,7 @@ public abstract class CacheAspectSupport extends AbstractCacheInvoker } private Collection createCacheNames(Collection caches) { - Collection names = new ArrayList(); + Collection names = new ArrayList<>(); for (Cache cache : caches) { names.add(cache.getName()); } diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheEvaluationContext.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheEvaluationContext.java index 8d65e15eae9..9aca05d04ff 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheEvaluationContext.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheEvaluationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ class CacheEvaluationContext extends MethodBasedEvaluationContext { ParameterNameDiscoverer paramDiscoverer) { super(rootObject, method, args, paramDiscoverer); - this.unavailableVariables = new ArrayList(); + this.unavailableVariables = new ArrayList<>(); } /** diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperation.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperation.java index 271b59f1e65..dca82086670 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperation.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperation.java @@ -155,7 +155,7 @@ public abstract class CacheOperation implements BasicOperation { } public void setCacheNames(String... cacheNames) { - this.cacheNames = new LinkedHashSet(cacheNames.length); + this.cacheNames = new LinkedHashSet<>(cacheNames.length); for (String cacheName : cacheNames) { Assert.hasText(cacheName, "Cache name must be non-null if specified"); this.cacheNames.add(cacheName); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationExpressionEvaluator.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationExpressionEvaluator.java index 9111bab0ca6..0e3de59b5b5 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationExpressionEvaluator.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CacheOperationExpressionEvaluator.java @@ -61,14 +61,14 @@ class CacheOperationExpressionEvaluator extends CachedExpressionEvaluator { public static final String RESULT_VARIABLE = "result"; - private final Map keyCache = new ConcurrentHashMap(64); + private final Map keyCache = new ConcurrentHashMap<>(64); - private final Map conditionCache = new ConcurrentHashMap(64); + private final Map conditionCache = new ConcurrentHashMap<>(64); - private final Map unlessCache = new ConcurrentHashMap(64); + private final Map unlessCache = new ConcurrentHashMap<>(64); private final Map targetMethodCache = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); /** diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java index a18db38b1d5..4bf1abe3fa7 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/CompositeCacheOperationSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri Collection cacheOperations = source.getCacheOperations(method, targetClass); if (cacheOperations != null) { if (ops == null) { - ops = new ArrayList(); + ops = new ArrayList<>(); } ops.addAll(cacheOperations); diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java index 2e26d932a12..c4371e49cf2 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri /** Keys are method names; values are TransactionAttributes */ - private Map> nameMap = new LinkedHashMap>(); + private Map> nameMap = new LinkedHashMap<>(); /** diff --git a/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java b/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java index f75fd2e8c16..06673979bbc 100644 --- a/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java +++ b/spring-context/src/main/java/org/springframework/cache/interceptor/NamedCacheResolver.java @@ -36,7 +36,7 @@ public class NamedCacheResolver extends AbstractCacheResolver { public NamedCacheResolver(CacheManager cacheManager, String... cacheNames) { super(cacheManager); - this.cacheNames = new ArrayList(Arrays.asList(cacheNames)); + this.cacheNames = new ArrayList<>(Arrays.asList(cacheNames)); } public NamedCacheResolver() { diff --git a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java index 93bfcc41041..4bb80ca4a1b 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/AbstractCacheManager.java @@ -38,7 +38,7 @@ import org.springframework.cache.CacheManager; */ public abstract class AbstractCacheManager implements CacheManager, InitializingBean { - private final ConcurrentMap cacheMap = new ConcurrentHashMap(16); + private final ConcurrentMap cacheMap = new ConcurrentHashMap<>(16); private volatile Set cacheNames = Collections.emptySet(); @@ -63,7 +63,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing synchronized (this.cacheMap) { this.cacheNames = Collections.emptySet(); this.cacheMap.clear(); - Set cacheNames = new LinkedHashSet(caches.size()); + Set cacheNames = new LinkedHashSet<>(caches.size()); for (Cache cache : caches) { String name = cache.getName(); this.cacheMap.put(name, decorateCache(cache)); @@ -136,7 +136,7 @@ public abstract class AbstractCacheManager implements CacheManager, Initializing * @param name the name of the cache to be added */ private void updateCacheNames(String name) { - Set cacheNames = new LinkedHashSet(this.cacheNames.size() + 1); + Set cacheNames = new LinkedHashSet<>(this.cacheNames.size() + 1); cacheNames.addAll(this.cacheNames); cacheNames.add(name); this.cacheNames = Collections.unmodifiableSet(cacheNames); diff --git a/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java index eac12fd8208..f10ec707bf8 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/CompositeCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ import org.springframework.cache.CacheManager; */ public class CompositeCacheManager implements CacheManager, InitializingBean { - private final List cacheManagers = new ArrayList(); + private final List cacheManagers = new ArrayList<>(); private boolean fallbackToNoOpCache = false; @@ -110,7 +110,7 @@ public class CompositeCacheManager implements CacheManager, InitializingBean { @Override public Collection getCacheNames() { - Set names = new LinkedHashSet(); + Set names = new LinkedHashSet<>(); for (CacheManager manager : this.cacheManagers) { names.addAll(manager.getCacheNames()); } diff --git a/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java b/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java index faa56c30991..2871028eac7 100644 --- a/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java +++ b/spring-context/src/main/java/org/springframework/cache/support/NoOpCacheManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,9 +41,9 @@ import org.springframework.cache.CacheManager; */ public class NoOpCacheManager implements CacheManager { - private final ConcurrentMap caches = new ConcurrentHashMap(16); + private final ConcurrentMap caches = new ConcurrentHashMap<>(16); - private final Set cacheNames = new LinkedHashSet(16); + private final Set cacheNames = new LinkedHashSet<>(16); /** diff --git a/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java b/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java index 619e334afc5..de025c5ab4a 100644 --- a/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java +++ b/spring-context/src/main/java/org/springframework/context/access/ContextSingletonBeanFactoryLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class ContextSingletonBeanFactoryLocator extends SingletonBeanFactoryLoca private static final String DEFAULT_RESOURCE_LOCATION = "classpath*:beanRefContext.xml"; /** The keyed singleton instances */ - private static final Map instances = new HashMap(); + private static final Map instances = new HashMap<>(); /** diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java index 764073b8737..a8976529841 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,7 +155,7 @@ public class AnnotationConfigUtils { } } - Set beanDefs = new LinkedHashSet(4); + Set beanDefs = new LinkedHashSet<>(4); if (!registry.containsBeanDefinition(CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME)) { RootBeanDefinition def = new RootBeanDefinition(ConfigurationClassPostProcessor.class); @@ -290,7 +290,7 @@ public class AnnotationConfigUtils { static Set attributesForRepeatable(AnnotationMetadata metadata, String containerClassName, String annotationClassName) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false)); Map container = metadata.getAnnotationAttributes(containerClassName, false); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java index 8e90baa5c0b..89d004212eb 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -243,7 +243,7 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo */ protected Set doScan(String... basePackages) { Assert.notEmpty(basePackages, "At least one base package must be specified"); - Set beanDefinitions = new LinkedHashSet(); + Set beanDefinitions = new LinkedHashSet<>(); for (String basePackage : basePackages) { Set candidates = findCandidateComponents(basePackage); for (BeanDefinition candidate : candidates) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java index 86a904810ca..aed66e9b1ad 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,9 +83,9 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC private String resourcePattern = DEFAULT_RESOURCE_PATTERN; - private final List includeFilters = new LinkedList(); + private final List includeFilters = new LinkedList<>(); - private final List excludeFilters = new LinkedList(); + private final List excludeFilters = new LinkedList<>(); private ConditionEvaluator conditionEvaluator; @@ -263,7 +263,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC * @return a corresponding Set of autodetected bean definitions */ public Set findCandidateComponents(String basePackage) { - Set candidates = new LinkedHashSet(); + Set candidates = new LinkedHashSet<>(); try { String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resolveBasePackage(basePackage) + "/" + this.resourcePattern; diff --git a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java index c3dbc0276ba..ef04f7fe43c 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java @@ -171,7 +171,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean } - private final Set ignoredResourceTypes = new HashSet(1); + private final Set ignoredResourceTypes = new HashSet<>(1); private boolean fallbackToDefaultTypeMatch = true; @@ -186,7 +186,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean private transient StringValueResolver embeddedValueResolver; private transient final Map injectionMetadataCache = - new ConcurrentHashMap(256); + new ConcurrentHashMap<>(256); /** @@ -351,12 +351,12 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean } private InjectionMetadata buildResourceMetadata(final Class clazz) { - LinkedList elements = new LinkedList(); + LinkedList elements = new LinkedList<>(); Class targetClass = clazz; do { final LinkedList currElements = - new LinkedList(); + new LinkedList<>(); ReflectionUtils.doWithLocalFields(targetClass, new ReflectionUtils.FieldCallback() { @Override @@ -514,7 +514,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean if (this.fallbackToDefaultTypeMatch && element.isDefaultName && factory instanceof AutowireCapableBeanFactory && !factory.containsBean(name)) { - autowiredBeanNames = new LinkedHashSet(); + autowiredBeanNames = new LinkedHashSet<>(); resource = ((AutowireCapableBeanFactory) factory).resolveDependency( element.getDependencyDescriptor(), requestingBeanName, autowiredBeanNames, null); } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanAnnotationParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanAnnotationParser.java index 18277312714..c47f4431ee8 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanAnnotationParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ComponentScanAnnotationParser.java @@ -121,7 +121,7 @@ class ComponentScanAnnotationParser { scanner.getBeanDefinitionDefaults().setLazyInit(true); } - Set basePackages = new LinkedHashSet(); + Set basePackages = new LinkedHashSet<>(); String[] basePackagesArray = componentScan.getAliasedStringArray("basePackages", ComponentScan.class, declaringClass); for (String pkg : basePackagesArray) { String[] tokenized = StringUtils.tokenizeToStringArray(this.environment.resolvePlaceholders(pkg), @@ -145,7 +145,7 @@ class ComponentScanAnnotationParser { } private List typeFiltersFor(AnnotationAttributes filterAttributes) { - List typeFilters = new ArrayList(); + List typeFilters = new ArrayList<>(); FilterType filterType = filterAttributes.getEnum("type"); for (Class filterClass : filterAttributes.getAliasedClassArray("classes", ComponentScan.Filter.class, null)) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConditionEvaluator.java b/spring-context/src/main/java/org/springframework/context/annotation/ConditionEvaluator.java index 14812b93d42..617a045652a 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConditionEvaluator.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConditionEvaluator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ class ConditionEvaluator { return shouldSkip(metadata, ConfigurationPhase.REGISTER_BEAN); } - List conditions = new ArrayList(); + List conditions = new ArrayList<>(); for (String[] conditionClasses : getConditionClasses(metadata)) { for (String conditionClass : conditionClasses) { Condition condition = getCondition(conditionClass, this.context.getClassLoader()); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java index 69d2c1978a5..77efc385d80 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClass.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,17 +54,17 @@ final class ConfigurationClass { private String beanName; - private final Set importedBy = new LinkedHashSet(1); + private final Set importedBy = new LinkedHashSet<>(1); - private final Set beanMethods = new LinkedHashSet(); + private final Set beanMethods = new LinkedHashSet<>(); private final Map> importedResources = - new LinkedHashMap>(); + new LinkedHashMap<>(); private final Map importBeanDefinitionRegistrars = - new LinkedHashMap(); + new LinkedHashMap<>(); - final Set skippedBeanMethods = new HashSet(); + final Set skippedBeanMethods = new HashSet<>(); /** diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java index 9031872e5b0..79eeb462d16 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,7 +185,7 @@ class ConfigurationClassBeanDefinitionReader { // Consider name and any aliases AnnotationAttributes bean = AnnotationConfigUtils.attributesFor(metadata, Bean.class); - List names = new ArrayList(Arrays.asList(bean.getStringArray("name"))); + List names = new ArrayList<>(Arrays.asList(bean.getStringArray("name"))); String beanName = (names.size() > 0 ? names.remove(0) : methodName); // Register aliases even when overridden @@ -305,7 +305,7 @@ class ConfigurationClassBeanDefinitionReader { private void loadBeanDefinitionsFromImportedResources( Map> importedResources) { - Map, BeanDefinitionReader> readerInstanceCache = new HashMap, BeanDefinitionReader>(); + Map, BeanDefinitionReader> readerInstanceCache = new HashMap<>(); for (Map.Entry> entry : importedResources.entrySet()) { String resource = entry.getKey(); @@ -414,7 +414,7 @@ class ConfigurationClassBeanDefinitionReader { */ private class TrackedConditionEvaluator { - private final Map skipped = new HashMap(); + private final Map skipped = new HashMap<>(); public boolean shouldSkip(ConfigurationClass configClass) { Boolean skip = this.skipped.get(configClass); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java index ffed74571f9..d467d4f5005 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java @@ -133,11 +133,11 @@ class ConfigurationClassParser { private final ConditionEvaluator conditionEvaluator; private final Map configurationClasses = - new LinkedHashMap(); + new LinkedHashMap<>(); - private final Map knownSuperclasses = new HashMap(); + private final Map knownSuperclasses = new HashMap<>(); - private final List propertySourceNames = new ArrayList(); + private final List propertySourceNames = new ArrayList<>(); private final ImportStack importStack = new ImportStack(); @@ -164,7 +164,7 @@ class ConfigurationClassParser { public void parse(Set configCandidates) { - this.deferredImportSelectors = new LinkedList(); + this.deferredImportSelectors = new LinkedList<>(); for (BeanDefinitionHolder holder : configCandidates) { BeanDefinition bd = holder.getBeanDefinition(); @@ -438,8 +438,8 @@ class ConfigurationClassParser { * Returns {@code @Import} class, considering all meta-annotations. */ private Set getImports(SourceClass sourceClass) throws IOException { - Set imports = new LinkedHashSet(); - Set visited = new LinkedHashSet(); + Set imports = new LinkedHashSet<>(); + Set visited = new LinkedHashSet<>(); collectImports(sourceClass, imports, visited); return imports; } @@ -624,7 +624,7 @@ class ConfigurationClassParser { * Factory method to obtain {@link SourceClass}s from class names. */ public Collection asSourceClasses(String[] classNames) throws IOException { - List annotatedClasses = new ArrayList(); + List annotatedClasses = new ArrayList<>(); for (String className : classNames) { annotatedClasses.add(asSourceClass(className)); } @@ -651,7 +651,7 @@ class ConfigurationClassParser { @SuppressWarnings("serial") private static class ImportStack extends ArrayDeque implements ImportRegistry { - private final MultiValueMap imports = new LinkedMultiValueMap(); + private final MultiValueMap imports = new LinkedMultiValueMap<>(); public void registerImport(AnnotationMetadata importingClass, String importedClass) { this.imports.add(importedClass, importingClass); @@ -771,7 +771,7 @@ class ConfigurationClassParser { Class sourceClass = (Class) sourceToProcess; try { Class[] declaredClasses = sourceClass.getDeclaredClasses(); - List members = new ArrayList(declaredClasses.length); + List members = new ArrayList<>(declaredClasses.length); for (Class declaredClass : declaredClasses) { members.add(asSourceClass(declaredClass)); } @@ -787,7 +787,7 @@ class ConfigurationClassParser { // ASM-based resolution - safe for non-resolvable classes as well MetadataReader sourceReader = (MetadataReader) sourceToProcess; String[] memberClassNames = sourceReader.getClassMetadata().getMemberClassNames(); - List members = new ArrayList(memberClassNames.length); + List members = new ArrayList<>(memberClassNames.length); for (String memberClassName : memberClassNames) { try { members.add(asSourceClass(memberClassName)); @@ -811,7 +811,7 @@ class ConfigurationClassParser { } public Set getInterfaces() throws IOException { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); if (this.source instanceof Class) { Class sourceClass = (Class) this.source; for (Class ifcClass : sourceClass.getInterfaces()) { @@ -827,7 +827,7 @@ class ConfigurationClassParser { } public Set getAnnotations() throws IOException { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (String className : this.metadata.getAnnotationTypes()) { try { result.add(getRelated(className)); @@ -846,7 +846,7 @@ class ConfigurationClassParser { return Collections.emptySet(); } String[] classNames = (String[]) annotationAttributes.get(attribute); - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (String className : classNames) { result.add(getRelated(className)); } diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java index 301256a6a82..f6f4ac12f12 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java @@ -117,9 +117,9 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo private boolean setMetadataReaderFactoryCalled = false; - private final Set registriesPostProcessed = new HashSet(); + private final Set registriesPostProcessed = new HashSet<>(); - private final Set factoriesPostProcessed = new HashSet(); + private final Set factoriesPostProcessed = new HashSet<>(); private ConfigurationClassBeanDefinitionReader reader; @@ -268,7 +268,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo * {@link Configuration} classes. */ public void processConfigBeanDefinitions(BeanDefinitionRegistry registry) { - List configCandidates = new ArrayList(); + List configCandidates = new ArrayList<>(); String[] candidateNames = registry.getBeanDefinitionNames(); for (String beanName : candidateNames) { @@ -315,13 +315,13 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo this.metadataReaderFactory, this.problemReporter, this.environment, this.resourceLoader, this.componentScanBeanNameGenerator, registry); - Set candidates = new LinkedHashSet(configCandidates); - Set alreadyParsed = new HashSet(configCandidates.size()); + Set candidates = new LinkedHashSet<>(configCandidates); + Set alreadyParsed = new HashSet<>(configCandidates.size()); do { parser.parse(candidates); parser.validate(); - Set configClasses = new LinkedHashSet(parser.getConfigurationClasses()); + Set configClasses = new LinkedHashSet<>(parser.getConfigurationClasses()); configClasses.removeAll(alreadyParsed); // Read the model and create bean definitions based on its content @@ -336,8 +336,8 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo candidates.clear(); if (registry.getBeanDefinitionCount() > candidateNames.length) { String[] newCandidateNames = registry.getBeanDefinitionNames(); - Set oldCandidateNames = new HashSet(Arrays.asList(candidateNames)); - Set alreadyParsedClasses = new HashSet(); + Set oldCandidateNames = new HashSet<>(Arrays.asList(candidateNames)); + Set alreadyParsedClasses = new HashSet<>(); for (ConfigurationClass configurationClass : alreadyParsed) { alreadyParsedClasses.add(configurationClass.getMetadata().getClassName()); } @@ -374,7 +374,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo * @see ConfigurationClassEnhancer */ public void enhanceConfigurationClasses(ConfigurableListableBeanFactory beanFactory) { - Map configBeanDefs = new LinkedHashMap(); + Map configBeanDefs = new LinkedHashMap<>(); for (String beanName : beanFactory.getBeanDefinitionNames()) { BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName); if (ConfigurationClassUtils.isFullConfigurationClass(beanDef)) { diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java index d5f71a9fa01..223f2977be8 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ abstract class ConfigurationClassUtils { private static final Log logger = LogFactory.getLog(ConfigurationClassUtils.class); - private static final Set candidateIndicators = new HashSet(4); + private static final Set candidateIndicators = new HashSet<>(4); static { candidateIndicators.add(Component.class.getName()); diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java b/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java index 1a4708322dd..a63d954cb53 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Jsr330ScopeMetadataResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ import org.springframework.beans.factory.config.BeanDefinition; */ public class Jsr330ScopeMetadataResolver implements ScopeMetadataResolver { - private final Map scopeMap = new HashMap(); + private final Map scopeMap = new HashMap<>(); public Jsr330ScopeMetadataResolver() { diff --git a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java index b7dd9186a18..4d6ead59c1e 100644 --- a/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java +++ b/spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java @@ -61,7 +61,7 @@ public abstract class AbstractApplicationEventMulticaster private final ListenerRetriever defaultRetriever = new ListenerRetriever(false); final Map retrieverCache = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); private ClassLoader beanClassLoader; @@ -203,12 +203,12 @@ public abstract class AbstractApplicationEventMulticaster private Collection> retrieveApplicationListeners( ResolvableType eventType, Class sourceType, ListenerRetriever retriever) { - LinkedList> allListeners = new LinkedList>(); + LinkedList> allListeners = new LinkedList<>(); Set> listeners; Set listenerBeans; synchronized (this.retrievalMutex) { - listeners = new LinkedHashSet>(this.defaultRetriever.applicationListeners); - listenerBeans = new LinkedHashSet(this.defaultRetriever.applicationListenerBeans); + listeners = new LinkedHashSet<>(this.defaultRetriever.applicationListeners); + listenerBeans = new LinkedHashSet<>(this.defaultRetriever.applicationListenerBeans); } for (ApplicationListener listener : listeners) { if (supportsEvent(listener, eventType, sourceType)) { @@ -345,13 +345,13 @@ public abstract class AbstractApplicationEventMulticaster private final boolean preFiltered; public ListenerRetriever(boolean preFiltered) { - this.applicationListeners = new LinkedHashSet>(); - this.applicationListenerBeans = new LinkedHashSet(); + this.applicationListeners = new LinkedHashSet<>(); + this.applicationListenerBeans = new LinkedHashSet<>(); this.preFiltered = preFiltered; } public Collection> getApplicationListeners() { - LinkedList> allListeners = new LinkedList>(); + LinkedList> allListeners = new LinkedList<>(); for (ApplicationListener listener : this.applicationListeners) { allListeners.add(listener); } diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index a57eb0c6120..84fed556293 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -354,7 +354,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe } EventListener ann = getEventListener(); if (ann != null && ann.classes().length > 0) { - List types = new ArrayList(); + List types = new ArrayList<>(); for (Class eventType : ann.classes()) { types.add(ResolvableType.forClass(eventType)); } diff --git a/spring-context/src/main/java/org/springframework/context/event/EventExpressionEvaluator.java b/spring-context/src/main/java/org/springframework/context/event/EventExpressionEvaluator.java index 8cb00fe8241..bf71571ff5b 100644 --- a/spring-context/src/main/java/org/springframework/context/event/EventExpressionEvaluator.java +++ b/spring-context/src/main/java/org/springframework/context/event/EventExpressionEvaluator.java @@ -40,9 +40,9 @@ import org.springframework.expression.Expression; */ class EventExpressionEvaluator extends CachedExpressionEvaluator { - private final Map conditionCache = new ConcurrentHashMap(64); + private final Map conditionCache = new ConcurrentHashMap<>(64); - private final Map targetMethodCache = new ConcurrentHashMap(64); + private final Map targetMethodCache = new ConcurrentHashMap<>(64); /** diff --git a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java index 7a95f172e3d..6ef4a7672d0 100644 --- a/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/event/EventListenerMethodProcessor.java @@ -119,7 +119,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton, */ protected List getEventListenerFactories() { Map beans = this.applicationContext.getBeansOfType(EventListenerFactory.class); - List allFactories = new ArrayList(beans.values()); + List allFactories = new ArrayList<>(beans.values()); AnnotationAwareOrderComparator.sort(allFactories); return allFactories; } diff --git a/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java b/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java index 29ff4fcacfc..5fa6b164274 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java +++ b/spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,10 +61,10 @@ public class StandardBeanExpressionResolver implements BeanExpressionResolver { private ExpressionParser expressionParser; - private final Map expressionCache = new ConcurrentHashMap(256); + private final Map expressionCache = new ConcurrentHashMap<>(256); private final Map evaluationCache = - new ConcurrentHashMap(8); + new ConcurrentHashMap<>(8); private final ParserContext beanExpressionParserContext = new ParserContext() { @Override diff --git a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java index 6803a29341c..1d727a280d5 100644 --- a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java +++ b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,10 +44,10 @@ import org.springframework.core.NamedThreadLocal; public abstract class LocaleContextHolder { private static final ThreadLocal localeContextHolder = - new NamedThreadLocal("Locale context"); + new NamedThreadLocal<>("Locale context"); private static final ThreadLocal inheritableLocaleContextHolder = - new NamedInheritableThreadLocal("Locale context"); + new NamedInheritableThreadLocal<>("Locale context"); /** diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 2e462c01cca..c42f43ae48f 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -173,7 +173,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader /** BeanFactoryPostProcessors to apply on refresh */ private final List beanFactoryPostProcessors = - new ArrayList(); + new ArrayList<>(); /** System time in milliseconds when this context started */ private long startupDate; @@ -203,7 +203,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader private ApplicationEventMulticaster applicationEventMulticaster; /** Statically specified listeners */ - private final Set> applicationListeners = new LinkedHashSet>(); + private final Set> applicationListeners = new LinkedHashSet<>(); /** ApplicationEvents published early */ private Set earlyApplicationEvents; @@ -368,7 +368,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader applicationEvent = (ApplicationEvent) event; } else { - applicationEvent = new PayloadApplicationEvent(this, event); + applicationEvent = new PayloadApplicationEvent<>(this, event); if (eventType == null) { eventType = ((PayloadApplicationEvent)applicationEvent).getResolvableType(); } @@ -590,7 +590,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader // Allow for the collection of early ApplicationEvents, // to be published once the multicaster is available... - this.earlyApplicationEvents = new LinkedHashSet(); + this.earlyApplicationEvents = new LinkedHashSet<>(); } /** diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java index 62fe2cc829c..0cca055234d 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -305,7 +305,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme if (args == null) { return new Object[0]; } - List resolvedArgs = new ArrayList(args.length); + List resolvedArgs = new ArrayList<>(args.length); for (Object arg : args) { if (arg instanceof MessageSourceResolvable) { resolvedArgs.add(getMessage((MessageSourceResolvable) arg, locale)); diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java index 404af2eb02a..5c6bae5777b 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java @@ -35,7 +35,7 @@ import org.springframework.util.ObjectUtils; */ public abstract class AbstractResourceBasedMessageSource extends AbstractMessageSource { - private final Set basenameSet = new LinkedHashSet(4); + private final Set basenameSet = new LinkedHashSet<>(4); private String defaultEncoding; diff --git a/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java b/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java index dd3ca6a10c4..75d4d52768f 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java +++ b/spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java @@ -56,7 +56,7 @@ class ContextTypeMatchClassLoader extends DecoratingClassLoader implements Smart /** Cache for byte array per class name */ - private final Map bytesCache = new ConcurrentHashMap(256); + private final Map bytesCache = new ConcurrentHashMap<>(256); public ContextTypeMatchClassLoader(ClassLoader parent) { diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java index 521d273f599..47c7d2feb5f 100644 --- a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -129,7 +129,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor private void startBeans(boolean autoStartupOnly) { Map lifecycleBeans = getLifecycleBeans(); - Map phases = new HashMap(); + Map phases = new HashMap<>(); for (Map.Entry entry : lifecycleBeans.entrySet()) { Lifecycle bean = entry.getValue(); if (!autoStartupOnly || (bean instanceof SmartLifecycle && ((SmartLifecycle) bean).isAutoStartup())) { @@ -143,7 +143,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor } } if (phases.size() > 0) { - List keys = new ArrayList(phases.keySet()); + List keys = new ArrayList<>(phases.keySet()); Collections.sort(keys); for (Integer key : keys) { phases.get(key).start(); @@ -184,7 +184,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor private void stopBeans() { Map lifecycleBeans = getLifecycleBeans(); - Map phases = new HashMap(); + Map phases = new HashMap<>(); for (Map.Entry entry : lifecycleBeans.entrySet()) { Lifecycle bean = entry.getValue(); int shutdownOrder = getPhase(bean); @@ -196,7 +196,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor group.add(entry.getKey(), bean); } if (phases.size() > 0) { - List keys = new ArrayList(phases.keySet()); + List keys = new ArrayList<>(phases.keySet()); Collections.sort(keys, Collections.reverseOrder()); for (Integer key : keys) { phases.get(key).stop(); @@ -269,7 +269,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor * @return the Map of applicable beans, with bean names as keys and bean instances as values */ protected Map getLifecycleBeans() { - Map beans = new LinkedHashMap(); + Map beans = new LinkedHashMap<>(); String[] beanNames = this.beanFactory.getBeanNamesForType(Lifecycle.class, false, false); for (String beanName : beanNames) { String beanNameToRegister = BeanFactoryUtils.transformedBeanName(beanName); @@ -307,7 +307,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor */ private class LifecycleGroup { - private final List members = new ArrayList(); + private final List members = new ArrayList<>(); private final int phase; diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java index b77e604634b..8b10f6bc3b1 100644 --- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java +++ b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar public static final String MBEAN_APPLICATION_KEY = "application"; private static final Set applicationContexts = - new LinkedHashSet(); + new LinkedHashSet<>(); static void registerApplicationContext(ConfigurableApplicationContext applicationContext) { @@ -128,7 +128,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar */ protected Set findApplicationContexts() { synchronized (applicationContexts) { - return new LinkedHashSet(applicationContexts); + return new LinkedHashSet<>(applicationContexts); } } diff --git a/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java b/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java index d863add6872..2f21c7fa0ee 100644 --- a/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java +++ b/spring-context/src/main/java/org/springframework/context/support/MessageSourceSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public abstract class MessageSourceSupport { * codes are cached on a specific basis in subclasses. */ private final Map> messageFormatsPerMessage = - new HashMap>(); + new HashMap<>(); /** @@ -122,7 +122,7 @@ public abstract class MessageSourceSupport { messageFormat = messageFormatsPerLocale.get(locale); } else { - messageFormatsPerLocale = new HashMap(); + messageFormatsPerLocale = new HashMap<>(); this.messageFormatsPerMessage.put(msg, messageFormatsPerLocale); } if (messageFormat == null) { diff --git a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java index 0557b6bd6ca..bcd55639f0b 100644 --- a/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java +++ b/spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java @@ -58,13 +58,13 @@ class PostProcessorRegistrationDelegate { ConfigurableListableBeanFactory beanFactory, List beanFactoryPostProcessors) { // Invoke BeanDefinitionRegistryPostProcessors first, if any. - Set processedBeans = new HashSet(); + Set processedBeans = new HashSet<>(); if (beanFactory instanceof BeanDefinitionRegistry) { BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; - List regularPostProcessors = new LinkedList(); + List regularPostProcessors = new LinkedList<>(); List registryPostProcessors = - new LinkedList(); + new LinkedList<>(); for (BeanFactoryPostProcessor postProcessor : beanFactoryPostProcessors) { if (postProcessor instanceof BeanDefinitionRegistryPostProcessor) { @@ -86,7 +86,7 @@ class PostProcessorRegistrationDelegate { beanFactory.getBeanNamesForType(BeanDefinitionRegistryPostProcessor.class, true, false); // First, invoke the BeanDefinitionRegistryPostProcessors that implement PriorityOrdered. - List priorityOrderedPostProcessors = new ArrayList(); + List priorityOrderedPostProcessors = new ArrayList<>(); for (String ppName : postProcessorNames) { if (beanFactory.isTypeMatch(ppName, PriorityOrdered.class)) { priorityOrderedPostProcessors.add(beanFactory.getBean(ppName, BeanDefinitionRegistryPostProcessor.class)); @@ -99,7 +99,7 @@ class PostProcessorRegistrationDelegate { // Next, invoke the BeanDefinitionRegistryPostProcessors that implement Ordered. postProcessorNames = beanFactory.getBeanNamesForType(BeanDefinitionRegistryPostProcessor.class, true, false); - List orderedPostProcessors = new ArrayList(); + List orderedPostProcessors = new ArrayList<>(); for (String ppName : postProcessorNames) { if (!processedBeans.contains(ppName) && beanFactory.isTypeMatch(ppName, Ordered.class)) { orderedPostProcessors.add(beanFactory.getBean(ppName, BeanDefinitionRegistryPostProcessor.class)); @@ -143,9 +143,9 @@ class PostProcessorRegistrationDelegate { // Separate between BeanFactoryPostProcessors that implement PriorityOrdered, // Ordered, and the rest. - List priorityOrderedPostProcessors = new ArrayList(); - List orderedPostProcessorNames = new ArrayList(); - List nonOrderedPostProcessorNames = new ArrayList(); + List priorityOrderedPostProcessors = new ArrayList<>(); + List orderedPostProcessorNames = new ArrayList<>(); + List nonOrderedPostProcessorNames = new ArrayList<>(); for (String ppName : postProcessorNames) { if (processedBeans.contains(ppName)) { // skip - already processed in first phase above @@ -166,7 +166,7 @@ class PostProcessorRegistrationDelegate { invokeBeanFactoryPostProcessors(priorityOrderedPostProcessors, beanFactory); // Next, invoke the BeanFactoryPostProcessors that implement Ordered. - List orderedPostProcessors = new ArrayList(); + List orderedPostProcessors = new ArrayList<>(); for (String postProcessorName : orderedPostProcessorNames) { orderedPostProcessors.add(beanFactory.getBean(postProcessorName, BeanFactoryPostProcessor.class)); } @@ -174,7 +174,7 @@ class PostProcessorRegistrationDelegate { invokeBeanFactoryPostProcessors(orderedPostProcessors, beanFactory); // Finally, invoke all other BeanFactoryPostProcessors. - List nonOrderedPostProcessors = new ArrayList(); + List nonOrderedPostProcessors = new ArrayList<>(); for (String postProcessorName : nonOrderedPostProcessorNames) { nonOrderedPostProcessors.add(beanFactory.getBean(postProcessorName, BeanFactoryPostProcessor.class)); } @@ -198,10 +198,10 @@ class PostProcessorRegistrationDelegate { // Separate between BeanPostProcessors that implement PriorityOrdered, // Ordered, and the rest. - List priorityOrderedPostProcessors = new ArrayList(); - List internalPostProcessors = new ArrayList(); - List orderedPostProcessorNames = new ArrayList(); - List nonOrderedPostProcessorNames = new ArrayList(); + List priorityOrderedPostProcessors = new ArrayList<>(); + List internalPostProcessors = new ArrayList<>(); + List orderedPostProcessorNames = new ArrayList<>(); + List nonOrderedPostProcessorNames = new ArrayList<>(); for (String ppName : postProcessorNames) { if (beanFactory.isTypeMatch(ppName, PriorityOrdered.class)) { BeanPostProcessor pp = beanFactory.getBean(ppName, BeanPostProcessor.class); @@ -223,7 +223,7 @@ class PostProcessorRegistrationDelegate { registerBeanPostProcessors(beanFactory, priorityOrderedPostProcessors); // Next, register the BeanPostProcessors that implement Ordered. - List orderedPostProcessors = new ArrayList(); + List orderedPostProcessors = new ArrayList<>(); for (String ppName : orderedPostProcessorNames) { BeanPostProcessor pp = beanFactory.getBean(ppName, BeanPostProcessor.class); orderedPostProcessors.add(pp); @@ -235,7 +235,7 @@ class PostProcessorRegistrationDelegate { registerBeanPostProcessors(beanFactory, orderedPostProcessors); // Now, register all regular BeanPostProcessors. - List nonOrderedPostProcessors = new ArrayList(); + List nonOrderedPostProcessors = new ArrayList<>(); for (String ppName : nonOrderedPostProcessorNames) { BeanPostProcessor pp = beanFactory.getBean(ppName, BeanPostProcessor.class); nonOrderedPostProcessors.add(pp); @@ -360,7 +360,7 @@ class PostProcessorRegistrationDelegate { private transient final AbstractApplicationContext applicationContext; - private transient final Map singletonNames = new ConcurrentHashMap(256); + private transient final Map singletonNames = new ConcurrentHashMap<>(256); public ApplicationListenerDetector(AbstractApplicationContext applicationContext) { this.applicationContext = applicationContext; diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java index 92fecb1a787..854ee437e63 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java @@ -101,15 +101,15 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased /** Cache to hold filename lists per Locale */ private final ConcurrentMap>> cachedFilenames = - new ConcurrentHashMap>>(); + new ConcurrentHashMap<>(); /** Cache to hold already loaded properties per filename */ private final ConcurrentMap cachedProperties = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); /** Cache to hold merged loaded properties per locale */ private final ConcurrentMap cachedMergedProperties = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); /** @@ -274,7 +274,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased return filenames; } } - List filenames = new ArrayList(7); + List filenames = new ArrayList<>(7); filenames.addAll(calculateFilenamesForLocale(basename, locale)); if (isFallbackToSystemLocale() && !locale.equals(Locale.getDefault())) { List fallbackFilenames = calculateFilenamesForLocale(basename, Locale.getDefault()); @@ -287,7 +287,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased } filenames.add(basename); if (localeMap == null) { - localeMap = new ConcurrentHashMap>(); + localeMap = new ConcurrentHashMap<>(); Map> existing = this.cachedFilenames.putIfAbsent(basename, localeMap); if (existing != null) { localeMap = existing; @@ -308,7 +308,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased * @return the List of filenames to check */ protected List calculateFilenamesForLocale(String basename, Locale locale) { - List result = new ArrayList(3); + List result = new ArrayList<>(3); String language = locale.getLanguage(); String country = locale.getCountry(); String variant = locale.getVariant(); @@ -553,7 +553,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased /** Cache to hold already generated MessageFormats per message code */ private final ConcurrentMap> cachedMessageFormats = - new ConcurrentHashMap>(); + new ConcurrentHashMap<>(); public PropertiesHolder() { this.properties = null; @@ -602,7 +602,7 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased String msg = this.properties.getProperty(code); if (msg != null) { if (localeMap == null) { - localeMap = new ConcurrentHashMap(); + localeMap = new ConcurrentHashMap<>(); Map existing = this.cachedMessageFormats.putIfAbsent(code, localeMap); if (existing != null) { localeMap = existing; diff --git a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java index d7dce2b57c9..3417ae508bd 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java @@ -77,7 +77,7 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou * than the ResourceBundle class's own cache. */ private final Map> cachedResourceBundles = - new HashMap>(); + new HashMap<>(); /** * Cache to hold already generated MessageFormats. @@ -88,7 +88,7 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou * @see #getMessageFormat */ private final Map>> cachedBundleMessageFormats = - new HashMap>>(); + new HashMap<>(); /** @@ -184,7 +184,7 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou try { ResourceBundle bundle = doGetBundle(basename, locale); if (localeMap == null) { - localeMap = new HashMap(); + localeMap = new HashMap<>(); this.cachedResourceBundles.put(basename, localeMap); } localeMap.put(locale, bundle); @@ -257,11 +257,11 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou String msg = getStringOrNull(bundle, code); if (msg != null) { if (codeMap == null) { - codeMap = new HashMap>(); + codeMap = new HashMap<>(); this.cachedBundleMessageFormats.put(bundle, codeMap); } if (localeMap == null) { - localeMap = new HashMap(); + localeMap = new HashMap<>(); codeMap.put(code, localeMap); } MessageFormat result = createMessageFormat(msg, locale); diff --git a/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java b/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java index 14357c9f747..12a1afa370f 100644 --- a/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java +++ b/spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class SimpleThreadScope implements Scope { new NamedThreadLocal>("SimpleThreadScope") { @Override protected Map initialValue() { - return new HashMap(); + return new HashMap<>(); } }; diff --git a/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java index 6292ab7b540..c301dba7c47 100644 --- a/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java +++ b/spring-context/src/main/java/org/springframework/context/support/StaticMessageSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,9 +36,9 @@ import org.springframework.util.Assert; public class StaticMessageSource extends AbstractMessageSource { /** Map from 'code + locale' keys to message Strings */ - private final Map messages = new HashMap(); + private final Map messages = new HashMap<>(); - private final Map cachedMessageFormats = new HashMap(); + private final Map cachedMessageFormats = new HashMap<>(); @Override diff --git a/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java b/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java index 17c2cef4b01..c74b2653964 100644 --- a/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java +++ b/spring-context/src/main/java/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class SpringBeanAutowiringInterceptor { * It simply protects against future usage of the interceptor in a shared scenario. */ private final Map beanFactoryReferences = - new WeakHashMap(); + new WeakHashMap<>(); /** diff --git a/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java b/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java index b11153669b9..b595823149e 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class DateFormatter implements Formatter { private static final Map ISO_PATTERNS; static { - Map formats = new HashMap(4); + Map formats = new HashMap<>(4); formats.put(ISO.DATE, "yyyy-MM-dd"); formats.put(ISO.TIME, "HH:mm:ss.SSSZ"); formats.put(ISO.DATE_TIME, "yyyy-MM-dd'T'HH:mm:ss.SSSZ"); diff --git a/spring-context/src/main/java/org/springframework/format/datetime/DateTimeFormatAnnotationFormatterFactory.java b/spring-context/src/main/java/org/springframework/format/datetime/DateTimeFormatAnnotationFormatterFactory.java index 5c749b4af53..65edf8bbf34 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/DateTimeFormatAnnotationFormatterFactory.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/DateTimeFormatAnnotationFormatterFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public class DateTimeFormatAnnotationFormatterFactory extends EmbeddedValueReso private static final Set> FIELD_TYPES; static { - Set> fieldTypes = new HashSet>(4); + Set> fieldTypes = new HashSet<>(4); fieldTypes.add(Date.class); fieldTypes.add(Calendar.class); fieldTypes.add(Long.class); diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java index c70a9ee6ff1..b043acf6fb2 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaDateTimeFormatAnnotationFormatterFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class JodaDateTimeFormatAnnotationFormatterFactory extends EmbeddedValueR // (if we did not do this, the default byType rules for LocalDate, LocalTime, // and LocalDateTime would take precedence over the annotation rule, which // is not what we want) - Set> fieldTypes = new HashSet>(8); + Set> fieldTypes = new HashSet<>(8); fieldTypes.add(ReadableInstant.class); fieldTypes.add(LocalDate.class); fieldTypes.add(LocalTime.class); diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java index ffc2b711379..e6c9412e1cc 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.core.NamedThreadLocal; public final class JodaTimeContextHolder { private static final ThreadLocal jodaTimeContextHolder = - new NamedThreadLocal("JodaTime Context"); + new NamedThreadLocal<>("JodaTime Context"); /** diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java index 9c57310f733..cb4af997ca0 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar { /** * User defined formatters. */ - private final Map formatters = new HashMap(); + private final Map formatters = new HashMap<>(); /** * Factories used when specific formatters have not been specified. @@ -82,7 +82,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar { public JodaTimeFormatterRegistrar() { - this.factories = new HashMap(); + this.factories = new HashMap<>(); for (Type type : Type.values()) { this.factories.put(type, new DateTimeFormatterFactory()); } diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java index 276cbff3a64..2fd3cd806a2 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeContextHolder.java @@ -30,7 +30,7 @@ import org.springframework.core.NamedThreadLocal; public final class DateTimeContextHolder { private static final ThreadLocal dateTimeContextHolder = - new NamedThreadLocal("DateTime Context"); + new NamedThreadLocal<>("DateTime Context"); /** diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java index d779976484e..1a2e72438f6 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/DateTimeFormatterRegistrar.java @@ -58,7 +58,7 @@ public class DateTimeFormatterRegistrar implements FormatterRegistrar { /** * User defined formatters. */ - private final Map formatters = new HashMap(); + private final Map formatters = new HashMap<>(); /** * Factories used when specific formatters have not been specified. @@ -67,7 +67,7 @@ public class DateTimeFormatterRegistrar implements FormatterRegistrar { public DateTimeFormatterRegistrar() { - this.factories = new HashMap(); + this.factories = new HashMap<>(); for (Type type : Type.values()) { this.factories.put(type, new DateTimeFormatterFactory()); } diff --git a/spring-context/src/main/java/org/springframework/format/datetime/standard/Jsr310DateTimeFormatAnnotationFormatterFactory.java b/spring-context/src/main/java/org/springframework/format/datetime/standard/Jsr310DateTimeFormatAnnotationFormatterFactory.java index 62729c4a45c..932c52887f4 100644 --- a/spring-context/src/main/java/org/springframework/format/datetime/standard/Jsr310DateTimeFormatAnnotationFormatterFactory.java +++ b/spring-context/src/main/java/org/springframework/format/datetime/standard/Jsr310DateTimeFormatAnnotationFormatterFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class Jsr310DateTimeFormatAnnotationFormatterFactory extends EmbeddedValu static { // Create the set of field types that may be annotated with @DateTimeFormat. - Set> fieldTypes = new HashSet>(8); + Set> fieldTypes = new HashSet<>(8); fieldTypes.add(LocalDate.class); fieldTypes.add(LocalTime.class); fieldTypes.add(LocalDateTime.class); diff --git a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java index e65e4fbda99..a6e9219bf1d 100644 --- a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java +++ b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java @@ -53,10 +53,10 @@ public class FormattingConversionService extends GenericConversionService private StringValueResolver embeddedValueResolver; private final Map cachedPrinters = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); private final Map cachedParsers = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); @Override diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java b/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java index 54a3571064c..827b56e9f23 100644 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java +++ b/spring-context/src/main/java/org/springframework/instrument/classloading/InstrumentationLoadTimeWeaver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class InstrumentationLoadTimeWeaver implements LoadTimeWeaver { private final Instrumentation instrumentation; - private final List transformers = new ArrayList(4); + private final List transformers = new ArrayList<>(4); /** diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoader.java b/spring-context/src/main/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoader.java index 47bb8dc30b4..4b4fbe924c6 100644 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoader.java +++ b/spring-context/src/main/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class ResourceOverridingShadowingClassLoader extends ShadowingClassLoader /** * Key is asked for value: value is actual value */ - private Map overrides = new HashMap(); + private Map overrides = new HashMap<>(); /** diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/ShadowingClassLoader.java b/spring-context/src/main/java/org/springframework/instrument/classloading/ShadowingClassLoader.java index fbff824dfde..4c63c25d462 100644 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/ShadowingClassLoader.java +++ b/spring-context/src/main/java/org/springframework/instrument/classloading/ShadowingClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,9 +54,9 @@ public class ShadowingClassLoader extends DecoratingClassLoader { private final ClassLoader enclosingClassLoader; - private final List classFileTransformers = new LinkedList(); + private final List classFileTransformers = new LinkedList<>(); - private final Map> classCache = new HashMap>(); + private final Map> classCache = new HashMap<>(); /** diff --git a/spring-context/src/main/java/org/springframework/instrument/classloading/WeavingTransformer.java b/spring-context/src/main/java/org/springframework/instrument/classloading/WeavingTransformer.java index bcae2c2f5cc..a84844e74d5 100644 --- a/spring-context/src/main/java/org/springframework/instrument/classloading/WeavingTransformer.java +++ b/spring-context/src/main/java/org/springframework/instrument/classloading/WeavingTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class WeavingTransformer { private final ClassLoader classLoader; - private final List transformers = new ArrayList(); + private final List transformers = new ArrayList<>(); /** diff --git a/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java b/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java index 9d7c677731c..1aebcf4495a 100644 --- a/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java +++ b/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java @@ -122,7 +122,7 @@ public class MBeanClientInterceptor private Map allowedOperations; - private final Map signatureCache = new HashMap(); + private final Map signatureCache = new HashMap<>(); private final Object preparationMonitor = new Object(); @@ -285,13 +285,13 @@ public class MBeanClientInterceptor MBeanInfo info = this.serverToUse.getMBeanInfo(this.objectName); MBeanAttributeInfo[] attributeInfo = info.getAttributes(); - this.allowedAttributes = new HashMap(attributeInfo.length); + this.allowedAttributes = new HashMap<>(attributeInfo.length); for (MBeanAttributeInfo infoEle : attributeInfo) { this.allowedAttributes.put(infoEle.getName(), infoEle); } MBeanOperationInfo[] operationInfo = info.getOperations(); - this.allowedOperations = new HashMap(operationInfo.length); + this.allowedOperations = new HashMap<>(operationInfo.length); for (MBeanOperationInfo infoEle : operationInfo) { Class[] paramTypes = JmxUtils.parameterInfoToTypes(infoEle.getSignature(), this.beanClassLoader); this.allowedOperations.put(new MethodCacheKey(infoEle.getName(), paramTypes), infoEle); diff --git a/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java b/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java index b9eb86caad2..c50ceb6228a 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -161,7 +161,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo private boolean exposeManagedResourceClassLoader = true; /** A set of bean names that should be excluded from autodetection */ - private Set excludedBeans = new HashSet(); + private Set excludedBeans = new HashSet<>(); /** The MBeanExporterListeners registered with this exporter. */ private MBeanExporterListener[] listeners; @@ -171,7 +171,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo /** Map of actually registered NotificationListeners */ private final Map registeredNotificationListeners = - new LinkedHashMap(); + new LinkedHashMap<>(); /** Stores the ClassLoader to use for generating lazy-init proxies */ private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); @@ -366,7 +366,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo public void setNotificationListenerMappings(Map listeners) { Assert.notNull(listeners, "'listeners' must not be null"); List notificationListeners = - new ArrayList(listeners.size()); + new ArrayList<>(listeners.size()); for (Map.Entry entry : listeners.entrySet()) { // Get the listener from the map value. @@ -520,7 +520,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo protected void registerBeans() { // The beans property may be null, for example if we are relying solely on autodetection. if (this.beans == null) { - this.beans = new HashMap(); + this.beans = new HashMap<>(); // Use AUTODETECT_ALL as default in no beans specified explicitly. if (this.autodetectMode == null) { this.autodetectMode = AUTODETECT_ALL; @@ -891,7 +891,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo * whether to include a bean or not */ private void autodetect(AutodetectCallback callback) { - Set beanNames = new LinkedHashSet(this.beanFactory.getBeanDefinitionCount()); + Set beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount()); beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames())); if (this.beanFactory instanceof ConfigurableBeanFactory) { beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames())); diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractConfigurableMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractConfigurableMBeanInfoAssembler.java index 4a5f78b648c..b341147b0d5 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractConfigurableMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractConfigurableMBeanInfoAssembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public abstract class AbstractConfigurableMBeanInfoAssembler extends AbstractRef private ModelMBeanNotificationInfo[] notificationInfos; private final Map notificationInfoMappings = - new HashMap(); + new HashMap<>(); public void setNotificationInfos(ManagedNotification[] notificationInfos) { @@ -78,7 +78,7 @@ public abstract class AbstractConfigurableMBeanInfoAssembler extends AbstractRef } else if (mapValue instanceof Collection) { Collection col = (Collection) mapValue; - List result = new ArrayList(); + List result = new ArrayList<>(); for (Object colValue : col) { if (!(colValue instanceof ManagedNotification)) { throw new IllegalArgumentException( diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java index a950b7eb7fe..f2d95bfa22c 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -292,7 +292,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean @Override protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException { PropertyDescriptor[] props = BeanUtils.getPropertyDescriptors(getClassToExpose(managedBean)); - List infos = new ArrayList(); + List infos = new ArrayList<>(); for (PropertyDescriptor prop : props) { Method getter = prop.getReadMethod(); @@ -346,7 +346,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean @Override protected ModelMBeanOperationInfo[] getOperationInfo(Object managedBean, String beanKey) { Method[] methods = getClassToExpose(managedBean).getMethods(); - List infos = new ArrayList(); + List infos = new ArrayList<>(); for (Method method : methods) { if (method.isSynthetic()) { diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java index 1356b0eaad0..c39dd3c4d68 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,7 +128,7 @@ public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanI * @return the resolved interface mappings (with Class objects as values) */ private Map[]> resolveInterfaceMappings(Properties mappings) { - Map[]> resolvedMappings = new HashMap[]>(mappings.size()); + Map[]> resolvedMappings = new HashMap<>(mappings.size()); for (Enumeration en = mappings.propertyNames(); en.hasMoreElements();) { String beanKey = (String) en.nextElement(); String[] classNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey)); diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssembler.java index 75178da1281..d4517c29e13 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ public class MethodExclusionMBeanInfoAssembler extends AbstractConfigurableMBean * @see #setIgnoredMethodMappings(java.util.Properties) */ public void setIgnoredMethods(String... ignoredMethodNames) { - this.ignoredMethods = new HashSet(Arrays.asList(ignoredMethodNames)); + this.ignoredMethods = new HashSet<>(Arrays.asList(ignoredMethodNames)); } /** @@ -80,11 +80,11 @@ public class MethodExclusionMBeanInfoAssembler extends AbstractConfigurableMBean * Spring will check these mappings first. */ public void setIgnoredMethodMappings(Properties mappings) { - this.ignoredMethodMappings = new HashMap>(); + this.ignoredMethodMappings = new HashMap<>(); for (Enumeration en = mappings.keys(); en.hasMoreElements();) { String beanKey = (String) en.nextElement(); String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey)); - this.ignoredMethodMappings.put(beanKey, new HashSet(Arrays.asList(methodNames))); + this.ignoredMethodMappings.put(beanKey, new HashSet<>(Arrays.asList(methodNames))); } } diff --git a/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssembler.java b/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssembler.java index 3df5350dfd0..b3c572984e9 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssembler.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssembler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean * @see #setMethodMappings */ public void setManagedMethods(String[] methodNames) { - this.managedMethods = new HashSet(Arrays.asList(methodNames)); + this.managedMethods = new HashSet<>(Arrays.asList(methodNames)); } /** @@ -84,11 +84,11 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean * @param mappings the mappins of bean keys to method names */ public void setMethodMappings(Properties mappings) { - this.methodMappings = new HashMap>(); + this.methodMappings = new HashMap<>(); for (Enumeration en = mappings.keys(); en.hasMoreElements();) { String beanKey = (String) en.nextElement(); String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey)); - this.methodMappings.put(beanKey, new HashSet(Arrays.asList(methodNames))); + this.methodMappings.put(beanKey, new HashSet<>(Arrays.asList(methodNames))); } } diff --git a/spring-context/src/main/java/org/springframework/jmx/export/naming/IdentityNamingStrategy.java b/spring-context/src/main/java/org/springframework/jmx/export/naming/IdentityNamingStrategy.java index 96626f07edb..6f67717a738 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/naming/IdentityNamingStrategy.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/naming/IdentityNamingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class IdentityNamingStrategy implements ObjectNamingStrategy { @Override public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException { String domain = ClassUtils.getPackageName(managedBean.getClass()); - Hashtable keys = new Hashtable(); + Hashtable keys = new Hashtable<>(); keys.put(TYPE_KEY, ClassUtils.getShortName(managedBean.getClass())); keys.put(HASH_CODE_KEY, ObjectUtils.getIdentityHexString(managedBean)); return ObjectNameManager.getInstance(domain, keys); diff --git a/spring-context/src/main/java/org/springframework/jmx/export/naming/MetadataNamingStrategy.java b/spring-context/src/main/java/org/springframework/jmx/export/naming/MetadataNamingStrategy.java index fde4adec670..6c9219d5c67 100644 --- a/spring-context/src/main/java/org/springframework/jmx/export/naming/MetadataNamingStrategy.java +++ b/spring-context/src/main/java/org/springframework/jmx/export/naming/MetadataNamingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,7 +124,7 @@ public class MetadataNamingStrategy implements ObjectNamingStrategy, Initializin if (domain == null) { domain = ClassUtils.getPackageName(managedClass); } - Hashtable properties = new Hashtable(); + Hashtable properties = new Hashtable<>(); properties.put("type", ClassUtils.getShortName(managedClass)); properties.put("name", beanKey); return ObjectNameManager.getInstance(domain, properties); diff --git a/spring-context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java b/spring-context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java index 5a4d05a7fb0..d0d4d85cd0d 100644 --- a/spring-context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport private String serviceUrl = DEFAULT_SERVICE_URL; - private Map environment = new HashMap(); + private Map environment = new HashMap<>(); private MBeanServerForwarder forwarder; diff --git a/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java b/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java index 4f732b22bb0..e61d43bed6a 100644 --- a/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java +++ b/spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java @@ -81,7 +81,7 @@ public class MBeanRegistrationSupport { /** * The beans that have been registered by this exporter. */ - private final Set registeredBeans = new LinkedHashSet(); + private final Set registeredBeans = new LinkedHashSet<>(); /** * The policy used when registering an MBean and finding that it already exists. @@ -174,7 +174,7 @@ public class MBeanRegistrationSupport { protected void unregisterBeans() { Set snapshot; synchronized (this.registeredBeans) { - snapshot = new LinkedHashSet(this.registeredBeans); + snapshot = new LinkedHashSet<>(this.registeredBeans); } if (!snapshot.isEmpty()) { logger.info("Unregistering JMX-exposed beans"); diff --git a/spring-context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java b/spring-context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java index 5c923b19034..0872fc3052a 100644 --- a/spring-context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class MBeanServerConnectionFactoryBean private JMXServiceURL serviceUrl; - private Map environment = new HashMap(); + private Map environment = new HashMap<>(); private boolean connectOnStartup = true; diff --git a/spring-context/src/main/java/org/springframework/jmx/support/NotificationListenerHolder.java b/spring-context/src/main/java/org/springframework/jmx/support/NotificationListenerHolder.java index bc508386791..c40fd00972d 100644 --- a/spring-context/src/main/java/org/springframework/jmx/support/NotificationListenerHolder.java +++ b/spring-context/src/main/java/org/springframework/jmx/support/NotificationListenerHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ public class NotificationListenerHolder { */ public void setMappedObjectNames(Object[] mappedObjectNames) { this.mappedObjectNames = (mappedObjectNames != null ? - new LinkedHashSet(Arrays.asList(mappedObjectNames)) : null); + new LinkedHashSet<>(Arrays.asList(mappedObjectNames)) : null); } /** diff --git a/spring-context/src/main/java/org/springframework/jndi/JndiTemplate.java b/spring-context/src/main/java/org/springframework/jndi/JndiTemplate.java index d781a5d3c03..3cec10527df 100644 --- a/spring-context/src/main/java/org/springframework/jndi/JndiTemplate.java +++ b/spring-context/src/main/java/org/springframework/jndi/JndiTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,7 +130,7 @@ public class JndiTemplate { Hashtable icEnv = null; Properties env = getEnvironment(); if (env != null) { - icEnv = new Hashtable(env.size()); + icEnv = new Hashtable<>(env.size()); CollectionUtils.mergePropertiesIntoMap(env, icEnv); } return new InitialContext(icEnv); diff --git a/spring-context/src/main/java/org/springframework/jndi/support/SimpleJndiBeanFactory.java b/spring-context/src/main/java/org/springframework/jndi/support/SimpleJndiBeanFactory.java index 16b7e7c4a30..6bfbec411d7 100644 --- a/spring-context/src/main/java/org/springframework/jndi/support/SimpleJndiBeanFactory.java +++ b/spring-context/src/main/java/org/springframework/jndi/support/SimpleJndiBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,13 +60,13 @@ import org.springframework.jndi.TypeMismatchNamingException; public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFactory { /** JNDI names of resources that are known to be shareable, i.e. can be cached */ - private final Set shareableResources = new HashSet(); + private final Set shareableResources = new HashSet<>(); /** Cache of shareable singleton objects: bean name --> bean instance */ - private final Map singletonObjects = new HashMap(); + private final Map singletonObjects = new HashMap<>(); /** Cache of the types of nonshareable resources: bean name --> bean type */ - private final Map> resourceTypes = new HashMap>(); + private final Map> resourceTypes = new HashMap<>(); public SimpleJndiBeanFactory() { diff --git a/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocation.java b/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocation.java index f0ec57a72ae..3d8ebba918d 100644 --- a/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocation.java +++ b/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -150,7 +150,7 @@ public class RemoteInvocation implements Serializable { */ public void addAttribute(String key, Serializable value) throws IllegalStateException { if (this.attributes == null) { - this.attributes = new HashMap(); + this.attributes = new HashMap<>(); } if (this.attributes.containsKey(key)) { throw new IllegalStateException("There is already an attribute with key '" + key + "' bound"); diff --git a/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationUtils.java b/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationUtils.java index 05c521c7f00..c5a79b0faf6 100644 --- a/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationUtils.java +++ b/spring-context/src/main/java/org/springframework/remoting/support/RemoteInvocationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public abstract class RemoteInvocationUtils { public static void fillInClientStackTraceIfPossible(Throwable ex) { if (ex != null) { StackTraceElement[] clientStack = new Throwable().getStackTrace(); - Set visitedExceptions = new HashSet(); + Set visitedExceptions = new HashSet<>(); Throwable exToUpdate = ex; while (exToUpdate != null && !visitedExceptions.contains(exToUpdate)) { StackTraceElement[] serverStack = exToUpdate.getStackTrace(); diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java index ff321cf8e74..703a0006f84 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java @@ -79,7 +79,7 @@ public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor implements B */ @SuppressWarnings("unchecked") public AsyncAnnotationAdvisor(Executor executor, AsyncUncaughtExceptionHandler exceptionHandler) { - Set> asyncAnnotationTypes = new LinkedHashSet>(2); + Set> asyncAnnotationTypes = new LinkedHashSet<>(2); asyncAnnotationTypes.add(Async.class); try { asyncAnnotationTypes.add((Class) @@ -117,7 +117,7 @@ public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor implements B */ public void setAsyncAnnotationType(Class asyncAnnotationType) { Assert.notNull(asyncAnnotationType, "'asyncAnnotationType' must not be null"); - Set> asyncAnnotationTypes = new HashSet>(); + Set> asyncAnnotationTypes = new HashSet<>(); asyncAnnotationTypes.add(asyncAnnotationType); this.pointcut = buildPointcut(asyncAnnotationTypes); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java index fdd33a614b8..842eb326655 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncResult.java @@ -125,7 +125,7 @@ public class AsyncResult implements ListenableFuture { * @see Future#get() */ public static ListenableFuture forValue(V value) { - return new AsyncResult(value, null); + return new AsyncResult<>(value, null); } /** @@ -137,7 +137,7 @@ public class AsyncResult implements ListenableFuture { * @see ExecutionException */ public static ListenableFuture forExecutionException(Throwable ex) { - return new AsyncResult(null, + return new AsyncResult<>(null, (ex instanceof ExecutionException ? (ExecutionException) ex : new ExecutionException(ex))); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java index 89d35299a05..2b3e501a0bb 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java @@ -113,7 +113,7 @@ public class ScheduledAnnotationBeanPostProcessor implements DestructionAwareBea Collections.newSetFromMap(new ConcurrentHashMap, Boolean>(64)); private final Map> scheduledTasks = - new ConcurrentHashMap>(16); + new ConcurrentHashMap<>(16); @Override @@ -304,7 +304,7 @@ public class ScheduledAnnotationBeanPostProcessor implements DestructionAwareBea Set tasks = this.scheduledTasks.get(bean); if (tasks == null) { - tasks = new LinkedHashSet(4); + tasks = new LinkedHashSet<>(4); this.scheduledTasks.put(bean, tasks); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java index b888092dd9d..3146d2014d4 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java @@ -229,7 +229,7 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche protected static class ManagedTaskBuilder { public static Runnable buildManagedTask(Runnable task, String identityName) { - Map properties = new HashMap(2); + Map properties = new HashMap<>(2); if (task instanceof SchedulingAwareRunnable) { properties.put(ManagedTask.LONGRUNNING_HINT, Boolean.toString(((SchedulingAwareRunnable) task).isLongLived())); @@ -239,7 +239,7 @@ public class ConcurrentTaskExecutor implements AsyncListenableTaskExecutor, Sche } public static Callable buildManagedTask(Callable task, String identityName) { - Map properties = new HashMap(1); + Map properties = new HashMap<>(1); properties.put(ManagedTask.IDENTITY_NAME, identityName); return ManagedExecutors.managedTask(task, properties, null); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java index 2ebbebf35b1..2125223fef4 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -181,10 +181,10 @@ public class ThreadPoolExecutorFactoryBean extends ExecutorConfigurationSupport */ protected BlockingQueue createQueue(int queueCapacity) { if (queueCapacity > 0) { - return new LinkedBlockingQueue(queueCapacity); + return new LinkedBlockingQueue<>(queueCapacity); } else { - return new SynchronousQueue(); + return new SynchronousQueue<>(); } } diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.java index 3391276b6c3..b7180c69b24 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.java @@ -244,10 +244,10 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport */ protected BlockingQueue createQueue(int queueCapacity) { if (queueCapacity > 0) { - return new LinkedBlockingQueue(queueCapacity); + return new LinkedBlockingQueue<>(queueCapacity); } else { - return new SynchronousQueue(); + return new SynchronousQueue<>(); } } @@ -328,7 +328,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport public ListenableFuture submitListenable(Runnable task) { ExecutorService executor = getThreadPoolExecutor(); try { - ListenableFutureTask future = new ListenableFutureTask(task, null); + ListenableFutureTask future = new ListenableFutureTask<>(task, null); executor.execute(future); return future; } @@ -341,7 +341,7 @@ public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport public ListenableFuture submitListenable(Callable task) { ExecutorService executor = getThreadPoolExecutor(); try { - ListenableFutureTask future = new ListenableFutureTask(task); + ListenableFutureTask future = new ListenableFutureTask<>(task); executor.execute(future); return future; } diff --git a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java index 8d7bf1b0e93..c0038e9c597 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java +++ b/spring-context/src/main/java/org/springframework/scheduling/concurrent/ThreadPoolTaskScheduler.java @@ -236,7 +236,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport try { Callable taskToUse = task; if (this.errorHandler != null) { - taskToUse = new DelegatingErrorHandlingCallable(task, this.errorHandler); + taskToUse = new DelegatingErrorHandlingCallable<>(task, this.errorHandler); } return executor.submit(taskToUse); } @@ -249,7 +249,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport public ListenableFuture submitListenable(Runnable task) { ExecutorService executor = getScheduledExecutor(); try { - ListenableFutureTask future = new ListenableFutureTask(task, null); + ListenableFutureTask future = new ListenableFutureTask<>(task, null); executor.execute(errorHandlingTask(future, false)); return future; } @@ -262,7 +262,7 @@ public class ThreadPoolTaskScheduler extends ExecutorConfigurationSupport public ListenableFuture submitListenable(Callable task) { ExecutorService executor = getScheduledExecutor(); try { - ListenableFutureTask future = new ListenableFutureTask(task); + ListenableFutureTask future = new ListenableFutureTask<>(task); executor.execute(errorHandlingTask(future, false)); return future; } diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java index d7fe6be3acf..771df301795 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTaskRegistrar.java @@ -67,9 +67,9 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean private List fixedDelayTasks; - private final Map unresolvedTasks = new HashMap(16); + private final Map unresolvedTasks = new HashMap<>(16); - private final Set scheduledTasks = new LinkedHashSet(16); + private final Set scheduledTasks = new LinkedHashSet<>(16); /** @@ -111,7 +111,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean * (typically custom implementations of the {@link Trigger} interface). */ public void setTriggerTasks(Map triggerTasks) { - this.triggerTasks = new ArrayList(); + this.triggerTasks = new ArrayList<>(); for (Map.Entry task : triggerTasks.entrySet()) { addTriggerTask(new TriggerTask(task.getKey(), task.getValue())); } @@ -142,7 +142,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean * @see CronTrigger */ public void setCronTasks(Map cronTasks) { - this.cronTasks = new ArrayList(); + this.cronTasks = new ArrayList<>(); for (Map.Entry task : cronTasks.entrySet()) { addCronTask(task.getKey(), task.getValue()); } @@ -173,7 +173,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean * @see TaskScheduler#scheduleAtFixedRate(Runnable, long) */ public void setFixedRateTasks(Map fixedRateTasks) { - this.fixedRateTasks = new ArrayList(); + this.fixedRateTasks = new ArrayList<>(); for (Map.Entry task : fixedRateTasks.entrySet()) { addFixedRateTask(task.getKey(), task.getValue()); } @@ -204,7 +204,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean * @see TaskScheduler#scheduleWithFixedDelay(Runnable, long) */ public void setFixedDelayTasks(Map fixedDelayTasks) { - this.fixedDelayTasks = new ArrayList(); + this.fixedDelayTasks = new ArrayList<>(); for (Map.Entry task : fixedDelayTasks.entrySet()) { addFixedDelayTask(task.getKey(), task.getValue()); } @@ -246,7 +246,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public void addTriggerTask(TriggerTask task) { if (this.triggerTasks == null) { - this.triggerTasks = new ArrayList(); + this.triggerTasks = new ArrayList<>(); } this.triggerTasks.add(task); } @@ -264,7 +264,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public void addCronTask(CronTask task) { if (this.cronTasks == null) { - this.cronTasks = new ArrayList(); + this.cronTasks = new ArrayList<>(); } this.cronTasks.add(task); } @@ -284,7 +284,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public void addFixedRateTask(IntervalTask task) { if (this.fixedRateTasks == null) { - this.fixedRateTasks = new ArrayList(); + this.fixedRateTasks = new ArrayList<>(); } this.fixedRateTasks.add(task); } @@ -304,7 +304,7 @@ public class ScheduledTaskRegistrar implements InitializingBean, DisposableBean */ public void addFixedDelayTask(IntervalTask task) { if (this.fixedDelayTasks == null) { - this.fixedDelayTasks = new ArrayList(); + this.fixedDelayTasks = new ArrayList<>(); } this.fixedDelayTasks.add(task); } diff --git a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParser.java b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParser.java index 0f5f810245c..cb30f3662a7 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParser.java +++ b/spring-context/src/main/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,10 +55,10 @@ public class ScheduledTasksBeanDefinitionParser extends AbstractSingleBeanDefini @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { builder.setLazyInit(false); // lazy scheduled tasks are a contradiction in terms -> force to false - ManagedList cronTaskList = new ManagedList(); - ManagedList fixedDelayTaskList = new ManagedList(); - ManagedList fixedRateTaskList = new ManagedList(); - ManagedList triggerTaskList = new ManagedList(); + ManagedList cronTaskList = new ManagedList<>(); + ManagedList fixedDelayTaskList = new ManagedList<>(); + ManagedList fixedRateTaskList = new ManagedList<>(); + ManagedList triggerTaskList = new ManagedList<>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); diff --git a/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java b/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java index a088205d438..cd625ae72aa 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java +++ b/spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java @@ -149,7 +149,7 @@ public class CronSequenceGenerator { } private void doNext(Calendar calendar, int dot) { - List resets = new ArrayList(); + List resets = new ArrayList<>(); int second = calendar.get(Calendar.SECOND); List emptyList = Collections.emptyList(); diff --git a/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java b/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java index 51ff49e148c..395efb78135 100644 --- a/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -176,7 +176,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces final DefaultListableBeanFactory scriptBeanFactory = new DefaultListableBeanFactory(); /** Map from bean name String to ScriptSource object */ - private final Map scriptSourceCache = new HashMap(); + private final Map scriptSourceCache = new HashMap<>(); /** * Set the delay between refresh checks, in milliseconds. diff --git a/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptUtils.java b/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptUtils.java index 05f62c2a8da..7fafe0d953a 100644 --- a/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptUtils.java +++ b/spring-context/src/main/java/org/springframework/scripting/support/StandardScriptUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public abstract class StandardScriptUtils { public static ScriptEngine retrieveEngineByName(ScriptEngineManager scriptEngineManager, String engineName) { ScriptEngine engine = scriptEngineManager.getEngineByName(engineName); if (engine == null) { - Set engineNames = new LinkedHashSet(); + Set engineNames = new LinkedHashSet<>(); for (ScriptEngineFactory engineFactory : scriptEngineManager.getEngineFactories()) { List factoryNames = engineFactory.getNames(); if (factoryNames.contains(engineName)) { diff --git a/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java b/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java index 7a8a4867d71..f91ec21f52e 100644 --- a/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java +++ b/spring-context/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class ResourceBundleThemeSource implements HierarchicalThemeSource, BeanC private ClassLoader beanClassLoader; /** Map from theme name to Theme instance */ - private final Map themeCache = new ConcurrentHashMap(); + private final Map themeCache = new ConcurrentHashMap<>(); @Override diff --git a/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java b/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java index 9e162d13ca6..36ac77b9a7c 100644 --- a/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java +++ b/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +48,9 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi private MessageCodesResolver messageCodesResolver = new DefaultMessageCodesResolver(); - private final List errors = new LinkedList(); + private final List errors = new LinkedList<>(); - private final Set suppressedFields = new HashSet(); + private final Set suppressedFields = new HashSet<>(); /** @@ -155,7 +155,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi @Override public List getGlobalErrors() { - List result = new LinkedList(); + List result = new LinkedList<>(); for (ObjectError objectError : this.errors) { if (!(objectError instanceof FieldError)) { result.add(objectError); @@ -176,7 +176,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi @Override public List getFieldErrors() { - List result = new LinkedList(); + List result = new LinkedList<>(); for (ObjectError objectError : this.errors) { if (objectError instanceof FieldError) { result.add((FieldError) objectError); @@ -197,7 +197,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi @Override public List getFieldErrors(String field) { - List result = new LinkedList(); + List result = new LinkedList<>(); String fixedField = fixedField(field); for (ObjectError objectError : this.errors) { if (objectError instanceof FieldError && isMatchingFieldError(fixedField, (FieldError) objectError)) { @@ -270,7 +270,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi */ @Override public Map getModel() { - Map model = new LinkedHashMap(2); + Map model = new LinkedHashMap<>(2); // Mapping from name to target object. model.put(getObjectName(), getTarget()); // Errors instance, even if no errors. diff --git a/spring-context/src/main/java/org/springframework/validation/AbstractErrors.java b/spring-context/src/main/java/org/springframework/validation/AbstractErrors.java index a0d182c9cce..1881e188854 100644 --- a/spring-context/src/main/java/org/springframework/validation/AbstractErrors.java +++ b/spring-context/src/main/java/org/springframework/validation/AbstractErrors.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public abstract class AbstractErrors implements Errors, Serializable { private String nestedPath = ""; - private final Stack nestedPathStack = new Stack(); + private final Stack nestedPathStack = new Stack<>(); @Override @@ -144,7 +144,7 @@ public abstract class AbstractErrors implements Errors, Serializable { @Override public List getAllErrors() { - List result = new LinkedList(); + List result = new LinkedList<>(); result.addAll(getGlobalErrors()); result.addAll(getFieldErrors()); return Collections.unmodifiableList(result); @@ -195,7 +195,7 @@ public abstract class AbstractErrors implements Errors, Serializable { @Override public List getFieldErrors(String field) { List fieldErrors = getFieldErrors(); - List result = new LinkedList(); + List result = new LinkedList<>(); String fixedField = fixedField(field); for (FieldError error : fieldErrors) { if (isMatchingFieldError(fixedField, error)) { diff --git a/spring-context/src/main/java/org/springframework/validation/DataBinder.java b/spring-context/src/main/java/org/springframework/validation/DataBinder.java index 880a1bc5c13..556c4a51386 100644 --- a/spring-context/src/main/java/org/springframework/validation/DataBinder.java +++ b/spring-context/src/main/java/org/springframework/validation/DataBinder.java @@ -145,7 +145,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter { private BindingErrorProcessor bindingErrorProcessor = new DefaultBindingErrorProcessor(); - private final List validators = new ArrayList(); + private final List validators = new ArrayList<>(); private ConversionService conversionService; @@ -762,7 +762,7 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter { protected void checkRequiredFields(MutablePropertyValues mpvs) { String[] requiredFields = getRequiredFields(); if (!ObjectUtils.isEmpty(requiredFields)) { - Map propertyValues = new HashMap(); + Map propertyValues = new HashMap<>(); PropertyValue[] pvs = mpvs.getPropertyValues(); for (PropertyValue pv : pvs) { String canonicalName = PropertyAccessorUtils.canonicalPropertyName(pv.getName()); diff --git a/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java b/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java index 0eee6f1bbc7..e41270dba83 100644 --- a/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java +++ b/spring-context/src/main/java/org/springframework/validation/DefaultMessageCodesResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -147,8 +147,8 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial */ @Override public String[] resolveMessageCodes(String errorCode, String objectName, String field, Class fieldType) { - Set codeList = new LinkedHashSet(); - List fieldList = new ArrayList(); + Set codeList = new LinkedHashSet<>(); + List fieldList = new ArrayList<>(); buildFieldList(field, fieldList); addCodes(codeList, errorCode, objectName, fieldList); int dotIndex = field.lastIndexOf('.'); diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java index 9db0fec7dc3..ea7d8979c17 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java @@ -99,7 +99,7 @@ public class LocalValidatorFactoryBean extends SpringValidatorAdapter private Resource[] mappingLocations; - private final Map validationPropertyMap = new HashMap(); + private final Map validationPropertyMap = new HashMap<>(); private ApplicationContext applicationContext; diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java index 7640c52c637..ae342ab2d6e 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java @@ -51,7 +51,7 @@ import org.springframework.validation.SmartValidator; */ public class SpringValidatorAdapter implements SmartValidator, javax.validation.Validator { - private static final Set internalAnnotationAttributes = new HashSet(3); + private static final Set internalAnnotationAttributes = new HashSet<>(3); static { internalAnnotationAttributes.add("message"); @@ -98,7 +98,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation. @Override public void validate(Object target, Errors errors, Object... validationHints) { if (this.targetValidator != null) { - Set> groups = new LinkedHashSet>(); + Set> groups = new LinkedHashSet<>(); if (validationHints != null) { for (Object hint : validationHints) { if (hint instanceof Class) { @@ -205,10 +205,10 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation. * @see org.springframework.validation.DefaultBindingErrorProcessor#getArgumentsForBindError */ protected Object[] getArgumentsForConstraint(String objectName, String field, ConstraintDescriptor descriptor) { - List arguments = new LinkedList(); + List arguments = new LinkedList<>(); arguments.add(getResolvableField(objectName, field)); // Using a TreeMap for alphabetical ordering of attribute names - Map attributesToExpose = new TreeMap(); + Map attributesToExpose = new TreeMap<>(); for (Map.Entry entry : descriptor.getAttributes().entrySet()) { String attributeName = entry.getKey(); Object attributeValue = entry.getValue(); diff --git a/spring-context/src/test/java/example/scannable/AutowiredQualifierFooService.java b/spring-context/src/test/java/example/scannable/AutowiredQualifierFooService.java index 02fb1e5d2a3..7e69c9c1905 100644 --- a/spring-context/src/test/java/example/scannable/AutowiredQualifierFooService.java +++ b/spring-context/src/test/java/example/scannable/AutowiredQualifierFooService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class AutowiredQualifierFooService implements FooService { @Override public Future asyncFoo(int id) { - return new AsyncResult(this.fooDao.findFoo(id)); + return new AsyncResult<>(this.fooDao.findFoo(id)); } @Override diff --git a/spring-context/src/test/java/example/scannable/FooServiceImpl.java b/spring-context/src/test/java/example/scannable/FooServiceImpl.java index b63cfaf013c..cc15ecbdcd4 100644 --- a/spring-context/src/test/java/example/scannable/FooServiceImpl.java +++ b/spring-context/src/test/java/example/scannable/FooServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ public class FooServiceImpl implements FooService { public Future asyncFoo(int id) { System.out.println(Thread.currentThread().getName()); Assert.state(ServiceInvocationCounter.getThreadLocalCount() != null, "Thread-local counter not exposed"); - return new AsyncResult(this.fooDao.findFoo(id)); + return new AsyncResult<>(this.fooDao.findFoo(id)); } @Override diff --git a/spring-context/src/test/java/example/scannable/ScopedProxyTestBean.java b/spring-context/src/test/java/example/scannable/ScopedProxyTestBean.java index 74191d87e57..f016960179b 100644 --- a/spring-context/src/test/java/example/scannable/ScopedProxyTestBean.java +++ b/spring-context/src/test/java/example/scannable/ScopedProxyTestBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class ScopedProxyTestBean implements FooService { @Override public Future asyncFoo(int id) { - return new AsyncResult("bar"); + return new AsyncResult<>("bar"); } @Override diff --git a/spring-context/src/test/java/example/scannable/ServiceInvocationCounter.java b/spring-context/src/test/java/example/scannable/ServiceInvocationCounter.java index 87cc4052222..aaba3b82200 100644 --- a/spring-context/src/test/java/example/scannable/ServiceInvocationCounter.java +++ b/spring-context/src/test/java/example/scannable/ServiceInvocationCounter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public class ServiceInvocationCounter { private int useCount; - private static final ThreadLocal threadLocalCount = new ThreadLocal(); + private static final ThreadLocal threadLocalCount = new ThreadLocal<>(); @Pointcut("execution(* example.scannable.FooService+.*(..))") diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java index d56d75ad025..017401f3cff 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,19 +105,19 @@ public final class AfterReturningGenericTypeMatchingTests { class GenericReturnTypeVariationClass { public Collection getStrings() { - return new ArrayList(); + return new ArrayList<>(); } public Collection getIntegers() { - return new ArrayList(); + return new ArrayList<>(); } public Collection getTestBeans() { - return new ArrayList(); + return new ArrayList<>(); } public Collection getEmployees() { - return new ArrayList(); + return new ArrayList<>(); } } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index 09b73f1c3aa..70694746f65 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -923,7 +923,7 @@ public abstract class AbstractAopProxyTests { pf2.addAdvisor(new DefaultIntroductionAdvisor(new TimestampIntroductionInterceptor())); ITestBean proxy2 = (ITestBean) createProxy(pf2); - HashMap h = new HashMap(); + HashMap h = new HashMap<>(); Object value1 = "foo"; Object value2 = "bar"; assertNull(h.get(proxy1)); @@ -1178,7 +1178,7 @@ public abstract class AbstractAopProxyTests { }; class NameSaver implements MethodInterceptor { - private List names = new LinkedList(); + private List names = new LinkedList<>(); @Override public Object invoke(MethodInvocation mi) throws Throwable { @@ -1357,17 +1357,17 @@ public abstract class AbstractAopProxyTests { } }; AdvisedSupport pc = new AdvisedSupport(ITestBean.class); - MapAwareMethodInterceptor mami1 = new MapAwareMethodInterceptor(new HashMap(), new HashMap()); - Map firstValuesToAdd = new HashMap(); + MapAwareMethodInterceptor mami1 = new MapAwareMethodInterceptor(new HashMap<>(), new HashMap()); + Map firstValuesToAdd = new HashMap<>(); firstValuesToAdd.put("test", ""); - MapAwareMethodInterceptor mami2 = new MapAwareMethodInterceptor(new HashMap(), firstValuesToAdd); - MapAwareMethodInterceptor mami3 = new MapAwareMethodInterceptor(firstValuesToAdd, new HashMap()); - MapAwareMethodInterceptor mami4 = new MapAwareMethodInterceptor(firstValuesToAdd, new HashMap()); - Map secondValuesToAdd = new HashMap(); + MapAwareMethodInterceptor mami2 = new MapAwareMethodInterceptor(new HashMap<>(), firstValuesToAdd); + MapAwareMethodInterceptor mami3 = new MapAwareMethodInterceptor(firstValuesToAdd, new HashMap<>()); + MapAwareMethodInterceptor mami4 = new MapAwareMethodInterceptor(firstValuesToAdd, new HashMap<>()); + Map secondValuesToAdd = new HashMap<>(); secondValuesToAdd.put("foo", "bar"); secondValuesToAdd.put("cat", "dog"); MapAwareMethodInterceptor mami5 = new MapAwareMethodInterceptor(firstValuesToAdd, secondValuesToAdd); - Map finalExpected = new HashMap(firstValuesToAdd); + Map finalExpected = new HashMap<>(firstValuesToAdd); finalExpected.putAll(secondValuesToAdd); MapAwareMethodInterceptor mami6 = new MapAwareMethodInterceptor(finalExpected, secondValuesToAdd); diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index 78b8e5f25bd..721820714a7 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -714,7 +714,7 @@ public final class ProxyFactoryBeanTests { @SuppressWarnings("serial") public static class PointcutForVoid extends DefaultPointcutAdvisor { - public static List methodNames = new LinkedList(); + public static List methodNames = new LinkedList<>(); public static void reset() { methodNames.clear(); diff --git a/spring-context/src/test/java/org/springframework/cache/CacheTestUtils.java b/spring-context/src/test/java/org/springframework/cache/CacheTestUtils.java index 65ddd2a615f..2c082d5d163 100644 --- a/spring-context/src/test/java/org/springframework/cache/CacheTestUtils.java +++ b/spring-context/src/test/java/org/springframework/cache/CacheTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class CacheTestUtils { */ public static CacheManager createSimpleCacheManager(String... cacheNames) { SimpleCacheManager result = new SimpleCacheManager(); - List caches = new ArrayList(); + List caches = new ArrayList<>(); for (String cacheName : cacheNames) { caches.add(new ConcurrentMapCache(cacheName)); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index 5bebb953b60..23624d135dd 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -856,7 +856,7 @@ public class ConfigurationClassPostProcessorTests { @Bean public Repository genericRepo() { - return new GenericRepository(); + return new GenericRepository<>(); } } @@ -918,12 +918,12 @@ public class ConfigurationClassPostProcessorTests { @Bean public Repository stringRepo() { - return new Repository(); + return new Repository<>(); } @Bean public Repository numberRepo() { - return new Repository(); + return new Repository<>(); } @Bean @@ -942,7 +942,7 @@ public class ConfigurationClassPostProcessorTests { @Bean public Repository numberRepo() { - return new Repository(); + return new Repository<>(); } @Bean diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java index 9d1ec9b2439..cf475da278c 100755 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,7 +185,7 @@ public class ConfigurationWithFactoryBeanAndAutowiringTests { @Bean public MyParameterizedFactoryBean factoryBean() { Assert.notNull(dummyBean, "DummyBean was not injected."); - return new MyParameterizedFactoryBean("whatev"); + return new MyParameterizedFactoryBean<>("whatev"); } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java index 4fd29e896c1..c274f124094 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ import static org.mockito.Mockito.*; @SuppressWarnings("resource") public class ImportSelectorTests { - static Map, String> importFrom = new HashMap, String>(); + static Map, String> importFrom = new HashMap<>(); @BeforeClass diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java index d2b3810b5d9..22ddb8da287 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,8 +163,8 @@ public class Spr3775InitDestroyLifecycleTests { public static class InitDestroyBean { - final List initMethods = new ArrayList(); - final List destroyMethods = new ArrayList(); + final List initMethods = new ArrayList<>(); + final List destroyMethods = new ArrayList<>(); public void afterPropertiesSet() throws Exception { @@ -193,8 +193,8 @@ public class Spr3775InitDestroyLifecycleTests { public static class CustomInitDestroyBean { - final List initMethods = new ArrayList(); - final List destroyMethods = new ArrayList(); + final List initMethods = new ArrayList<>(); + final List destroyMethods = new ArrayList<>(); public void customInit() throws Exception { this.initMethods.add("customInit"); @@ -253,8 +253,8 @@ public class Spr3775InitDestroyLifecycleTests { public static class AllInOneBean implements InitializingBean, DisposableBean { - final List initMethods = new ArrayList(); - final List destroyMethods = new ArrayList(); + final List initMethods = new ArrayList<>(); + final List destroyMethods = new ArrayList<>(); @Override @PostConstruct diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java index a9bba8cf5df..a80d7f1d3c0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -330,7 +330,7 @@ public class ScopingTests { public boolean createNewScope = true; - private Map beans = new HashMap(); + private Map beans = new HashMap<>(); @Override public Object get(String name, ObjectFactory objectFactory) { diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index c65d60b89ce..bce850dae1b 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -415,7 +415,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen public static class MyOrderedListener1 implements ApplicationListener, Ordered { - public final Set seenEvents = new HashSet(); + public final Set seenEvents = new HashSet<>(); @Override public void onApplicationEvent(ApplicationEvent event) { @@ -459,7 +459,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen public static class MyPayloadListener implements ApplicationListener { - public final Set seenPayloads = new HashSet(); + public final Set seenPayloads = new HashSet<>(); @Override public void onApplicationEvent(PayloadApplicationEvent event) { @@ -470,7 +470,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen public static class MyNonSingletonListener implements ApplicationListener { - public static final Set seenEvents = new HashSet(); + public static final Set seenEvents = new HashSet<>(); @Override public void onApplicationEvent(ApplicationEvent event) { @@ -482,7 +482,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen @Order(5) public static class MyOrderedListener3 implements ApplicationListener { - public final Set seenEvents = new HashSet(); + public final Set seenEvents = new HashSet<>(); @Override public void onApplicationEvent(ApplicationEvent event) { diff --git a/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java b/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java index 4164631923b..34ca82b355c 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ public class MapAccessorTests { } public static class MapGetter { - Map map = new HashMap(); + Map map = new HashMap<>(); public MapGetter() { map.put("foo", "bar"); @@ -82,15 +82,15 @@ public class MapAccessorTests { } public Map getSimpleTestMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo","bar"); return map; } public Map> getNestedTestMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo","bar"); - Map> map2 = new HashMap>(); + Map> map2 = new HashMap<>(); map2.put("aaa", map); return map2; } diff --git a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java index 336f89e9027..cc3efcfc580 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class ConversionServiceFactoryBeanTests { @Test public void createDefaultConversionServiceWithSupplements() { ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean(); - Set converters = new HashSet(); + Set converters = new HashSet<>(); converters.add(new Converter() { @Override public Foo convert(String source) { @@ -94,7 +94,7 @@ public class ConversionServiceFactoryBeanTests { @Test(expected=IllegalArgumentException.class) public void createDefaultConversionServiceWithInvalidSupplements() { ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean(); - Set converters = new HashSet(); + Set converters = new HashSet<>(); converters.add("bogus"); factory.setConverters(converters); factory.afterPropertiesSet(); diff --git a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java index ffc29168200..0e818bc13d1 100644 --- a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ public class DefaultLifecycleProcessorTests { @Test public void singleSmartLifecycleAutoStartup() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean bean = TestSmartLifecycleBean.forStartupTests(1, startedBeans); bean.setAutoStartup(true); StaticApplicationContext context = new StaticApplicationContext(); @@ -105,7 +105,7 @@ public class DefaultLifecycleProcessorTests { @Test public void singleSmartLifecycleWithoutAutoStartup() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean bean = TestSmartLifecycleBean.forStartupTests(1, startedBeans); bean.setAutoStartup(false); StaticApplicationContext context = new StaticApplicationContext(); @@ -122,7 +122,7 @@ public class DefaultLifecycleProcessorTests { @Test public void singleSmartLifecycleAutoStartupWithNonAutoStartupDependency() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean bean = TestSmartLifecycleBean.forStartupTests(1, startedBeans); bean.setAutoStartup(true); TestSmartLifecycleBean dependency = TestSmartLifecycleBean.forStartupTests(1, startedBeans); @@ -144,7 +144,7 @@ public class DefaultLifecycleProcessorTests { @Test public void smartLifecycleGroupStartup() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forStartupTests(Integer.MIN_VALUE, startedBeans); TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forStartupTests(1, startedBeans); TestSmartLifecycleBean bean2 = TestSmartLifecycleBean.forStartupTests(2, startedBeans); @@ -178,7 +178,7 @@ public class DefaultLifecycleProcessorTests { @Test public void contextRefreshThenStartWithMixedBeans() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestLifecycleBean simpleBean1 = TestLifecycleBean.forStartupTests(startedBeans); TestLifecycleBean simpleBean2 = TestLifecycleBean.forStartupTests(startedBeans); TestSmartLifecycleBean smartBean1 = TestSmartLifecycleBean.forStartupTests(5, startedBeans); @@ -212,7 +212,7 @@ public class DefaultLifecycleProcessorTests { @Test public void contextRefreshThenStopAndRestartWithMixedBeans() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestLifecycleBean simpleBean1 = TestLifecycleBean.forStartupTests(startedBeans); TestLifecycleBean simpleBean2 = TestLifecycleBean.forStartupTests(startedBeans); TestSmartLifecycleBean smartBean1 = TestSmartLifecycleBean.forStartupTests(5, startedBeans); @@ -255,7 +255,7 @@ public class DefaultLifecycleProcessorTests { public void smartLifecycleGroupShutdown() throws Exception { Assume.group(TestGroup.PERFORMANCE); - CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 300, stoppedBeans); TestSmartLifecycleBean bean2 = TestSmartLifecycleBean.forShutdownTests(3, 100, stoppedBeans); TestSmartLifecycleBean bean3 = TestSmartLifecycleBean.forShutdownTests(1, 600, stoppedBeans); @@ -286,7 +286,7 @@ public class DefaultLifecycleProcessorTests { public void singleSmartLifecycleShutdown() throws Exception { Assume.group(TestGroup.PERFORMANCE); - CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean bean = TestSmartLifecycleBean.forShutdownTests(99, 300, stoppedBeans); StaticApplicationContext context = new StaticApplicationContext(); context.getBeanFactory().registerSingleton("bean", bean); @@ -300,7 +300,7 @@ public class DefaultLifecycleProcessorTests { @Test public void singleLifecycleShutdown() throws Exception { - CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList<>(); Lifecycle bean = new TestLifecycleBean(null, stoppedBeans); StaticApplicationContext context = new StaticApplicationContext(); context.getBeanFactory().registerSingleton("bean", bean); @@ -316,7 +316,7 @@ public class DefaultLifecycleProcessorTests { @Test public void mixedShutdown() throws Exception { - CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList<>(); Lifecycle bean1 = TestLifecycleBean.forShutdownTests(stoppedBeans); Lifecycle bean2 = TestSmartLifecycleBean.forShutdownTests(500, 200, stoppedBeans); Lifecycle bean3 = TestSmartLifecycleBean.forShutdownTests(Integer.MAX_VALUE, 100, stoppedBeans); @@ -364,7 +364,7 @@ public class DefaultLifecycleProcessorTests { @Test public void dependencyStartedFirstEvenIfItsPhaseIsHigher() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forStartupTests(Integer.MIN_VALUE, startedBeans); TestSmartLifecycleBean bean2 = TestSmartLifecycleBean.forStartupTests(2, startedBeans); TestSmartLifecycleBean bean99 = TestSmartLifecycleBean.forStartupTests(99, startedBeans); @@ -394,7 +394,7 @@ public class DefaultLifecycleProcessorTests { public void dependentShutdownFirstEvenIfItsPhaseIsLower() throws Exception { Assume.group(TestGroup.PERFORMANCE); - CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forShutdownTests(Integer.MIN_VALUE, 100, stoppedBeans); TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 200, stoppedBeans); TestSmartLifecycleBean bean99 = TestSmartLifecycleBean.forShutdownTests(99, 100, stoppedBeans); @@ -436,7 +436,7 @@ public class DefaultLifecycleProcessorTests { @Test public void dependencyStartedFirstAndIsSmartLifecycle() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean beanNegative = TestSmartLifecycleBean.forStartupTests(-99, startedBeans); TestSmartLifecycleBean bean99 = TestSmartLifecycleBean.forStartupTests(99, startedBeans); TestSmartLifecycleBean bean7 = TestSmartLifecycleBean.forStartupTests(7, startedBeans); @@ -468,7 +468,7 @@ public class DefaultLifecycleProcessorTests { public void dependentShutdownFirstAndIsSmartLifecycle() throws Exception { Assume.group(TestGroup.PERFORMANCE); - CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forShutdownTests(Integer.MIN_VALUE, 400, stoppedBeans); TestSmartLifecycleBean beanNegative = TestSmartLifecycleBean.forShutdownTests(-99, 100, stoppedBeans); TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 200, stoppedBeans); @@ -509,7 +509,7 @@ public class DefaultLifecycleProcessorTests { @Test public void dependencyStartedFirstButNotSmartLifecycle() throws Exception { - CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList startedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forStartupTests(Integer.MIN_VALUE, startedBeans); TestSmartLifecycleBean bean7 = TestSmartLifecycleBean.forStartupTests(7, startedBeans); TestLifecycleBean simpleBean = TestLifecycleBean.forStartupTests(startedBeans); @@ -533,7 +533,7 @@ public class DefaultLifecycleProcessorTests { public void dependentShutdownFirstButNotSmartLifecycle() throws Exception { Assume.group(TestGroup.PERFORMANCE); - CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList(); + CopyOnWriteArrayList stoppedBeans = new CopyOnWriteArrayList<>(); TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 200, stoppedBeans); TestLifecycleBean simpleBean = TestLifecycleBean.forShutdownTests(stoppedBeans); TestSmartLifecycleBean bean2 = TestSmartLifecycleBean.forShutdownTests(2, 300, stoppedBeans); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java index aad1246f628..31fa4cbeaba 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio @Override protected ConfigurableApplicationContext createContext() throws Exception { StaticApplicationContext parent = new StaticApplicationContext(); - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("name", "Roderick"); parent.registerPrototype("rod", TestBean.class, new MutablePropertyValues(m)); m.put("name", "Albert"); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java index 8a30b5424b2..c266f7d94ab 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes @Override protected ConfigurableApplicationContext createContext() throws Exception { StaticApplicationContext parent = new StaticApplicationContext(); - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("name", "Roderick"); parent.registerPrototype("rod", TestBean.class, new MutablePropertyValues(m)); m.put("name", "Albert"); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index 634dfa9e91f..739b3335798 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -191,7 +191,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { protected ConfigurableApplicationContext createContext() throws Exception { StaticApplicationContext parent = new StaticApplicationContext(); - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("name", "Roderick"); parent.registerPrototype("rod", org.springframework.tests.sample.beans.TestBean.class, new MutablePropertyValues(m)); m.put("name", "Albert"); @@ -214,7 +214,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { sac.addApplicationListener(listener); StaticMessageSource messageSource = sac.getStaticMessageSource(); - Map usMessages = new HashMap(3); + Map usMessages = new HashMap<>(3); usMessages.put("message.format.example1", MSG_TXT1_US); usMessages.put("message.format.example2", MSG_TXT2_US); usMessages.put("message.format.example3", MSG_TXT3_US); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java index 0681d4ece1b..f1e93b3e1d0 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java @@ -260,7 +260,7 @@ public class DateFormattingTests { @DateTimeFormat(iso=ISO.DATE_TIME) private Date isoDateTime; - private final List children = new ArrayList(); + private final List children = new ArrayList<>(); public Long getMillis() { return millis; diff --git a/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java index b0de33ec7b6..3ac3e45f1b9 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java @@ -570,7 +570,7 @@ public class JodaTimeFormattingTests { private MonthDay monthDay; - private final List children = new ArrayList(); + private final List children = new ArrayList<>(); public LocalDate getLocalDate() { return localDate; diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java index f112d4462c5..f4d22caa3c9 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java @@ -421,7 +421,7 @@ public class DateTimeFormattingTests { private MonthDay monthDay; - private final List children = new ArrayList(); + private final List children = new ArrayList<>(); public LocalDate getLocalDate() { return localDate; diff --git a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java index 067befcbc10..72bfdd5b451 100644 --- a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ public class FormattingConversionServiceFactoryBeanTests { @Test public void testCustomFormatter() throws Exception { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); - Set formatters = new HashSet(); + Set formatters = new HashSet<>(); formatters.add(new TestBeanFormatter()); formatters.add(new SpecialIntAnnotationFormatterFactory()); factory.setFormatters(formatters); @@ -105,7 +105,7 @@ public class FormattingConversionServiceFactoryBeanTests { @Test public void testFormatterRegistrar() throws Exception { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); - Set registrars = new HashSet(); + Set registrars = new HashSet<>(); registrars.add(new TestFormatterRegistrar()); factory.setFormatterRegistrars(registrars); factory.afterPropertiesSet(); @@ -119,7 +119,7 @@ public class FormattingConversionServiceFactoryBeanTests { @Test public void testInvalidFormatter() throws Exception { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); - Set formatters = new HashSet(); + Set formatters = new HashSet<>(); formatters.add(new Object()); factory.setFormatters(formatters); try { @@ -174,7 +174,7 @@ public class FormattingConversionServiceFactoryBeanTests { private static class SpecialIntAnnotationFormatterFactory implements AnnotationFormatterFactory { - private final Set> fieldTypes = new HashSet>(1); + private final Set> fieldTypes = new HashSet<>(1); public SpecialIntAnnotationFormatterFactory() { fieldTypes.add(Integer.class); diff --git a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java index a6f5779b848..07b7364152f 100644 --- a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java +++ b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -205,7 +205,7 @@ public class FormattingConversionServiceTests { new TypeDescriptor(modelClass.getField("date")))); assertEquals(new LocalDate(2009, 10, 31), date); - List dates = new ArrayList(); + List dates = new ArrayList<>(); dates.add(new LocalDate(2009, 10, 31).toDateTimeAtCurrentTime().toDate()); dates.add(new LocalDate(2009, 11, 1).toDateTimeAtCurrentTime().toDate()); dates.add(new LocalDate(2009, 11, 2).toDateTimeAtCurrentTime().toDate()); diff --git a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java index 3f30e901e7d..0abae6b4bf3 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java @@ -67,7 +67,7 @@ public class MBeanClientInterceptorTests extends AbstractMBeanServerTests { target.setName("Rob Harrop"); MBeanExporter adapter = new MBeanExporter(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(OBJECT_NAME, target); adapter.setServer(getServer()); adapter.setBeans(beans); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java index 0fb302c106a..f30b5f27955 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java @@ -79,7 +79,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { @Test public void testRegisterNullNotificationListenerType() throws Exception { - Map listeners = new HashMap(); + Map listeners = new HashMap<>(); // put null in as a value... listeners.put("*", null); MBeanExporter exporter = new MBeanExporter(); @@ -90,7 +90,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { @Test public void testRegisterNotificationListenerForNonExistentMBean() throws Exception { - Map listeners = new HashMap(); + Map listeners = new HashMap<>(); NotificationListener dummyListener = new NotificationListener() { @Override public void handleNotification(Notification notification, Object handback) { @@ -130,7 +130,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { @Test public void testUserCreatedMBeanRegWithDynamicMBean() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("spring:name=dynBean", new TestDynamicMBean()); InvokeDetectAssembler asm = new InvokeDetectAssembler(); @@ -249,7 +249,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { IJmxTestBean proxy = (IJmxTestBean) factory.getProxy(); String name = "bean:mmm=whatever"; - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(name, proxy); MBeanExporter exporter = new MBeanExporter(); @@ -268,7 +268,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { SelfNamingTestBean testBean = new SelfNamingTestBean(); testBean.setObjectName(objectName); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put("foo", testBean); MBeanExporter exporter = new MBeanExporter(); @@ -295,7 +295,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { String objectName2 = "spring:test=equalBean"; - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.toString(), springRegistered); beans.put(objectName2, springRegistered); @@ -327,7 +327,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { Person springRegistered = new Person(); springRegistered.setName("Sally Greenwood"); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.toString(), springRegistered); MBeanExporter exporter = new MBeanExporter(); @@ -353,7 +353,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { bean.setName(name); ObjectName objectName = ObjectNameManager.getInstance("spring:type=Test"); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.toString(), bean); MBeanExporter exporter = new MBeanExporter(); @@ -383,7 +383,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { factory.registerSingleton(exportedBeanName, new TestBean()); MBeanExporter exporter = new MBeanExporter(); - Map beansToExport = new HashMap(); + Map beansToExport = new HashMap<>(); beansToExport.put(OBJECT_NAME, exportedBeanName); exporter.setBeans(beansToExport); exporter.setServer(getServer()); @@ -470,7 +470,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { MBeanExporter exporter = new MBeanExporter(); exporter.setServer(getServer()); - Map beansToExport = new HashMap(); + Map beansToExport = new HashMap<>(); beansToExport.put(OBJECT_NAME, OBJECT_NAME); exporter.setBeans(beansToExport); exporter.setAssembler(new NamedBeanAutodetectCapableMBeanInfoAssemblerStub(OBJECT_NAME)); @@ -526,7 +526,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { @Test public void testNotRunningInBeanFactoryAndPassedBeanNameToExport() throws Exception { MBeanExporter exporter = new MBeanExporter(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(OBJECT_NAME, "beanName"); exporter.setBeans(beans); thrown.expect(MBeanExportException.class); @@ -576,7 +576,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { MBeanExporter exporter = new MBeanExporter(); exporter.setServer(getServer()); - Map beansToExport = new HashMap(); + Map beansToExport = new HashMap<>(); beansToExport.put("test:what=ever", testBeanInstance); exporter.setBeans(beansToExport); exporter.setBeanFactory(factory); @@ -598,7 +598,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { MBeanExporter exporter = new MBeanExporter(); exporter.setServer(getServer()); - Map beansToExport = new HashMap(); + Map beansToExport = new HashMap<>(); beansToExport.put("test:what=ever", testBeanInstance); exporter.setBeans(beansToExport); exporter.setBeanFactory(factory); @@ -626,7 +626,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { MBeanExporter exporter = new MBeanExporter(); exporter.setServer(getServer()); - Map beansToExport = new HashMap(); + Map beansToExport = new HashMap<>(); beansToExport.put(objectName1, objectName1); beansToExport.put(objectName2, objectName2); exporter.setBeans(beansToExport); @@ -672,7 +672,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { } private Map getBeanMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put(OBJECT_NAME, new JmxTestBean()); return map; } @@ -700,9 +700,9 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { private static class MockMBeanExporterListener implements MBeanExporterListener { - private List registered = new ArrayList(); + private List registered = new ArrayList<>(); - private List unregistered = new ArrayList(); + private List unregistered = new ArrayList<>(); @Override public void mbeanRegistered(ObjectName objectName) { @@ -762,7 +762,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests { public static final class StubNotificationListener implements NotificationListener { - private List notifications = new ArrayList(); + private List notifications = new ArrayList<>(); @Override public void handleNotification(Notification notification, Object handback) { diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java index 149e574c27e..7d6789e7727 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.getCanonicalName(), bean); CountingAttributeChangeNotificationListener listener = new CountingAttributeChangeNotificationListener(); @@ -76,7 +76,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.getCanonicalName(), bean); CountingAttributeChangeNotificationListener listener = new CountingAttributeChangeNotificationListener(); @@ -101,7 +101,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { String objectName = "spring:name=Test"; JmxTestBean bean = new JmxTestBean(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName, bean); CountingAttributeChangeNotificationListener listener = new CountingAttributeChangeNotificationListener(); @@ -132,7 +132,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.getCanonicalName(), bean); CountingAttributeChangeNotificationListener listener = new CountingAttributeChangeNotificationListener(); @@ -159,7 +159,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.getCanonicalName(), bean); CountingAttributeChangeNotificationListener listener = new CountingAttributeChangeNotificationListener(); @@ -218,7 +218,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerSingleton(beanName, testBean); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(beanName, beanName); Map listenerMappings = new HashMap(); @@ -249,7 +249,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerSingleton(beanName, testBean); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(beanName, testBean); Map listenerMappings = new HashMap(); @@ -280,7 +280,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerSingleton(beanName, testBean); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(beanName, testBean); Map listenerMappings = new HashMap(); @@ -312,7 +312,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); factory.registerSingleton(beanName, testBean); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(beanName, testBean); Map listenerMappings = new HashMap(); @@ -351,7 +351,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { factory.registerSingleton(beanName1, testBean1); factory.registerSingleton(beanName2, testBean2); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(beanName1, testBean1); beans.put(beanName2, testBean2); @@ -381,7 +381,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.getCanonicalName(), bean); MBeanExporter exporter = new MBeanExporter(); @@ -416,7 +416,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { JmxTestBean bean = new JmxTestBean(); JmxTestBean bean2 = new JmxTestBean(); - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName.getCanonicalName(), bean); beans.put(objectName2.getCanonicalName(), bean2); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java index 4bcbdc57afa..30e386280dd 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java @@ -172,7 +172,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble String objectName = "spring:bean=test,proxy=true"; - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put(objectName, proxy); exporter.setBeans(beans); start(exporter); diff --git a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java b/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java index 15bd7ba0959..a3bfea5729e 100644 --- a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class SimpleNamingContextTests { assertTrue("Correct DataSource registered", context1.lookup("java:comp/env/jdbc/myds") == ds); assertTrue("Correct Object registered", context1.lookup("myobject") == obj); - Hashtable env2 = new Hashtable(); + Hashtable env2 = new Hashtable<>(); env2.put("key1", "value1"); Context context2 = factory.getInitialContext(env2); assertTrue("Correct DataSource registered", context2.lookup("java:comp/env/jdbc/myds") == ds); @@ -116,7 +116,7 @@ public class SimpleNamingContextTests { assertTrue("Correct Integer registered", context3.lookup("myinteger") == i); assertTrue("Correct String registered", context3.lookup("mystring") == s); - Map bindingMap = new HashMap(); + Map bindingMap = new HashMap<>(); NamingEnumeration bindingEnum = context3.listBindings(""); while (bindingEnum.hasMoreElements()) { Binding binding = (Binding) bindingEnum.nextElement(); @@ -127,7 +127,7 @@ public class SimpleNamingContextTests { Context jdbcContext = (Context) context3.lookup("jdbc"); jdbcContext.bind("mydsX", ds); - Map subBindingMap = new HashMap(); + Map subBindingMap = new HashMap<>(); NamingEnumeration subBindingEnum = jdbcContext.listBindings(""); while (subBindingEnum.hasMoreElements()) { Binding binding = (Binding) subBindingEnum.nextElement(); @@ -145,7 +145,7 @@ public class SimpleNamingContextTests { context1.createSubcontext("jdbc").bind("sub/subds", ds); - Map pairMap = new HashMap(); + Map pairMap = new HashMap<>(); NamingEnumeration pairEnum = context2.list("jdbc"); while (pairEnum.hasMore()) { NameClassPair pair = (NameClassPair) pairEnum.next(); @@ -154,7 +154,7 @@ public class SimpleNamingContextTests { assertTrue("Correct sub subcontext", SimpleNamingContext.class.getName().equals(pairMap.get("sub"))); Context subContext = (Context) context2.lookup("jdbc/sub"); - Map subPairMap = new HashMap(); + Map subPairMap = new HashMap<>(); NamingEnumeration subPairEnum = subContext.list(""); while (subPairEnum.hasMoreElements()) { NameClassPair pair = (NameClassPair) subPairEnum.next(); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java index 0d55ec7a20c..d431ca90bde 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -454,7 +454,7 @@ public class AsyncExecutionTests { else if (i < 0) { return AsyncResult.forExecutionException(new IOException()); } - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } @Async @@ -494,13 +494,13 @@ public class AsyncExecutionTests { public Future returnSomething(int i) { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); assertTrue(Thread.currentThread().getName().startsWith("e2-")); - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } public Future returnSomething2(int i) { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); assertTrue(Thread.currentThread().getName().startsWith("e0-")); - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } } @@ -528,7 +528,7 @@ public class AsyncExecutionTests { if (i == 0) { throw new IllegalArgumentException(); } - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } public ListenableFuture returnSomethingListenable(int i) { @@ -536,7 +536,7 @@ public class AsyncExecutionTests { if (i == 0) { throw new IllegalArgumentException(); } - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } @Async @@ -571,7 +571,7 @@ public class AsyncExecutionTests { public Future returnSomething(int i) { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } } @@ -595,7 +595,7 @@ public class AsyncExecutionTests { @Override public Future returnSomething(int i) { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } } @@ -611,7 +611,7 @@ public class AsyncExecutionTests { public Object invoke(MethodInvocation invocation) throws Throwable { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); if (Future.class.equals(invocation.getMethod().getReturnType())) { - return new AsyncResult(invocation.getArguments()[0].toString()); + return new AsyncResult<>(invocation.getArguments()[0].toString()); } return null; } @@ -665,7 +665,7 @@ public class AsyncExecutionTests { @Override public Future returnSomething(int i) { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); - return new AsyncResult(Integer.toString(i)); + return new AsyncResult<>(Integer.toString(i)); } } @@ -681,7 +681,7 @@ public class AsyncExecutionTests { public Object invoke(MethodInvocation invocation) throws Throwable { assertTrue(!Thread.currentThread().getName().equals(originalThreadName)); if (Future.class.equals(invocation.getMethod().getReturnType())) { - return new AsyncResult(invocation.getArguments()[0].toString()); + return new AsyncResult<>(invocation.getArguments()[0].toString()); } return null; } diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java index 3f04c76db30..54573d1ec94 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -160,22 +160,22 @@ public class EnableAsyncTests { @Async public Future work0() { - return new AsyncResult(Thread.currentThread()); + return new AsyncResult<>(Thread.currentThread()); } @Async("e1") public Future work() { - return new AsyncResult(Thread.currentThread()); + return new AsyncResult<>(Thread.currentThread()); } @Async("otherExecutor") public Future work2() { - return new AsyncResult(Thread.currentThread()); + return new AsyncResult<>(Thread.currentThread()); } @Async("e2") public Future work3() { - return new AsyncResult(Thread.currentThread()); + return new AsyncResult<>(Thread.currentThread()); } } diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java index 6f5a00b20a8..3e7fe5e5d3e 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java @@ -486,7 +486,7 @@ public class ScheduledAnnotationBeanPostProcessorTests { BeanDefinition targetDefinition = new RootBeanDefinition(ExpressionWithCronTestBean.class); context.registerBeanDefinition("postProcessor", processorDefinition); context.registerBeanDefinition("target", targetDefinition); - Map schedules = new HashMap(); + Map schedules = new HashMap<>(); schedules.put("businessHours", businessHoursCronExpression); context.getBeanFactory().registerSingleton("schedules", schedules); context.refresh(); diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java index 08239ddfb6e..ab2af2c5a81 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class ThreadPoolExecutorFactoryBeanTests { ApplicationContext context = new AnnotationConfigApplicationContext(ExecutorConfig.class); ExecutorService executor = context.getBean("executor", ExecutorService.class); - FutureTask task = new FutureTask(new Callable() { + FutureTask task = new FutureTask<>(new Callable() { @Override public String call() throws Exception { return "foo"; diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java index 9777e559e13..9204132f49e 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class ExecutorBeanDefinitionParserTests { assertEquals(60, getKeepAliveSeconds(executor)); assertEquals(false, getAllowCoreThreadTimeOut(executor)); - FutureTask task = new FutureTask(new Callable() { + FutureTask task = new FutureTask<>(new Callable() { @Override public String call() throws Exception { return "foo"; diff --git a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java index 773291168f5..e0ead9542e6 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class CronTriggerTests { @Parameters(name = "date [{0}], time zone [{1}]") public static List getParameters() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(new Object[] { new Date(), TimeZone.getTimeZone("PST") }); list.add(new Object[] { new Date(), TimeZone.getTimeZone("CET") }); return list; diff --git a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java index a325658f31d..3da382ec007 100644 --- a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class BshScriptEvaluatorTests { @Test public void testGroovyScriptWithArguments() { ScriptEvaluator evaluator = new BshScriptEvaluator(); - Map arguments = new HashMap(); + Map arguments = new HashMap<>(); arguments.put("a", 3); arguments.put("b", 2); Object result = evaluator.evaluate(new StaticScriptSource("return a * b;"), arguments); diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java index 14ab7aa3568..615458c7702 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ public class GroovyScriptEvaluatorTests { @Test public void testGroovyScriptWithArguments() { ScriptEvaluator evaluator = new GroovyScriptEvaluator(); - Map arguments = new HashMap(); + Map arguments = new HashMap<>(); arguments.put("a", 3); arguments.put("b", 2); Object result = evaluator.evaluate(new StaticScriptSource("return a * b"), arguments); @@ -77,7 +77,7 @@ public class GroovyScriptEvaluatorTests { public void testGroovyScriptWithArgumentsUsingJsr223() { StandardScriptEvaluator evaluator = new StandardScriptEvaluator(); evaluator.setLanguage("Groovy"); - Map arguments = new HashMap(); + Map arguments = new HashMap<>(); arguments.put("a", 3); arguments.put("b", 2); Object result = evaluator.evaluate(new StaticScriptSource("return a * b"), arguments); diff --git a/spring-context/src/test/java/org/springframework/tests/context/SimpleMapScope.java b/spring-context/src/test/java/org/springframework/tests/context/SimpleMapScope.java index 9b63bfc3332..7ae94ba27f2 100644 --- a/spring-context/src/test/java/org/springframework/tests/context/SimpleMapScope.java +++ b/spring-context/src/test/java/org/springframework/tests/context/SimpleMapScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,9 +32,9 @@ import org.springframework.beans.factory.config.Scope; @SuppressWarnings("serial") public class SimpleMapScope implements Scope, Serializable { - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); - private final List callbacks = new LinkedList(); + private final List callbacks = new LinkedList<>(); public SimpleMapScope() { diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java b/spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java index 8cc22aab1b2..aef52f3801f 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java +++ b/spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.jndi.JndiTemplate; */ public class ExpectedLookupTemplate extends JndiTemplate { - private final Map jndiObjects = new ConcurrentHashMap(); + private final Map jndiObjects = new ConcurrentHashMap<>(); /** diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java b/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java index bdad96e32d0..c4ba15c2179 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java +++ b/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class SimpleNamingContext implements Context { private final Hashtable boundObjects; - private final Hashtable environment = new Hashtable(); + private final Hashtable environment = new Hashtable<>(); /** @@ -73,7 +73,7 @@ public class SimpleNamingContext implements Context { */ public SimpleNamingContext(String root) { this.root = root; - this.boundObjects = new Hashtable(); + this.boundObjects = new Hashtable<>(); } /** @@ -302,7 +302,7 @@ public class SimpleNamingContext implements Context { proot = proot + "/"; } String root = context.root + proot; - Map contents = new HashMap(); + Map contents = new HashMap<>(); for (String boundName : context.boundObjects.keySet()) { if (boundName.startsWith(root)) { int startIndex = root.length(); diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java b/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java index 1ae3b78d6b1..34b63b18c6a 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java +++ b/spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder private final Log logger = LogFactory.getLog(getClass()); - private final Hashtable boundObjects = new Hashtable(); + private final Hashtable boundObjects = new Hashtable<>(); /** diff --git a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java index 8d225238044..a8b6c279f84 100644 --- a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java +++ b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,7 +115,7 @@ public final class ModelMapTests { @Test public void testOneArgCtorWithEmptyCollection() throws Exception { - ModelMap model = new ModelMap(new HashSet()); + ModelMap model = new ModelMap(new HashSet<>()); // must not add if collection is empty... assertEquals(0, model.size()); } @@ -154,7 +154,7 @@ public final class ModelMapTests { public void testAddAllObjectsWithSparseArrayList() throws Exception { // Null model arguments added without a name being explicitly supplied are not allowed ModelMap model = new ModelMap(); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); list.add("bing"); list.add(null); model.addAllAttributes(list); @@ -162,7 +162,7 @@ public final class ModelMapTests { @Test public void testAddMap() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("one", "one-value"); map.put("two", "two-value"); ModelMap model = new ModelMap(); @@ -184,7 +184,7 @@ public final class ModelMapTests { @Test public void testAddListOfTheSameObjects() throws Exception { - List beans = new ArrayList(); + List beans = new ArrayList<>(); beans.add(new TestBean("one")); beans.add(new TestBean("two")); beans.add(new TestBean("three")); @@ -195,7 +195,7 @@ public final class ModelMapTests { @Test public void testMergeMapWithOverriding() throws Exception { - Map beans = new HashMap(); + Map beans = new HashMap<>(); beans.put("one", new TestBean("one")); beans.put("two", new TestBean("two")); beans.put("three", new TestBean("three")); @@ -238,7 +238,7 @@ public final class ModelMapTests { public void testAopJdkProxy() throws Exception { ModelMap map = new ModelMap(); ProxyFactory factory = new ProxyFactory(); - Map target = new HashMap(); + Map target = new HashMap<>(); factory.setTarget(target); factory.addInterface(Map.class); Object proxy = factory.getProxy(); @@ -249,7 +249,7 @@ public final class ModelMapTests { @Test public void testAopJdkProxyWithMultipleInterfaces() throws Exception { ModelMap map = new ModelMap(); - Map target = new HashMap(); + Map target = new HashMap<>(); ProxyFactory factory = new ProxyFactory(); factory.setTarget(target); factory.addInterface(Serializable.class); @@ -264,7 +264,7 @@ public final class ModelMapTests { @Test public void testAopJdkProxyWithDetectedInterfaces() throws Exception { ModelMap map = new ModelMap(); - Map target = new HashMap(); + Map target = new HashMap<>(); ProxyFactory factory = new ProxyFactory(target); Object proxy = factory.getProxy(); map.addAttribute(proxy); diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java index bdb12118b96..c34c0a1fbe2 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -2112,7 +2112,7 @@ public class DataBinderTests { private List list; public GrowingList() { - this.list = new ArrayList(); + this.list = new ArrayList<>(); } public List getWrappedList() { @@ -2200,8 +2200,8 @@ public class DataBinderTests { private final Map f; public Form() { - f = new HashMap(); - f.put("list", new GrowingList()); + f = new HashMap<>(); + f.put("list", new GrowingList<>()); } public Map getF() { diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java index 144c6fd98fa..09a11e66810 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -266,10 +266,10 @@ public class ValidatorFactoryTests { private ValidAddress address = new ValidAddress(); @Valid - private List addressList = new LinkedList(); + private List addressList = new LinkedList<>(); @Valid - private Set addressSet = new LinkedHashSet(); + private Set addressSet = new LinkedHashSet<>(); public boolean expectsAutowiredValidator = false; diff --git a/spring-core/src/main/java/org/springframework/core/AttributeAccessorSupport.java b/spring-core/src/main/java/org/springframework/core/AttributeAccessorSupport.java index dbbe1aff514..10017c658b6 100644 --- a/spring-core/src/main/java/org/springframework/core/AttributeAccessorSupport.java +++ b/spring-core/src/main/java/org/springframework/core/AttributeAccessorSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.util.Assert; public abstract class AttributeAccessorSupport implements AttributeAccessor, Serializable { /** Map with String keys and Object values */ - private final Map attributes = new LinkedHashMap(0); + private final Map attributes = new LinkedHashMap<>(0); @Override diff --git a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java index 15ecf85ee14..3e6953b35a6 100644 --- a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java +++ b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public abstract class BridgeMethodResolver { return bridgeMethod; } // Gather all methods with matching name and parameter size. - List candidateMethods = new ArrayList(); + List candidateMethods = new ArrayList<>(); Method[] methods = ReflectionUtils.getAllDeclaredMethods(bridgeMethod.getDeclaringClass()); for (Method candidateMethod : methods) { if (isBridgedCandidateFor(candidateMethod, bridgeMethod)) { diff --git a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java b/spring-core/src/main/java/org/springframework/core/CollectionFactory.java index e9af0617fcd..060bf0c3e99 100644 --- a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java +++ b/spring-core/src/main/java/org/springframework/core/CollectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,9 +55,9 @@ import org.springframework.util.MultiValueMap; */ public abstract class CollectionFactory { - private static final Set> approximableCollectionTypes = new HashSet>(11); + private static final Set> approximableCollectionTypes = new HashSet<>(11); - private static final Set> approximableMapTypes = new HashSet>(7); + private static final Set> approximableMapTypes = new HashSet<>(7); static { @@ -118,10 +118,10 @@ public abstract class CollectionFactory { @SuppressWarnings({ "unchecked", "cast", "rawtypes" }) public static Collection createApproximateCollection(Object collection, int capacity) { if (collection instanceof LinkedList) { - return new LinkedList(); + return new LinkedList<>(); } else if (collection instanceof List) { - return new ArrayList(capacity); + return new ArrayList<>(capacity); } else if (collection instanceof EnumSet) { // Cast is necessary for compilation in Eclipse 4.4.1. @@ -130,10 +130,10 @@ public abstract class CollectionFactory { return enumSet; } else if (collection instanceof SortedSet) { - return new TreeSet(((SortedSet) collection).comparator()); + return new TreeSet<>(((SortedSet) collection).comparator()); } else { - return new LinkedHashSet(capacity); + return new LinkedHashSet<>(capacity); } } @@ -179,13 +179,13 @@ public abstract class CollectionFactory { Assert.notNull(collectionType, "Collection type must not be null"); if (collectionType.isInterface()) { if (Set.class == collectionType || Collection.class == collectionType) { - return new LinkedHashSet(capacity); + return new LinkedHashSet<>(capacity); } else if (List.class == collectionType) { - return new ArrayList(capacity); + return new ArrayList<>(capacity); } else if (SortedSet.class == collectionType || NavigableSet.class == collectionType) { - return new TreeSet(); + return new TreeSet<>(); } else { throw new IllegalArgumentException("Unsupported Collection interface: " + collectionType.getName()); @@ -245,10 +245,10 @@ public abstract class CollectionFactory { return enumMap; } else if (map instanceof SortedMap) { - return new TreeMap(((SortedMap) map).comparator()); + return new TreeMap<>(((SortedMap) map).comparator()); } else { - return new LinkedHashMap(capacity); + return new LinkedHashMap<>(capacity); } } @@ -295,10 +295,10 @@ public abstract class CollectionFactory { Assert.notNull(mapType, "Map type must not be null"); if (mapType.isInterface()) { if (Map.class == mapType) { - return new LinkedHashMap(capacity); + return new LinkedHashMap<>(capacity); } else if (SortedMap.class == mapType || NavigableMap.class == mapType) { - return new TreeMap(); + return new TreeMap<>(); } else if (MultiValueMap.class == mapType) { return new LinkedMultiValueMap(); diff --git a/spring-core/src/main/java/org/springframework/core/Constants.java b/spring-core/src/main/java/org/springframework/core/Constants.java index 3f8d9737bc8..16df5584b3e 100644 --- a/spring-core/src/main/java/org/springframework/core/Constants.java +++ b/spring-core/src/main/java/org/springframework/core/Constants.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class Constants { private final String className; /** Map from String field name to object value */ - private final Map fieldCache = new HashMap(); + private final Map fieldCache = new HashMap<>(); /** @@ -159,7 +159,7 @@ public class Constants { */ public Set getNames(String namePrefix) { String prefixToUse = (namePrefix != null ? namePrefix.trim().toUpperCase(Locale.ENGLISH) : ""); - Set names = new HashSet(); + Set names = new HashSet<>(); for (String code : this.fieldCache.keySet()) { if (code.startsWith(prefixToUse)) { names.add(code); @@ -191,7 +191,7 @@ public class Constants { */ public Set getNamesForSuffix(String nameSuffix) { String suffixToUse = (nameSuffix != null ? nameSuffix.trim().toUpperCase(Locale.ENGLISH) : ""); - Set names = new HashSet(); + Set names = new HashSet<>(); for (String code : this.fieldCache.keySet()) { if (code.endsWith(suffixToUse)) { names.add(code); @@ -213,7 +213,7 @@ public class Constants { */ public Set getValues(String namePrefix) { String prefixToUse = (namePrefix != null ? namePrefix.trim().toUpperCase(Locale.ENGLISH) : ""); - Set values = new HashSet(); + Set values = new HashSet<>(); for (String code : this.fieldCache.keySet()) { if (code.startsWith(prefixToUse)) { values.add(this.fieldCache.get(code)); @@ -245,7 +245,7 @@ public class Constants { */ public Set getValuesForSuffix(String nameSuffix) { String suffixToUse = (nameSuffix != null ? nameSuffix.trim().toUpperCase(Locale.ENGLISH) : ""); - Set values = new HashSet(); + Set values = new HashSet<>(); for (String code : this.fieldCache.keySet()) { if (code.endsWith(suffixToUse)) { values.add(this.fieldCache.get(code)); diff --git a/spring-core/src/main/java/org/springframework/core/Conventions.java b/spring-core/src/main/java/org/springframework/core/Conventions.java index 2c4152ff194..867ff4fc5da 100644 --- a/spring-core/src/main/java/org/springframework/core/Conventions.java +++ b/spring-core/src/main/java/org/springframework/core/Conventions.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public abstract class Conventions { private static final Set> IGNORED_INTERFACES; static { IGNORED_INTERFACES = Collections.unmodifiableSet( - new HashSet>(Arrays.> asList( + new HashSet<>(Arrays.>asList( Serializable.class, Externalizable.class, Cloneable.class, diff --git a/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java b/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java index 5819d30c125..6bcf98d05ba 100644 --- a/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java +++ b/spring-core/src/main/java/org/springframework/core/ExceptionDepthComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ public class ExceptionDepthComparator implements Comparator> handledExceptions = - new ArrayList>(exceptionTypes); + new ArrayList<>(exceptionTypes); Collections.sort(handledExceptions, new ExceptionDepthComparator(targetException)); return handledExceptions.get(0); } diff --git a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java index 74cfb0122cd..acd21913981 100644 --- a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java +++ b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public abstract class GenericTypeResolver { /** Cache from Class to TypeVariable Map */ @SuppressWarnings("rawtypes") private static final Map, Map> typeVariableCache = - new ConcurrentReferenceHashMap, Map>(); + new ConcurrentReferenceHashMap<>(); /** @@ -273,7 +273,7 @@ public abstract class GenericTypeResolver { public static Map getTypeVariableMap(Class clazz) { Map typeVariableMap = typeVariableCache.get(clazz); if (typeVariableMap == null) { - typeVariableMap = new HashMap(); + typeVariableMap = new HashMap<>(); buildTypeVariableMap(ResolvableType.forClass(clazz), typeVariableMap); typeVariableCache.put(clazz, Collections.unmodifiableMap(typeVariableMap)); } diff --git a/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java index cc09fd80d3c..767be3046ef 100644 --- a/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD // the cache uses a nested index (value is a map) to keep the top level cache relatively small in size private final Map, Map> parameterNamesCache = - new ConcurrentHashMap, Map>(32); + new ConcurrentHashMap<>(32); @Override @@ -110,7 +110,7 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD } try { ClassReader classReader = new ClassReader(is); - Map map = new ConcurrentHashMap(32); + Map map = new ConcurrentHashMap<>(32); classReader.accept(new ParameterNameDiscoveringVisitor(clazz, map), 0); return map; } diff --git a/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java b/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java index edf92355de9..dbd594c4637 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java +++ b/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,8 +52,8 @@ public abstract class MethodIntrospector { * or an empty map in case of no match */ public static Map selectMethods(Class targetType, final MetadataLookup metadataLookup) { - final Map methodMap = new LinkedHashMap(); - Set> handlerTypes = new LinkedHashSet>(); + final Map methodMap = new LinkedHashMap<>(); + Set> handlerTypes = new LinkedHashSet<>(); Class specificHandlerType = null; if (!Proxy.isProxyClass(targetType)) { diff --git a/spring-core/src/main/java/org/springframework/core/MethodParameter.java b/spring-core/src/main/java/org/springframework/core/MethodParameter.java index 86179de64d3..223a48ff4ae 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodParameter.java +++ b/spring-core/src/main/java/org/springframework/core/MethodParameter.java @@ -277,7 +277,7 @@ public class MethodParameter { */ private Map getTypeIndexesPerLevel() { if (this.typeIndexesPerLevel == null) { - this.typeIndexesPerLevel = new HashMap(4); + this.typeIndexesPerLevel = new HashMap<>(4); } return this.typeIndexesPerLevel; } diff --git a/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java b/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java index 086a0cc967e..535118be7d6 100644 --- a/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java +++ b/spring-core/src/main/java/org/springframework/core/PrioritizedParameterNameDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import java.util.List; public class PrioritizedParameterNameDiscoverer implements ParameterNameDiscoverer { private final List parameterNameDiscoverers = - new LinkedList(); + new LinkedList<>(); /** diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 60c6c4547ee..2302b88d239 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,7 @@ public class ResolvableType implements Serializable { private static final ResolvableType[] EMPTY_TYPES_ARRAY = new ResolvableType[0]; private static final ConcurrentReferenceHashMap cache = - new ConcurrentReferenceHashMap(256); + new ConcurrentReferenceHashMap<>(256); /** @@ -334,7 +334,7 @@ public class ResolvableType implements Serializable { return false; } if (matchedBefore == null) { - matchedBefore = new IdentityHashMap(1); + matchedBefore = new IdentityHashMap<>(1); } matchedBefore.put(this.type, other.type); for (int i = 0; i < ourGenerics.length; i++) { diff --git a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java index 8f1fd9d9eb3..5338c830adb 100644 --- a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java +++ b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ abstract class SerializableTypeWrapper { GenericArrayType.class, ParameterizedType.class, TypeVariable.class, WildcardType.class}; private static final ConcurrentReferenceHashMap cache = - new ConcurrentReferenceHashMap(256); + new ConcurrentReferenceHashMap<>(256); /** diff --git a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java index 16c73b5f41d..b1ff3b7e009 100644 --- a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.util.StringValueResolver; public class SimpleAliasRegistry implements AliasRegistry { /** Map from alias to canonical name */ - private final Map aliasMap = new ConcurrentHashMap(16); + private final Map aliasMap = new ConcurrentHashMap<>(16); @Override @@ -105,7 +105,7 @@ public class SimpleAliasRegistry implements AliasRegistry { @Override public String[] getAliases(String name) { - List result = new ArrayList(); + List result = new ArrayList<>(); synchronized (this.aliasMap) { retrieveAliases(name, result); } @@ -138,7 +138,7 @@ public class SimpleAliasRegistry implements AliasRegistry { public void resolveAliases(StringValueResolver valueResolver) { Assert.notNull(valueResolver, "StringValueResolver must not be null"); synchronized (this.aliasMap) { - Map aliasCopy = new HashMap(this.aliasMap); + Map aliasCopy = new HashMap<>(this.aliasMap); for (String alias : aliasCopy.keySet()) { String registeredName = aliasCopy.get(alias); String resolvedAlias = valueResolver.resolveStringValue(alias); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java index 14f571fbeb3..e19015f1eed 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java @@ -183,14 +183,14 @@ public class AnnotatedElementUtils { } try { - final Set types = new LinkedHashSet(); + final Set types = new LinkedHashSet<>(); searchWithGetSemantics(composed.annotationType(), null, null, null, new SimpleAnnotationProcessor(true) { @Override public Object process(AnnotatedElement annotatedElement, Annotation annotation, int metaDepth) { types.add(annotation.annotationType().getName()); return CONTINUE; } - }, new HashSet(), 1); + }, new HashSet<>(), 1); return (!types.isEmpty() ? types : null); } catch (Throwable ex) { @@ -560,7 +560,7 @@ public class AnnotatedElementUtils { public static MultiValueMap getAllAnnotationAttributes(AnnotatedElement element, String annotationName, final boolean classValuesAsString, final boolean nestedAnnotationsAsMap) { - final MultiValueMap attributesMap = new LinkedMultiValueMap(); + final MultiValueMap attributesMap = new LinkedMultiValueMap<>(); searchWithGetSemantics(element, null, annotationName, new SimpleAnnotationProcessor() { @Override @@ -853,7 +853,7 @@ public class AnnotatedElementUtils { try { return searchWithGetSemantics(element, annotationType, annotationName, containerType, processor, - new HashSet(), 0); + new HashSet<>(), 0); } catch (Throwable ex) { AnnotationUtils.rethrowAnnotationConfigurationException(ex); @@ -895,7 +895,7 @@ public class AnnotatedElementUtils { } if (element instanceof Class) { // otherwise getAnnotations doesn't return anything new - List inheritedAnnotations = new ArrayList(); + List inheritedAnnotations = new ArrayList<>(); for (Annotation annotation : element.getAnnotations()) { if (!declaredAnnotations.contains(annotation)) { inheritedAnnotations.add(annotation); @@ -1037,7 +1037,7 @@ public class AnnotatedElementUtils { try { return searchWithFindSemantics( - element, annotationType, annotationName, containerType, processor, new HashSet(), 0); + element, annotationType, annotationName, containerType, processor, new HashSet<>(), 0); } catch (Throwable ex) { AnnotationUtils.rethrowAnnotationConfigurationException(ex); @@ -1073,7 +1073,7 @@ public class AnnotatedElementUtils { try { // Locally declared annotations (ignoring @Inherited) Annotation[] annotations = element.getDeclaredAnnotations(); - List aggregatedResults = (processor.aggregates() ? new ArrayList() : null); + List aggregatedResults = (processor.aggregates() ? new ArrayList<>() : null); // Search in local annotations for (Annotation annotation : annotations) { @@ -1302,7 +1302,7 @@ public class AnnotatedElementUtils { private static Set postProcessAndSynthesizeAggregatedResults(AnnotatedElement element, Class annotationType, List aggregatedResults) { - Set annotations = new LinkedHashSet(); + Set annotations = new LinkedHashSet<>(); for (AnnotationAttributes attributes : aggregatedResults) { AnnotationUtils.postProcessAnnotationAttributes(element, attributes, false, false); annotations.add(AnnotationUtils.synthesizeAnnotation(attributes, annotationType, element)); @@ -1502,7 +1502,7 @@ public class AnnotatedElementUtils { this.classValuesAsString = classValuesAsString; this.nestedAnnotationsAsMap = nestedAnnotationsAsMap; this.aggregates = aggregates; - this.aggregatedResults = (aggregates ? new ArrayList() : null); + this.aggregatedResults = (aggregates ? new ArrayList<>() : null); } @Override @@ -1533,7 +1533,7 @@ public class AnnotatedElementUtils { // Track which attribute values have already been replaced so that we can short // circuit the search algorithms. - Set valuesAlreadyReplaced = new HashSet(); + Set valuesAlreadyReplaced = new HashSet<>(); for (Method attributeMethod : AnnotationUtils.getAttributeMethods(annotation.annotationType())) { String attributeName = attributeMethod.getName(); @@ -1545,7 +1545,7 @@ public class AnnotatedElementUtils { continue; } - List targetAttributeNames = new ArrayList(); + List targetAttributeNames = new ArrayList<>(); targetAttributeNames.add(attributeOverrideName); valuesAlreadyReplaced.add(attributeOverrideName); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index 6f13e492a0f..15fc7c7dc27 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -114,25 +114,25 @@ public abstract class AnnotationUtils { private static final String REPEATABLE_CLASS_NAME = "java.lang.annotation.Repeatable"; private static final Map findAnnotationCache = - new ConcurrentReferenceHashMap(256); + new ConcurrentReferenceHashMap<>(256); private static final Map metaPresentCache = - new ConcurrentReferenceHashMap(256); + new ConcurrentReferenceHashMap<>(256); private static final Map, Boolean> annotatedInterfaceCache = - new ConcurrentReferenceHashMap, Boolean>(256); + new ConcurrentReferenceHashMap<>(256); private static final Map, Boolean> synthesizableCache = - new ConcurrentReferenceHashMap, Boolean>(256); + new ConcurrentReferenceHashMap<>(256); private static final Map, Map>> attributeAliasesCache = - new ConcurrentReferenceHashMap, Map>>(256); + new ConcurrentReferenceHashMap<>(256); private static final Map, List> attributeMethodsCache = - new ConcurrentReferenceHashMap, List>(256); + new ConcurrentReferenceHashMap<>(256); private static final Map aliasDescriptorCache = - new ConcurrentReferenceHashMap(256); + new ConcurrentReferenceHashMap<>(256); private static transient Log logger; @@ -438,7 +438,7 @@ public abstract class AnnotationUtils { if (annotatedElement instanceof Method) { annotatedElement = BridgeMethodResolver.findBridgedMethod((Method) annotatedElement); } - return new AnnotationCollector(annotationType, containerAnnotationType, declaredMode).getResult(annotatedElement); + return new AnnotationCollector<>(annotationType, containerAnnotationType, declaredMode).getResult(annotatedElement); } catch (Exception ex) { handleIntrospectionFailure(annotatedElement, ex); @@ -470,7 +470,7 @@ public abstract class AnnotationUtils { // Do NOT store result in the findAnnotationCache since doing so could break // findAnnotation(Class, Class) and findAnnotation(Method, Class). - A ann = findAnnotation(annotatedElement, annotationType, new HashSet()); + A ann = findAnnotation(annotatedElement, annotationType, new HashSet<>()); return synthesizeAnnotation(ann, annotatedElement); } @@ -655,7 +655,7 @@ public abstract class AnnotationUtils { AnnotationCacheKey cacheKey = new AnnotationCacheKey(clazz, annotationType); A result = (A) findAnnotationCache.get(cacheKey); if (result == null) { - result = findAnnotation(clazz, annotationType, new HashSet()); + result = findAnnotation(clazz, annotationType, new HashSet<>()); if (result != null && synthesize) { result = synthesizeAnnotation(result, clazz); findAnnotationCache.put(cacheKey, result); @@ -1144,7 +1144,7 @@ public abstract class AnnotationUtils { // Track which attribute values have already been replaced so that we can short // circuit the search algorithms. - Set valuesAlreadyReplaced = new HashSet(); + Set valuesAlreadyReplaced = new HashSet<>(); // Validate @AliasFor configuration Map> aliasMap = getAttributeAliasMap(annotationType); @@ -1509,7 +1509,7 @@ public abstract class AnnotationUtils { return map; } - map = new LinkedHashMap>(); + map = new LinkedHashMap<>(); for (Method attribute : getAttributeMethods(annotationType)) { List aliasNames = getAttributeAliasNames(attribute); if (!aliasNames.isEmpty()) { @@ -1645,7 +1645,7 @@ public abstract class AnnotationUtils { return methods; } - methods = new ArrayList(); + methods = new ArrayList<>(); for (Method method : annotationType.getDeclaredMethods()) { if (isAttributeMethod(method)) { ReflectionUtils.makeAccessible(method); @@ -1824,9 +1824,9 @@ public abstract class AnnotationUtils { private final boolean declaredMode; - private final Set visited = new HashSet(); + private final Set visited = new HashSet<>(); - private final Set result = new LinkedHashSet(); + private final Set result = new LinkedHashSet<>(); AnnotationCollector(Class annotationType, Class containerAnnotationType, boolean declaredMode) { this.annotationType = annotationType; @@ -1867,7 +1867,7 @@ public abstract class AnnotationUtils { @SuppressWarnings("unchecked") private List getValue(AnnotatedElement element, Annotation annotation) { try { - List synthesizedAnnotations = new ArrayList(); + List synthesizedAnnotations = new ArrayList<>(); for (A anno : (A[]) AnnotationUtils.getValue(annotation)) { synthesizedAnnotations.add(synthesizeAnnotation(anno, element)); } @@ -2080,7 +2080,7 @@ public abstract class AnnotationUtils { } // Else: search for implicit aliases - List aliases = new ArrayList(); + List aliases = new ArrayList<>(); for (AliasDescriptor otherDescriptor : getOtherDescriptors()) { if (this.isAliasFor(otherDescriptor)) { this.validateAgainst(otherDescriptor); @@ -2091,7 +2091,7 @@ public abstract class AnnotationUtils { } private List getOtherDescriptors() { - List otherDescriptors = new ArrayList(); + List otherDescriptors = new ArrayList<>(); for (Method currentAttribute : getAttributeMethods(this.sourceAnnotationType)) { if (!this.sourceAttribute.equals(currentAttribute)) { AliasDescriptor otherDescriptor = AliasDescriptor.from(currentAttribute); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/MapAnnotationAttributeExtractor.java b/spring-core/src/main/java/org/springframework/core/annotation/MapAnnotationAttributeExtractor.java index 15ca984e81b..2c2606a058b 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/MapAnnotationAttributeExtractor.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/MapAnnotationAttributeExtractor.java @@ -88,7 +88,7 @@ class MapAnnotationAttributeExtractor extends AbstractAliasAwareAnnotationAttrib private static Map enrichAndValidateAttributes( Map originalAttributes, Class annotationType) { - Map attributes = new LinkedHashMap(originalAttributes); + Map attributes = new LinkedHashMap<>(originalAttributes); Map> attributeAliasMap = getAttributeAliasMap(annotationType); for (Method attributeMethod : getAttributeMethods(annotationType)) { diff --git a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedAnnotationInvocationHandler.java b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedAnnotationInvocationHandler.java index c8614eb575e..1f07ed2592e 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedAnnotationInvocationHandler.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/SynthesizedAnnotationInvocationHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class SynthesizedAnnotationInvocationHandler implements InvocationHandler { private final AnnotationAttributeExtractor attributeExtractor; - private final Map valueCache = new ConcurrentHashMap(8); + private final Map valueCache = new ConcurrentHashMap<>(8); /** diff --git a/spring-core/src/main/java/org/springframework/core/convert/Property.java b/spring-core/src/main/java/org/springframework/core/convert/Property.java index 84258e9d96a..b86b10c5939 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/Property.java +++ b/spring-core/src/main/java/org/springframework/core/convert/Property.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ import org.springframework.util.StringUtils; public final class Property { private static Map annotationCache = - new ConcurrentReferenceHashMap(); + new ConcurrentReferenceHashMap<>(); private final Class objectType; @@ -194,7 +194,7 @@ public final class Property { private Annotation[] resolveAnnotations() { Annotation[] annotations = annotationCache.get(this); if (annotations == null) { - Map, Annotation> annotationMap = new LinkedHashMap, Annotation>(); + Map, Annotation> annotationMap = new LinkedHashMap<>(); addAnnotationsToMap(annotationMap, getReadMethod()); addAnnotationsToMap(annotationMap, getWriteMethod()); addAnnotationsToMap(annotationMap, getField()); diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java index 85a15f66c79..53856f91aaa 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java @@ -48,7 +48,7 @@ public class TypeDescriptor implements Serializable { static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0]; - private static final Map, TypeDescriptor> commonTypesCache = new HashMap, TypeDescriptor>(18); + private static final Map, TypeDescriptor> commonTypesCache = new HashMap<>(18); private static final Class[] CACHED_COMMON_TYPES = { boolean.class, Boolean.class, byte.class, Byte.class, char.class, Character.class, diff --git a/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java b/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java index a6b5a8f41b8..19e128c8848 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java +++ b/spring-core/src/main/java/org/springframework/core/convert/converter/ConvertingComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ public class ConvertingComparator implements Comparator { public ConvertingComparator( Comparator comparator, ConversionService conversionService, Class targetType) { - this(comparator, new ConversionServiceConverter(conversionService, targetType)); + this(comparator, new ConversionServiceConverter<>(conversionService, targetType)); } @@ -88,7 +88,7 @@ public class ConvertingComparator implements Comparator { * @return a new {@link ConvertingComparator} instance */ public static ConvertingComparator, K> mapEntryKeys(Comparator comparator) { - return new ConvertingComparator, K>(comparator, new Converter, K>() { + return new ConvertingComparator<>(comparator, new Converter, K>() { @Override public K convert(Map.Entry source) { return source.getKey(); @@ -103,7 +103,7 @@ public class ConvertingComparator implements Comparator { * @return a new {@link ConvertingComparator} instance */ public static ConvertingComparator, V> mapEntryValues(Comparator comparator) { - return new ConvertingComparator, V>(comparator, new Converter, V>() { + return new ConvertingComparator<>(comparator, new Converter, V>() { @Override public V convert(Map.Entry source) { return source.getValue(); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ByteBufferConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ByteBufferConverter.java index 878808d7208..5db79a94037 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ByteBufferConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ByteBufferConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ final class ByteBufferConverter implements ConditionalGenericConverter { private static final Set CONVERTIBLE_PAIRS; static { - Set convertiblePairs = new HashSet(4); + Set convertiblePairs = new HashSet<>(4); convertiblePairs.add(new ConvertiblePair(ByteBuffer.class, byte[].class)); convertiblePairs.add(new ConvertiblePair(byte[].class, ByteBuffer.class)); convertiblePairs.add(new ConvertiblePair(ByteBuffer.class, Object.class)); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/CharacterToNumberFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/CharacterToNumberFactory.java index 179823f32c1..e91bc9736c1 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/CharacterToNumberFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/CharacterToNumberFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ final class CharacterToNumberFactory implements ConverterFactory Converter getConverter(Class targetType) { - return new CharacterToNumber(targetType); + return new CharacterToNumber<>(targetType); } private static final class CharacterToNumber implements Converter { diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java index 1790b617903..24743d45570 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java @@ -76,7 +76,7 @@ public class GenericConversionService implements ConfigurableConversionService { private final Converters converters = new Converters(); private final Map converterCache = - new ConcurrentReferenceHashMap(64); + new ConcurrentReferenceHashMap<>(64); // ConverterRegistry implementation @@ -476,10 +476,10 @@ public class GenericConversionService implements ConfigurableConversionService { */ private static class Converters { - private final Set globalConverters = new LinkedHashSet(); + private final Set globalConverters = new LinkedHashSet<>(); private final Map converters = - new LinkedHashMap(36); + new LinkedHashMap<>(36); public void add(GenericConverter converter) { Set convertibleTypes = converter.getConvertibleTypes(); @@ -559,8 +559,8 @@ public class GenericConversionService implements ConfigurableConversionService { * @return an ordered list of all classes that the given type extends or implements */ private List> getClassHierarchy(Class type) { - List> hierarchy = new ArrayList>(20); - Set> visited = new HashSet>(20); + List> hierarchy = new ArrayList<>(20); + Set> visited = new HashSet<>(20); addToClassHierarchy(0, ClassUtils.resolvePrimitiveIfNecessary(type), false, hierarchy, visited); boolean array = type.isArray(); @@ -617,7 +617,7 @@ public class GenericConversionService implements ConfigurableConversionService { } private List getConverterStrings() { - List converterStrings = new ArrayList(); + List converterStrings = new ArrayList<>(); for (ConvertersForPair convertersForPair : converters.values()) { converterStrings.add(convertersForPair.toString()); } @@ -632,7 +632,7 @@ public class GenericConversionService implements ConfigurableConversionService { */ private static class ConvertersForPair { - private final LinkedList converters = new LinkedList(); + private final LinkedList converters = new LinkedList<>(); public void add(GenericConverter converter) { this.converters.addFirst(converter); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java index b5225c7e810..bbe611f4ca0 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/MapToMapConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ final class MapToMapConverter implements ConditionalGenericConverter { TypeDescriptor keyDesc = targetType.getMapKeyTypeDescriptor(); TypeDescriptor valueDesc = targetType.getMapValueTypeDescriptor(); - List targetEntries = new ArrayList(sourceMap.size()); + List targetEntries = new ArrayList<>(sourceMap.size()); for (Map.Entry entry : sourceMap.entrySet()) { Object sourceKey = entry.getKey(); Object sourceValue = entry.getValue(); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/NumberToNumberConverterFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/NumberToNumberConverterFactory.java index 773721a2348..a0d467c58b6 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/NumberToNumberConverterFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/NumberToNumberConverterFactory.java @@ -44,7 +44,7 @@ final class NumberToNumberConverterFactory implements ConverterFactory Converter getConverter(Class targetType) { - return new NumberToNumber(targetType); + return new NumberToNumber<>(targetType); } @Override diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToObjectConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToObjectConverter.java index b3183c6e17f..c68034d929b 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToObjectConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ObjectToObjectConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ final class ObjectToObjectConverter implements ConditionalGenericConverter { // Cache for the latest to-method resolved on a given Class private static final Map, Member> conversionMemberCache = - new ConcurrentReferenceHashMap, Member>(32); + new ConcurrentReferenceHashMap<>(32); @Override diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java index 3ef3bbffabc..93274976c8d 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java @@ -112,7 +112,7 @@ class StreamConverter implements ConditionalGenericConverter { private static Set createConvertibleTypes() { - Set convertiblePairs = new HashSet(); + Set convertiblePairs = new HashSet<>(); convertiblePairs.add(new ConvertiblePair(Stream.class, Collection.class)); convertiblePairs.add(new ConvertiblePair(Stream.class, Object[].class)); convertiblePairs.add(new ConvertiblePair(Collection.class, Stream.class)); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java index 1d8bc61ef7b..2c46bc9c3cf 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ import org.springframework.core.convert.converter.Converter; */ final class StringToBooleanConverter implements Converter { - private static final Set trueValues = new HashSet(4); + private static final Set trueValues = new HashSet<>(4); - private static final Set falseValues = new HashSet(4); + private static final Set falseValues = new HashSet<>(4); static { trueValues.add("true"); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java index 172e8d2d5d4..1ed02ec4729 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToNumberConverterFactory.java @@ -42,7 +42,7 @@ final class StringToNumberConverterFactory implements ConverterFactory Converter getConverter(Class targetType) { - return new StringToNumber(targetType); + return new StringToNumber<>(targetType); } diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java index de7c5ac6c5e..af23835eb8e 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java @@ -104,9 +104,9 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment { protected final Log logger = LogFactory.getLog(getClass()); - private final Set activeProfiles = new LinkedHashSet(); + private final Set activeProfiles = new LinkedHashSet<>(); - private final Set defaultProfiles = new LinkedHashSet(getReservedDefaultProfiles()); + private final Set defaultProfiles = new LinkedHashSet<>(getReservedDefaultProfiles()); private final MutablePropertySources propertySources = new MutablePropertySources(this.logger); diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java index a8e395396b1..20d690b5a07 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java @@ -52,7 +52,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe private String valueSeparator = SystemPropertyUtils.VALUE_SEPARATOR; - private final Set requiredProperties = new LinkedHashSet(); + private final Set requiredProperties = new LinkedHashSet<>(); @Override diff --git a/spring-core/src/main/java/org/springframework/core/env/CommandLineArgs.java b/spring-core/src/main/java/org/springframework/core/env/CommandLineArgs.java index 189484a6dfc..951f1cefb8d 100644 --- a/spring-core/src/main/java/org/springframework/core/env/CommandLineArgs.java +++ b/spring-core/src/main/java/org/springframework/core/env/CommandLineArgs.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,8 +33,8 @@ import java.util.Set; */ class CommandLineArgs { - private final Map> optionArgs = new HashMap>(); - private final List nonOptionArgs = new ArrayList(); + private final Map> optionArgs = new HashMap<>(); + private final List nonOptionArgs = new ArrayList<>(); /** * Add an option argument for the given option name and add the given value to the @@ -44,7 +44,7 @@ class CommandLineArgs { */ public void addOptionArg(String optionName, String optionValue) { if (!this.optionArgs.containsKey(optionName)) { - this.optionArgs.put(optionName, new ArrayList()); + this.optionArgs.put(optionName, new ArrayList<>()); } if (optionValue != null) { this.optionArgs.get(optionName).add(optionValue); diff --git a/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java index 8591360229a..31902223704 100644 --- a/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/CompositePropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ import org.springframework.util.StringUtils; */ public class CompositePropertySource extends EnumerablePropertySource { - private final Set> propertySources = new LinkedHashSet>(); + private final Set> propertySources = new LinkedHashSet<>(); /** @@ -76,7 +76,7 @@ public class CompositePropertySource extends EnumerablePropertySource { @Override public String[] getPropertyNames() { - Set names = new LinkedHashSet(); + Set names = new LinkedHashSet<>(); for (PropertySource propertySource : this.propertySources) { if (!(propertySource instanceof EnumerablePropertySource)) { throw new IllegalStateException( @@ -102,7 +102,7 @@ public class CompositePropertySource extends EnumerablePropertySource { * @since 4.1 */ public void addFirstPropertySource(PropertySource propertySource) { - List> existing = new ArrayList>(this.propertySources); + List> existing = new ArrayList<>(this.propertySources); this.propertySources.clear(); this.propertySources.add(propertySource); this.propertySources.addAll(existing); diff --git a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java index b34e4b9dc4a..b35a4cb53f1 100644 --- a/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/JOptCommandLinePropertySource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,9 +82,9 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource names = new ArrayList(); + List names = new ArrayList<>(); for (OptionSpec spec : this.source.specs()) { - List aliases = new ArrayList(spec.options()); + List aliases = new ArrayList<>(spec.options()); if (!aliases.isEmpty()) { // Only the longest name is used for enumerating names.add(aliases.get(aliases.size() - 1)); @@ -96,7 +96,7 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource getOptionValues(String name) { List argValues = this.source.valuesOf(name); - List stringArgValues = new ArrayList(); + List stringArgValues = new ArrayList<>(); for (Object argValue : argValues) { stringArgValues.add(argValue instanceof String ? (String) argValue : argValue.toString()); } @@ -109,7 +109,7 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource getNonOptionArgs() { List argValues = this.source.nonOptionArguments(); - List stringArgValues = new ArrayList(); + List stringArgValues = new ArrayList<>(); for (Object argValue : argValues) { Assert.isInstanceOf(String.class, argValue, "Argument values must be of type String"); stringArgValues.add((String) argValue); diff --git a/spring-core/src/main/java/org/springframework/core/env/MissingRequiredPropertiesException.java b/spring-core/src/main/java/org/springframework/core/env/MissingRequiredPropertiesException.java index 8c4d338e2c8..18866d1045d 100644 --- a/spring-core/src/main/java/org/springframework/core/env/MissingRequiredPropertiesException.java +++ b/spring-core/src/main/java/org/springframework/core/env/MissingRequiredPropertiesException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import java.util.Set; @SuppressWarnings("serial") public class MissingRequiredPropertiesException extends IllegalStateException { - private final Set missingRequiredProperties = new LinkedHashSet(); + private final Set missingRequiredProperties = new LinkedHashSet<>(); /** * Return the set of properties marked as required but not present diff --git a/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java b/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java index 1587833c081..10976daf718 100644 --- a/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java +++ b/spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class MutablePropertySources implements PropertySources { private final Log logger; - private final List> propertySourceList = new CopyOnWriteArrayList>(); + private final List> propertySourceList = new CopyOnWriteArrayList<>(); /** diff --git a/spring-core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java b/spring-core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java index b7c5219f1b2..34a15b7c7c2 100644 --- a/spring-core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java +++ b/spring-core/src/main/java/org/springframework/core/io/DefaultResourceLoader.java @@ -45,7 +45,7 @@ public class DefaultResourceLoader implements ResourceLoader { private ClassLoader classLoader; - private final Set protocolResolvers = new LinkedHashSet(4); + private final Set protocolResolvers = new LinkedHashSet<>(4); /** diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java index 7f8c8f029d5..c24739d498c 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java @@ -327,7 +327,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol * @since 4.1.1 */ protected Set doFindAllClassPathResources(String path) throws IOException { - Set result = new LinkedHashSet(16); + Set result = new LinkedHashSet<>(16); ClassLoader cl = getClassLoader(); Enumeration resourceUrls = (cl != null ? cl.getResources(path) : ClassLoader.getSystemResources(path)); while (resourceUrls.hasMoreElements()) { @@ -459,7 +459,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol String rootDirPath = determineRootDir(locationPattern); String subPattern = locationPattern.substring(rootDirPath.length()); Resource[] rootDirResources = getResources(rootDirPath); - Set result = new LinkedHashSet(16); + Set result = new LinkedHashSet<>(16); for (Resource rootDirResource : rootDirResources) { rootDirResource = resolveRootDirResource(rootDirResource); URL rootDirURL = rootDirResource.getURL(); @@ -607,7 +607,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol // The Sun JRE does not return a slash here, but BEA JRockit does. rootEntryPath = rootEntryPath + "/"; } - Set result = new LinkedHashSet(8); + Set result = new LinkedHashSet<>(8); for (Enumeration entries = jarFile.entries(); entries.hasMoreElements();) { JarEntry entry = entries.nextElement(); String entryPath = entry.getName(); @@ -687,7 +687,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol logger.debug("Looking for matching resources in directory tree [" + rootDir.getPath() + "]"); } Set matchingFiles = retrieveMatchingFiles(rootDir, subPattern); - Set result = new LinkedHashSet(matchingFiles.size()); + Set result = new LinkedHashSet<>(matchingFiles.size()); for (File file : matchingFiles) { result.add(new FileSystemResource(file)); } @@ -730,7 +730,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol fullPattern += "/"; } fullPattern = fullPattern + StringUtils.replace(pattern, File.separator, "/"); - Set result = new LinkedHashSet(8); + Set result = new LinkedHashSet<>(8); doRetrieveMatchingFiles(fullPattern, rootDir, result); return result; } @@ -806,7 +806,7 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol private final String rootPath; - private final Set resources = new LinkedHashSet(); + private final Set resources = new LinkedHashSet<>(); public PatternVirtualFileVisitor(String rootPath, String subPattern, PathMatcher pathMatcher) { this.subPattern = subPattern; diff --git a/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java b/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java index 101fe8150be..bb394e0f9c0 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,7 +125,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport { public void setValue(Object value) throws IllegalArgumentException { if (value instanceof Collection || (value instanceof Object[] && !(value instanceof Resource[]))) { Collection input = (value instanceof Collection ? (Collection) value : Arrays.asList((Object[]) value)); - List merged = new ArrayList(); + List merged = new ArrayList<>(); for (Object element : input) { if (element instanceof String) { // A location pattern: resolve it into a Resource array. diff --git a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java index 8021208bafb..57bf6e03410 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java @@ -88,7 +88,7 @@ public abstract class SpringFactoriesLoader { if (logger.isTraceEnabled()) { logger.trace("Loaded [" + factoryClass.getName() + "] names: " + factoryNames); } - List result = new ArrayList(factoryNames.size()); + List result = new ArrayList<>(factoryNames.size()); for (String factoryName : factoryNames) { result.add(instantiateFactory(factoryName, factoryClass, classLoaderToUse)); } @@ -111,7 +111,7 @@ public abstract class SpringFactoriesLoader { try { Enumeration urls = (classLoader != null ? classLoader.getResources(FACTORIES_RESOURCE_LOCATION) : ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION)); - List result = new ArrayList(); + List result = new ArrayList<>(); while (urls.hasMoreElements()) { URL url = urls.nextElement(); Properties properties = PropertiesLoaderUtils.loadProperties(new UrlResource(url)); diff --git a/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java b/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java index 0483932ae7b..8d392835a92 100644 --- a/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java +++ b/spring-core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java @@ -191,28 +191,28 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator implement @Override public Future submit(Runnable task) { - FutureTask future = new FutureTask(task, null); + FutureTask future = new FutureTask<>(task, null); execute(future, TIMEOUT_INDEFINITE); return future; } @Override public Future submit(Callable task) { - FutureTask future = new FutureTask(task); + FutureTask future = new FutureTask<>(task); execute(future, TIMEOUT_INDEFINITE); return future; } @Override public ListenableFuture submitListenable(Runnable task) { - ListenableFutureTask future = new ListenableFutureTask(task, null); + ListenableFutureTask future = new ListenableFutureTask<>(task, null); execute(future, TIMEOUT_INDEFINITE); return future; } @Override public ListenableFuture submitListenable(Callable task) { - ListenableFutureTask future = new ListenableFutureTask(task); + ListenableFutureTask future = new ListenableFutureTask<>(task); execute(future, TIMEOUT_INDEFINITE); return future; } diff --git a/spring-core/src/main/java/org/springframework/core/task/support/TaskExecutorAdapter.java b/spring-core/src/main/java/org/springframework/core/task/support/TaskExecutorAdapter.java index 165533dfadc..2811f7f9247 100644 --- a/spring-core/src/main/java/org/springframework/core/task/support/TaskExecutorAdapter.java +++ b/spring-core/src/main/java/org/springframework/core/task/support/TaskExecutorAdapter.java @@ -102,7 +102,7 @@ public class TaskExecutorAdapter implements AsyncListenableTaskExecutor { return ((ExecutorService) this.concurrentExecutor).submit(task); } else { - FutureTask future = new FutureTask(task, null); + FutureTask future = new FutureTask<>(task, null); doExecute(this.concurrentExecutor, this.taskDecorator, future); return future; } @@ -120,7 +120,7 @@ public class TaskExecutorAdapter implements AsyncListenableTaskExecutor { return ((ExecutorService) this.concurrentExecutor).submit(task); } else { - FutureTask future = new FutureTask(task); + FutureTask future = new FutureTask<>(task); doExecute(this.concurrentExecutor, this.taskDecorator, future); return future; } @@ -134,7 +134,7 @@ public class TaskExecutorAdapter implements AsyncListenableTaskExecutor { @Override public ListenableFuture submitListenable(Runnable task) { try { - ListenableFutureTask future = new ListenableFutureTask(task, null); + ListenableFutureTask future = new ListenableFutureTask<>(task, null); doExecute(this.concurrentExecutor, this.taskDecorator, future); return future; } @@ -147,7 +147,7 @@ public class TaskExecutorAdapter implements AsyncListenableTaskExecutor { @Override public ListenableFuture submitListenable(Callable task) { try { - ListenableFutureTask future = new ListenableFutureTask(task); + ListenableFutureTask future = new ListenableFutureTask<>(task); doExecute(this.concurrentExecutor, this.taskDecorator, future); return future; } diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java index 668a4b5cf38..ff2f1e695d7 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements @Override public Set getAnnotationTypes() { - Set types = new LinkedHashSet(); + Set types = new LinkedHashSet<>(); for (Annotation ann : this.annotations) { types.add(ann.annotationType().getName()); } @@ -150,7 +150,7 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements public Set getAnnotatedMethods(String annotationName) { try { Method[] methods = getIntrospectedClass().getDeclaredMethods(); - Set annotatedMethods = new LinkedHashSet(); + Set annotatedMethods = new LinkedHashSet<>(); for (Method method : methods) { if (!method.isBridge() && method.getAnnotations().length > 0 && AnnotatedElementUtils.isAnnotated(method, annotationName)) { diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java index 935184b0c52..9330e29b1a2 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardClassMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +121,7 @@ public class StandardClassMetadata implements ClassMetadata { @Override public String[] getMemberClassNames() { - LinkedHashSet memberClassNames = new LinkedHashSet(); + LinkedHashSet memberClassNames = new LinkedHashSet<>(); for (Class nestedClass : this.introspectedClass.getDeclaredClasses()) { memberClassNames.add(nestedClass.getName()); } diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java index ab001b50ecb..7dc0631385e 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java @@ -72,7 +72,7 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib else { attributes.add(0, this.attributes); } - Set visited = new LinkedHashSet(); + Set visited = new LinkedHashSet<>(); Annotation[] metaAnnotations = AnnotationUtils.getAnnotations(annotationClass); if (!ObjectUtils.isEmpty(metaAnnotations)) { for (Annotation metaAnnotation : metaAnnotations) { @@ -82,7 +82,7 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib } } if (this.metaAnnotationMap != null) { - Set metaAnnotationTypeNames = new LinkedHashSet(visited.size()); + Set metaAnnotationTypeNames = new LinkedHashSet<>(visited.size()); for (Annotation ann : visited) { metaAnnotationTypeNames.add(ann.annotationType().getName()); } diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java index eea3d825806..ade5e772046 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,9 +50,9 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito protected final ClassLoader classLoader; - protected final Set annotationSet = new LinkedHashSet(4); + protected final Set annotationSet = new LinkedHashSet<>(4); - protected final Map> metaAnnotationMap = new LinkedHashMap>(4); + protected final Map> metaAnnotationMap = new LinkedHashMap<>(4); /** * Declared as a {@link LinkedMultiValueMap} instead of a {@link MultiValueMap} @@ -60,9 +60,9 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito * @see AnnotationReadingVisitorUtils#getMergedAnnotationAttributes */ protected final LinkedMultiValueMap attributesMap = - new LinkedMultiValueMap(4); + new LinkedMultiValueMap<>(4); - protected final Set methodMetadataSet = new LinkedHashSet(4); + protected final Set methodMetadataSet = new LinkedHashSet<>(4); public AnnotationMetadataReadingVisitor(ClassLoader classLoader) { @@ -141,7 +141,7 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito @Override public MultiValueMap getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) { - MultiValueMap allAttributes = new LinkedMultiValueMap(); + MultiValueMap allAttributes = new LinkedMultiValueMap<>(); List attributes = this.attributesMap.get(annotationName); if (attributes == null) { return null; @@ -167,7 +167,7 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito @Override public Set getAnnotatedMethods(String annotationName) { - Set annotatedMethods = new LinkedHashSet(4); + Set annotatedMethods = new LinkedHashSet<>(4); for (MethodMetadata methodMetadata : this.methodMetadataSet) { if (methodMetadata.isAnnotated(annotationName)) { annotatedMethods.add(methodMetadata); diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java index 0d7ba35f259..f6e71a94f2f 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationReadingVisitorUtils.java @@ -129,13 +129,13 @@ abstract class AnnotationReadingVisitorUtils { // method. AnnotationAttributes results = new AnnotationAttributes(attributesList.get(0)); - Set overridableAttributeNames = new HashSet(results.keySet()); + Set overridableAttributeNames = new HashSet<>(results.keySet()); overridableAttributeNames.remove(AnnotationUtils.VALUE); // Since the map is a LinkedMultiValueMap, we depend on the ordering of // elements in the map and reverse the order of the keys in order to traverse // "down" the annotation hierarchy. - List annotationTypes = new ArrayList(attributesMap.keySet()); + List annotationTypes = new ArrayList<>(attributesMap.keySet()); Collections.reverse(annotationTypes); // No need to revisit the target annotation type: diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java index 83a62aeebed..2429129052d 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ class ClassMetadataReadingVisitor extends ClassVisitor implements ClassMetadata private String[] interfaces; - private Set memberClassNames = new LinkedHashSet(); + private Set memberClassNames = new LinkedHashSet<>(); public ClassMetadataReadingVisitor() { diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java index 00bd9cb1303..240797a1c59 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,10 +56,10 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho protected final Set methodMetadataSet; - protected final Map> metaAnnotationMap = new LinkedHashMap>(4); + protected final Map> metaAnnotationMap = new LinkedHashMap<>(4); protected final LinkedMultiValueMap attributesMap = - new LinkedMultiValueMap(4); + new LinkedMultiValueMap<>(4); public MethodMetadataReadingVisitor(String methodName, int access, String declaringClassName, @@ -135,7 +135,7 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho if (!this.attributesMap.containsKey(annotationName)) { return null; } - MultiValueMap allAttributes = new LinkedMultiValueMap(); + MultiValueMap allAttributes = new LinkedMultiValueMap<>(); for (AnnotationAttributes annotationAttributes : this.attributesMap.get(annotationName)) { for (Map.Entry entry : AnnotationReadingVisitorUtils.convertClassValues( this.classLoader, annotationAttributes, classValuesAsString).entrySet()) { diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java index 3c5bd9a43f6..f2ec3f55c64 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/RecursiveAnnotationArrayVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ class RecursiveAnnotationArrayVisitor extends AbstractRecursiveAnnotationVisitor private final String attributeName; - private final List allNestedAttributes = new ArrayList(); + private final List allNestedAttributes = new ArrayList<>(); public RecursiveAnnotationArrayVisitor( diff --git a/spring-core/src/main/java/org/springframework/objenesis/SpringObjenesis.java b/spring-core/src/main/java/org/springframework/objenesis/SpringObjenesis.java index f52ddf41551..41d9bdf6c66 100644 --- a/spring-core/src/main/java/org/springframework/objenesis/SpringObjenesis.java +++ b/spring-core/src/main/java/org/springframework/objenesis/SpringObjenesis.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class SpringObjenesis implements Objenesis { private final InstantiatorStrategy strategy; private final ConcurrentReferenceHashMap, ObjectInstantiator> cache = - new ConcurrentReferenceHashMap, ObjectInstantiator>(); + new ConcurrentReferenceHashMap<>(); private volatile Boolean worthTrying; diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index 2d050218ec1..b5e651969d8 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -87,9 +87,9 @@ public class AntPathMatcher implements PathMatcher { private volatile Boolean cachePatterns; - private final Map tokenizedPatternCache = new ConcurrentHashMap(256); + private final Map tokenizedPatternCache = new ConcurrentHashMap<>(256); - final Map stringMatcherCache = new ConcurrentHashMap(256); + final Map stringMatcherCache = new ConcurrentHashMap<>(256); /** @@ -487,7 +487,7 @@ public class AntPathMatcher implements PathMatcher { @Override public Map extractUriTemplateVariables(String pattern, String path) { - Map variables = new LinkedHashMap(); + Map variables = new LinkedHashMap<>(); boolean result = doMatch(pattern, path, true, variables); if (!result) { throw new IllegalStateException("Pattern \"" + pattern + "\" is not a match for \"" + path + "\""); @@ -623,7 +623,7 @@ public class AntPathMatcher implements PathMatcher { private final Pattern pattern; - private final List variableNames = new LinkedList(); + private final List variableNames = new LinkedList<>(); public AntPathStringMatcher(String pattern) { this(pattern, true); diff --git a/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java b/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java index 9cea1c99dfd..1f42d01defc 100644 --- a/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java +++ b/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class AutoPopulatingList implements List, Serializable { * to the backing {@link List} on demand. */ public AutoPopulatingList(Class elementClass) { - this(new ArrayList(), elementClass); + this(new ArrayList<>(), elementClass); } /** @@ -69,7 +69,7 @@ public class AutoPopulatingList implements List, Serializable { * {@link List} on demand. */ public AutoPopulatingList(List backingList, Class elementClass) { - this(backingList, new ReflectiveElementFactory(elementClass)); + this(backingList, new ReflectiveElementFactory<>(elementClass)); } /** @@ -77,7 +77,7 @@ public class AutoPopulatingList implements List, Serializable { * {@link ArrayList} and creates new elements on demand using the supplied {@link ElementFactory}. */ public AutoPopulatingList(ElementFactory elementFactory) { - this(new ArrayList(), elementFactory); + this(new ArrayList<>(), elementFactory); } /** diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 93dd3d616e2..f867fe9aa37 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,25 +76,25 @@ public abstract class ClassUtils { * Map with primitive wrapper type as key and corresponding primitive * type as value, for example: Integer.class -> int.class. */ - private static final Map, Class> primitiveWrapperTypeMap = new IdentityHashMap, Class>(8); + private static final Map, Class> primitiveWrapperTypeMap = new IdentityHashMap<>(8); /** * Map with primitive type as key and corresponding wrapper * type as value, for example: int.class -> Integer.class. */ - private static final Map, Class> primitiveTypeToWrapperMap = new IdentityHashMap, Class>(8); + private static final Map, Class> primitiveTypeToWrapperMap = new IdentityHashMap<>(8); /** * Map with primitive type name as key and corresponding primitive * type as value, for example: "int" -> "int.class". */ - private static final Map> primitiveTypeNameMap = new HashMap>(32); + private static final Map> primitiveTypeNameMap = new HashMap<>(32); /** * Map with common "java.lang" class name as key and corresponding Class as value. * Primarily for efficient deserialization of remote invocations. */ - private static final Map> commonClassCache = new HashMap>(32); + private static final Map> commonClassCache = new HashMap<>(32); static { @@ -112,7 +112,7 @@ public abstract class ClassUtils { registerCommonClasses(entry.getKey()); } - Set> primitiveTypes = new HashSet>(32); + Set> primitiveTypes = new HashSet<>(32); primitiveTypes.addAll(primitiveWrapperTypeMap.values()); primitiveTypes.addAll(Arrays.asList(new Class[] { boolean[].class, byte[].class, char[].class, double[].class, @@ -629,7 +629,7 @@ public abstract class ClassUtils { } } else { - Set candidates = new HashSet(1); + Set candidates = new HashSet<>(1); Method[] methods = clazz.getMethods(); for (Method method : methods) { if (methodName.equals(method.getName())) { @@ -673,7 +673,7 @@ public abstract class ClassUtils { } } else { - Set candidates = new HashSet(1); + Set candidates = new HashSet<>(1); Method[] methods = clazz.getMethods(); for (Method method : methods) { if (methodName.equals(method.getName())) { @@ -1136,7 +1136,7 @@ public abstract class ClassUtils { if (clazz.isInterface() && isVisible(clazz, classLoader)) { return Collections.>singleton(clazz); } - Set> interfaces = new LinkedHashSet>(); + Set> interfaces = new LinkedHashSet<>(); while (clazz != null) { Class[] ifcs = clazz.getInterfaces(); for (Class ifc : ifcs) { diff --git a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java index ae6d8be36e0..7027e261ce7 100644 --- a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -318,7 +318,7 @@ public abstract class CollectionUtils { * returned will be a different instance than the array given. */ public static A[] toArray(Enumeration enumeration, A[] array) { - ArrayList elements = new ArrayList(); + ArrayList elements = new ArrayList<>(); while (enumeration.hasMoreElements()) { elements.add(enumeration.nextElement()); } @@ -331,7 +331,7 @@ public abstract class CollectionUtils { * @return the iterator */ public static Iterator toIterator(Enumeration enumeration) { - return new EnumerationIterator(enumeration); + return new EnumerationIterator<>(enumeration); } /** @@ -341,7 +341,7 @@ public abstract class CollectionUtils { * @since 3.1 */ public static MultiValueMap toMultiValueMap(Map> map) { - return new MultiValueMapAdapter(map); + return new MultiValueMapAdapter<>(map); } /** @@ -353,7 +353,7 @@ public abstract class CollectionUtils { @SuppressWarnings("unchecked") public static MultiValueMap unmodifiableMultiValueMap(MultiValueMap map) { Assert.notNull(map, "'map' must not be null"); - Map> result = new LinkedHashMap>(map.size()); + Map> result = new LinkedHashMap<>(map.size()); for (Map.Entry> entry : map.entrySet()) { List values = Collections.unmodifiableList(entry.getValue()); result.put(entry.getKey(), (List) values); @@ -408,7 +408,7 @@ public abstract class CollectionUtils { public void add(K key, V value) { List values = this.map.get(key); if (values == null) { - values = new LinkedList(); + values = new LinkedList<>(); this.map.put(key, values); } values.add(value); @@ -422,7 +422,7 @@ public abstract class CollectionUtils { @Override public void set(K key, V value) { - List values = new LinkedList(); + List values = new LinkedList<>(); values.add(value); this.map.put(key, values); } @@ -436,7 +436,7 @@ public abstract class CollectionUtils { @Override public Map toSingleValueMap() { - LinkedHashMap singleValueMap = new LinkedHashMap(this.map.size()); + LinkedHashMap singleValueMap = new LinkedHashMap<>(this.map.size()); for (Entry> entry : map.entrySet()) { singleValueMap.put(entry.getKey(), entry.getValue().get(0)); } diff --git a/spring-core/src/main/java/org/springframework/util/CompositeIterator.java b/spring-core/src/main/java/org/springframework/util/CompositeIterator.java index dea6f292a0d..198145c4f87 100644 --- a/spring-core/src/main/java/org/springframework/util/CompositeIterator.java +++ b/spring-core/src/main/java/org/springframework/util/CompositeIterator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import java.util.Set; */ public class CompositeIterator implements Iterator { - private final Set> iterators = new LinkedHashSet>(); + private final Set> iterators = new LinkedHashSet<>(); private boolean inUse = false; diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java index 7710ed273d5..af1e5baedb3 100644 --- a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java +++ b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java @@ -483,7 +483,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen @Override public void add(V value) { @SuppressWarnings("unchecked") - Entry newEntry = new Entry((K) key, value); + Entry newEntry = new Entry<>((K) key, value); Reference newReference = Segment.this.referenceManager.createReference(newEntry, hash, head); Segment.this.references[index] = newReference; Segment.this.count++; @@ -532,7 +532,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen Set> toPurge = Collections.emptySet(); if (reference != null) { - toPurge = new HashSet>(); + toPurge = new HashSet<>(); while (reference != null) { toPurge.add(reference); reference = this.referenceManager.pollForPurge(); @@ -924,7 +924,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen */ protected class ReferenceManager { - private final ReferenceQueue> queue = new ReferenceQueue>(); + private final ReferenceQueue> queue = new ReferenceQueue<>(); /** * Factory method used to create a new {@link Reference}. @@ -935,9 +935,9 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen */ public Reference createReference(Entry entry, int hash, Reference next) { if (ConcurrentReferenceHashMap.this.referenceType == ReferenceType.WEAK) { - return new WeakEntryReference(entry, hash, next, this.queue); + return new WeakEntryReference<>(entry, hash, next, this.queue); } - return new SoftEntryReference(entry, hash, next, this.queue); + return new SoftEntryReference<>(entry, hash, next, this.queue); } /** diff --git a/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java b/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java index 09cb9e8cc01..1258f8fef74 100644 --- a/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java +++ b/spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java @@ -48,7 +48,7 @@ public class FastByteArrayOutputStream extends OutputStream { // The buffers used to store the content bytes - private final LinkedList buffers = new LinkedList(); + private final LinkedList buffers = new LinkedList<>(); // The size, in bytes, to use when allocating the first byte[] private final int initialBlockSize; diff --git a/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java b/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java index cde4e615ef4..fe69026961c 100644 --- a/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java +++ b/spring-core/src/main/java/org/springframework/util/LinkedCaseInsensitiveMap.java @@ -57,7 +57,7 @@ public class LinkedCaseInsensitiveMap extends LinkedHashMap { */ public LinkedCaseInsensitiveMap(Locale locale) { super(); - this.caseInsensitiveKeys = new HashMap(); + this.caseInsensitiveKeys = new HashMap<>(); this.locale = (locale != null ? locale : Locale.getDefault()); } @@ -82,7 +82,7 @@ public class LinkedCaseInsensitiveMap extends LinkedHashMap { */ public LinkedCaseInsensitiveMap(int initialCapacity, Locale locale) { super(initialCapacity); - this.caseInsensitiveKeys = new HashMap(initialCapacity); + this.caseInsensitiveKeys = new HashMap<>(initialCapacity); this.locale = (locale != null ? locale : Locale.getDefault()); } diff --git a/spring-core/src/main/java/org/springframework/util/LinkedMultiValueMap.java b/spring-core/src/main/java/org/springframework/util/LinkedMultiValueMap.java index 747f78c71f3..6148e84cd47 100644 --- a/spring-core/src/main/java/org/springframework/util/LinkedMultiValueMap.java +++ b/spring-core/src/main/java/org/springframework/util/LinkedMultiValueMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa * Create a new LinkedMultiValueMap that wraps a {@link LinkedHashMap}. */ public LinkedMultiValueMap() { - this.targetMap = new LinkedHashMap>(); + this.targetMap = new LinkedHashMap<>(); } /** @@ -55,7 +55,7 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa * @param initialCapacity the initial capacity */ public LinkedMultiValueMap(int initialCapacity) { - this.targetMap = new LinkedHashMap>(initialCapacity); + this.targetMap = new LinkedHashMap<>(initialCapacity); } /** @@ -67,7 +67,7 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa * @see #deepCopy() */ public LinkedMultiValueMap(Map> otherMap) { - this.targetMap = new LinkedHashMap>(otherMap); + this.targetMap = new LinkedHashMap<>(otherMap); } @@ -77,7 +77,7 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa public void add(K key, V value) { List values = this.targetMap.get(key); if (values == null) { - values = new LinkedList(); + values = new LinkedList<>(); this.targetMap.put(key, values); } values.add(value); @@ -91,7 +91,7 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa @Override public void set(K key, V value) { - List values = new LinkedList(); + List values = new LinkedList<>(); values.add(value); this.targetMap.put(key, values); } @@ -105,7 +105,7 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa @Override public Map toSingleValueMap() { - LinkedHashMap singleValueMap = new LinkedHashMap(this.targetMap.size()); + LinkedHashMap singleValueMap = new LinkedHashMap<>(this.targetMap.size()); for (Entry> entry : this.targetMap.entrySet()) { singleValueMap.put(entry.getKey(), entry.getValue().get(0)); } @@ -185,7 +185,7 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa */ @Override public LinkedMultiValueMap clone() { - return new LinkedMultiValueMap(this); + return new LinkedMultiValueMap<>(this); } /** @@ -195,9 +195,9 @@ public class LinkedMultiValueMap implements MultiValueMap, Serializa * @see #clone() */ public LinkedMultiValueMap deepCopy() { - LinkedMultiValueMap copy = new LinkedMultiValueMap(this.targetMap.size()); + LinkedMultiValueMap copy = new LinkedMultiValueMap<>(this.targetMap.size()); for (Map.Entry> entry : this.targetMap.entrySet()) { - copy.put(entry.getKey(), new LinkedList(entry.getValue())); + copy.put(entry.getKey(), new LinkedList<>(entry.getValue())); } return copy; } diff --git a/spring-core/src/main/java/org/springframework/util/MimeType.java b/spring-core/src/main/java/org/springframework/util/MimeType.java index 164c3b10d13..d3eeae3486f 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeType.java +++ b/spring-core/src/main/java/org/springframework/util/MimeType.java @@ -172,7 +172,7 @@ public class MimeType implements Comparable, Serializable { this.type = type.toLowerCase(Locale.ENGLISH); this.subtype = subtype.toLowerCase(Locale.ENGLISH); if (!CollectionUtils.isEmpty(parameters)) { - Map map = new LinkedCaseInsensitiveMap(parameters.size(), Locale.ENGLISH); + Map map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH); for (Map.Entry entry : parameters.entrySet()) { String attribute = entry.getKey(); String value = entry.getValue(); @@ -482,9 +482,9 @@ public class MimeType implements Comparable, Serializable { if (comp != 0) { return comp; } - TreeSet thisAttributes = new TreeSet(String.CASE_INSENSITIVE_ORDER); + TreeSet thisAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); thisAttributes.addAll(getParameters().keySet()); - TreeSet otherAttributes = new TreeSet(String.CASE_INSENSITIVE_ORDER); + TreeSet otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); otherAttributes.addAll(other.getParameters().keySet()); Iterator thisAttributesIterator = thisAttributes.iterator(); Iterator otherAttributesIterator = otherAttributes.iterator(); @@ -520,7 +520,7 @@ public class MimeType implements Comparable, Serializable { } private static Map addCharsetParameter(Charset charset, Map parameters) { - Map map = new LinkedHashMap(parameters); + Map map = new LinkedHashMap<>(parameters); map.put(PARAM_CHARSET, charset.name()); return map; } diff --git a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java index a0ad5cc0953..522cfbd41b1 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java +++ b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java @@ -244,7 +244,7 @@ public abstract class MimeTypeUtils { Map parameters = null; if (parts.length > 1) { - parameters = new LinkedHashMap(parts.length - 1); + parameters = new LinkedHashMap<>(parts.length - 1); for (int i = 1; i < parts.length; i++) { String parameter = parts[i]; int eqIndex = parameter.indexOf('='); @@ -278,7 +278,7 @@ public abstract class MimeTypeUtils { return Collections.emptyList(); } String[] tokens = mimeTypes.split(",\\s*"); - List result = new ArrayList(tokens.length); + List result = new ArrayList<>(tokens.length); for (String token : tokens) { result.add(parseMimeType(token)); } @@ -358,6 +358,6 @@ public abstract class MimeTypeUtils { /** * Comparator used by {@link #sortBySpecificity(List)}. */ - public static final Comparator SPECIFICITY_COMPARATOR = new SpecificityComparator(); + public static final Comparator SPECIFICITY_COMPARATOR = new SpecificityComparator<>(); } diff --git a/spring-core/src/main/java/org/springframework/util/NumberUtils.java b/spring-core/src/main/java/org/springframework/util/NumberUtils.java index 46b3f868b75..9faa5d72a2b 100644 --- a/spring-core/src/main/java/org/springframework/util/NumberUtils.java +++ b/spring-core/src/main/java/org/springframework/util/NumberUtils.java @@ -47,7 +47,7 @@ public abstract class NumberUtils { public static final Set> STANDARD_NUMBER_TYPES; static { - Set> numberTypes = new HashSet>(8); + Set> numberTypes = new HashSet<>(8); numberTypes.add(Byte.class); numberTypes.add(Short.class); numberTypes.add(Integer.class); diff --git a/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java b/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java index b5c749fbba4..206b147c78d 100644 --- a/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java +++ b/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class PropertyPlaceholderHelper { private static final Log logger = LogFactory.getLog(PropertyPlaceholderHelper.class); - private static final Map wellKnownSimplePrefixes = new HashMap(4); + private static final Map wellKnownSimplePrefixes = new HashMap<>(4); static { wellKnownSimplePrefixes.put("}", "{"); @@ -123,7 +123,7 @@ public class PropertyPlaceholderHelper { */ public String replacePlaceholders(String value, PlaceholderResolver placeholderResolver) { Assert.notNull(value, "'value' must not be null"); - return parseStringValue(value, placeholderResolver, new HashSet()); + return parseStringValue(value, placeholderResolver, new HashSet<>()); } protected String parseStringValue( diff --git a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java index 301ad5a71a6..fd2df57be1b 100644 --- a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java @@ -61,13 +61,13 @@ public abstract class ReflectionUtils { * from Java 8 based interfaces, allowing for fast iteration. */ private static final Map, Method[]> declaredMethodsCache = - new ConcurrentReferenceHashMap, Method[]>(256); + new ConcurrentReferenceHashMap<>(256); /** * Cache for {@link Class#getDeclaredFields()}, allowing for fast iteration. */ private static final Map, Field[]> declaredFieldsCache = - new ConcurrentReferenceHashMap, Field[]>(256); + new ConcurrentReferenceHashMap<>(256); /** @@ -549,7 +549,7 @@ public abstract class ReflectionUtils { * @param leafClass the class to introspect */ public static Method[] getAllDeclaredMethods(Class leafClass) { - final List methods = new ArrayList(32); + final List methods = new ArrayList<>(32); doWithMethods(leafClass, new MethodCallback() { @Override public void doWith(Method method) { @@ -566,7 +566,7 @@ public abstract class ReflectionUtils { * @param leafClass the class to introspect */ public static Method[] getUniqueDeclaredMethods(Class leafClass) { - final List methods = new ArrayList(32); + final List methods = new ArrayList<>(32); doWithMethods(leafClass, new MethodCallback() { @Override public void doWith(Method method) { @@ -634,7 +634,7 @@ public abstract class ReflectionUtils { for (Method ifcMethod : ifc.getMethods()) { if (!Modifier.isAbstract(ifcMethod.getModifiers())) { if (result == null) { - result = new LinkedList(); + result = new LinkedList<>(); } result.add(ifcMethod); } diff --git a/spring-core/src/main/java/org/springframework/util/SocketUtils.java b/spring-core/src/main/java/org/springframework/util/SocketUtils.java index 091a3febbc1..e0a0a4c8f4f 100644 --- a/spring-core/src/main/java/org/springframework/util/SocketUtils.java +++ b/spring-core/src/main/java/org/springframework/util/SocketUtils.java @@ -287,7 +287,7 @@ public class SocketUtils { Assert.isTrue((maxPort - minPort) >= numRequested, "'numRequested' must not be greater than 'maxPort' - 'minPort'"); - SortedSet availablePorts = new TreeSet(); + SortedSet availablePorts = new TreeSet<>(); int attemptCount = 0; while ((++attemptCount <= numRequested + 100) && availablePorts.size() < numRequested) { availablePorts.add(findAvailablePort(minPort, maxPort)); diff --git a/spring-core/src/main/java/org/springframework/util/StopWatch.java b/spring-core/src/main/java/org/springframework/util/StopWatch.java index 1ba39880035..77d6b621ef5 100644 --- a/spring-core/src/main/java/org/springframework/util/StopWatch.java +++ b/spring-core/src/main/java/org/springframework/util/StopWatch.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class StopWatch { private boolean keepTaskList = true; - private final List taskList = new LinkedList(); + private final List taskList = new LinkedList<>(); /** Start time of the current task */ private long startTimeMillis; diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 6d470ae88e8..8fd7b8b1780 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -640,7 +640,7 @@ public abstract class StringUtils { } String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR); - List pathElements = new LinkedList(); + List pathElements = new LinkedList<>(); int tops = 0; for (int i = pathArray.length - 1; i >= 0; i--) { @@ -808,7 +808,7 @@ public abstract class StringUtils { if (ObjectUtils.isEmpty(array2)) { return array1; } - List result = new ArrayList(); + List result = new ArrayList<>(); result.addAll(Arrays.asList(array1)); for (String str : array2) { if (!result.contains(str)) { @@ -888,7 +888,7 @@ public abstract class StringUtils { if (ObjectUtils.isEmpty(array)) { return array; } - Set set = new LinkedHashSet(); + Set set = new LinkedHashSet<>(); for (String element : array) { set.add(element); } @@ -1013,7 +1013,7 @@ public abstract class StringUtils { return null; } StringTokenizer st = new StringTokenizer(str, delimiters); - List tokens = new ArrayList(); + List tokens = new ArrayList<>(); while (st.hasMoreTokens()) { String token = st.nextToken(); if (trimTokens) { @@ -1065,7 +1065,7 @@ public abstract class StringUtils { if (delimiter == null) { return new String[] {str}; } - List result = new ArrayList(); + List result = new ArrayList<>(); if ("".equals(delimiter)) { for (int i = 0; i < str.length(); i++) { result.add(deleteAny(str.substring(i, i + 1), charsToDelete)); @@ -1105,7 +1105,7 @@ public abstract class StringUtils { * @see #removeDuplicateStrings(String[]) */ public static Set commaDelimitedListToSet(String str) { - Set set = new LinkedHashSet(); + Set set = new LinkedHashSet<>(); String[] tokens = commaDelimitedListToStringArray(str); for (String token : tokens) { set.add(token); diff --git a/spring-core/src/main/java/org/springframework/util/WeakReferenceMonitor.java b/spring-core/src/main/java/org/springframework/util/WeakReferenceMonitor.java index 1a486757264..7d9b698c9a2 100644 --- a/spring-core/src/main/java/org/springframework/util/WeakReferenceMonitor.java +++ b/spring-core/src/main/java/org/springframework/util/WeakReferenceMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,10 +50,10 @@ public class WeakReferenceMonitor { private static final Log logger = LogFactory.getLog(WeakReferenceMonitor.class); // Queue receiving reachability events - private static final ReferenceQueue handleQueue = new ReferenceQueue(); + private static final ReferenceQueue handleQueue = new ReferenceQueue<>(); // All tracked entries (WeakReference => ReleaseListener) - private static final Map, ReleaseListener> trackedEntries = new HashMap, ReleaseListener>(); + private static final Map, ReleaseListener> trackedEntries = new HashMap<>(); // Thread polling handleQueue, lazy initialized private static Thread monitoringThread = null; @@ -72,7 +72,7 @@ public class WeakReferenceMonitor { // Make weak reference to this handle, so we can say when // handle is not used any more by polling on handleQueue. - WeakReference weakRef = new WeakReference(handle, handleQueue); + WeakReference weakRef = new WeakReference<>(handle, handleQueue); // Add monitored entry to internal map of all monitored entries. addEntry(weakRef, listener); diff --git a/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java b/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java index c04735c81d1..cf784ebda30 100644 --- a/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java +++ b/spring-core/src/main/java/org/springframework/util/comparator/CompoundComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class CompoundComparator implements Comparator, Serializable { * IllegalStateException is thrown. */ public CompoundComparator() { - this.comparators = new ArrayList(); + this.comparators = new ArrayList<>(); } /** @@ -62,7 +62,7 @@ public class CompoundComparator implements Comparator, Serializable { @SuppressWarnings("unchecked") public CompoundComparator(Comparator... comparators) { Assert.notNull(comparators, "Comparators must not be null"); - this.comparators = new ArrayList(comparators.length); + this.comparators = new ArrayList<>(comparators.length); for (Comparator comparator : comparators) { this.addComparator(comparator); } @@ -121,7 +121,7 @@ public class CompoundComparator implements Comparator, Serializable { * @param ascending the sort order: ascending (true) or descending (false) */ public void setComparator(int index, Comparator comparator, boolean ascending) { - this.comparators.set(index, new InvertibleComparator(comparator, ascending)); + this.comparators.set(index, new InvertibleComparator<>(comparator, ascending)); } /** diff --git a/spring-core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java b/spring-core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java index f18b374d58f..3732a28f04f 100644 --- a/spring-core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java +++ b/spring-core/src/main/java/org/springframework/util/comparator/NullSafeComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,14 +36,14 @@ public class NullSafeComparator implements Comparator { * than non-null objects. */ @SuppressWarnings("rawtypes") - public static final NullSafeComparator NULLS_LOW = new NullSafeComparator(true); + public static final NullSafeComparator NULLS_LOW = new NullSafeComparator<>(true); /** * A shared default instance of this comparator, treating nulls higher * than non-null objects. */ @SuppressWarnings("rawtypes") - public static final NullSafeComparator NULLS_HIGH = new NullSafeComparator(false); + public static final NullSafeComparator NULLS_HIGH = new NullSafeComparator<>(false); private final Comparator nonNullComparator; diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java b/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java index 18707cf43b8..a0de053e1ba 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/CompletableToListenableFutureAdapter.java @@ -32,7 +32,7 @@ public class CompletableToListenableFutureAdapter implements ListenableFuture private final CompletableFuture completableFuture; - private final ListenableFutureCallbackRegistry callbacks = new ListenableFutureCallbackRegistry(); + private final ListenableFutureCallbackRegistry callbacks = new ListenableFutureCallbackRegistry<>(); public CompletableToListenableFutureAdapter(CompletableFuture completableFuture) { diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java index 46eb746bbc4..7d099cda60a 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java @@ -34,9 +34,9 @@ import org.springframework.util.Assert; */ public class ListenableFutureCallbackRegistry { - private final Queue> successCallbacks = new LinkedList>(); + private final Queue> successCallbacks = new LinkedList<>(); - private final Queue failureCallbacks = new LinkedList(); + private final Queue failureCallbacks = new LinkedList<>(); private State state = State.NEW; diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureTask.java b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureTask.java index 393a6e64c73..2bb8faa31bf 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureTask.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import java.util.concurrent.FutureTask; */ public class ListenableFutureTask extends FutureTask implements ListenableFuture { - private final ListenableFutureCallbackRegistry callbacks = new ListenableFutureCallbackRegistry(); + private final ListenableFutureCallbackRegistry callbacks = new ListenableFutureCallbackRegistry<>(); /** diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java b/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java index 3a61db2b5be..76c1f5fb011 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java @@ -44,8 +44,8 @@ public class SettableListenableFuture implements ListenableFuture { public SettableListenableFuture() { - this.settableTask = new SettableTask(); - this.listenableFuture = new ListenableFutureTask(this.settableTask); + this.settableTask = new SettableTask<>(); + this.listenableFuture = new ListenableFutureTask<>(this.settableTask); } @@ -152,7 +152,7 @@ public class SettableListenableFuture implements ListenableFuture { private static final Object NO_VALUE = new Object(); - private final AtomicReference value = new AtomicReference(NO_VALUE); + private final AtomicReference value = new AtomicReference<>(NO_VALUE); private volatile boolean cancelled = false; diff --git a/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxHandler.java b/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxHandler.java index afbdf9a03b7..dfc7cee9709 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxHandler.java +++ b/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import org.xml.sax.ext.LexicalHandler; */ abstract class AbstractStaxHandler implements ContentHandler, LexicalHandler { - private final List> namespaceMappings = new ArrayList>(); + private final List> namespaceMappings = new ArrayList<>(); private boolean inCData; @@ -233,7 +233,7 @@ abstract class AbstractStaxHandler implements ContentHandler, LexicalHandler { } private void newNamespaceMapping() { - this.namespaceMappings.add(new HashMap()); + this.namespaceMappings.add(new HashMap<>()); } private void removeNamespaceMapping() { diff --git a/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java b/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java index 77c74d26f68..123def48263 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java +++ b/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java @@ -57,7 +57,7 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader { private Boolean isStandalone; - private final Map namespaces = new LinkedHashMap(); + private final Map namespaces = new LinkedHashMap<>(); @Override diff --git a/spring-core/src/main/java/org/springframework/util/xml/DomContentHandler.java b/spring-core/src/main/java/org/springframework/util/xml/DomContentHandler.java index 5a8d92aa850..1383a97dfbe 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/DomContentHandler.java +++ b/spring-core/src/main/java/org/springframework/util/xml/DomContentHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ class DomContentHandler implements ContentHandler { private final Document document; - private final List elements = new ArrayList(); + private final List elements = new ArrayList<>(); private final Node node; diff --git a/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java b/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java index 61c6271dc3e..6d2988fd738 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java +++ b/spring-core/src/main/java/org/springframework/util/xml/DomUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public abstract class DomUtils { Assert.notNull(childEleNames, "Element names collection must not be null"); List childEleNameList = Arrays.asList(childEleNames); NodeList nl = ele.getChildNodes(); - List childEles = new ArrayList(); + List childEles = new ArrayList<>(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameMatch(node, childEleNameList)) { @@ -123,7 +123,7 @@ public abstract class DomUtils { public static List getChildElements(Element ele) { Assert.notNull(ele, "Element must not be null"); NodeList nl = ele.getChildNodes(); - List childEles = new ArrayList(); + List childEles = new ArrayList<>(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element) { diff --git a/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java b/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java index 05f3de13942..5f61b36f241 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java +++ b/spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,9 +38,9 @@ import org.springframework.util.Assert; */ public class SimpleNamespaceContext implements NamespaceContext { - private final Map prefixToNamespaceUri = new HashMap(); + private final Map prefixToNamespaceUri = new HashMap<>(); - private final Map> namespaceUriToPrefixes = new HashMap>(); + private final Map> namespaceUriToPrefixes = new HashMap<>(); private String defaultNamespaceUri = ""; @@ -125,7 +125,7 @@ public class SimpleNamespaceContext implements NamespaceContext { this.prefixToNamespaceUri.put(prefix, namespaceUri); Set prefixes = this.namespaceUriToPrefixes.get(namespaceUri); if (prefixes == null) { - prefixes = new LinkedHashSet(); + prefixes = new LinkedHashSet<>(); this.namespaceUriToPrefixes.put(namespaceUri, prefixes); } prefixes.add(prefix); diff --git a/spring-core/src/main/java/org/springframework/util/xml/StaxEventHandler.java b/spring-core/src/main/java/org/springframework/util/xml/StaxEventHandler.java index 7a4151dc3eb..28457cd073b 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/StaxEventHandler.java +++ b/spring-core/src/main/java/org/springframework/util/xml/StaxEventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ class StaxEventHandler extends AbstractStaxHandler { } private List getNamespaces(Map namespaceMapping) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (Map.Entry entry : namespaceMapping.entrySet()) { String prefix = entry.getKey(); String namespaceUri = entry.getValue(); @@ -106,7 +106,7 @@ class StaxEventHandler extends AbstractStaxHandler { } private List getAttributes(Attributes attributes) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (int i = 0; i < attributes.getLength(); i++) { QName attrName = toQName(attributes.getURI(i), attributes.getQName(i)); if (!isNamespaceDeclaration(attrName)) { diff --git a/spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamWriter.java b/spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamWriter.java index f910377d271..09b1d607282 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamWriter.java +++ b/spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ class XMLEventStreamWriter implements XMLStreamWriter { private final XMLEventFactory eventFactory; - private final List endElements = new ArrayList(); + private final List endElements = new ArrayList<>(); private boolean emptyElement = false; @@ -201,7 +201,7 @@ class XMLEventStreamWriter implements XMLStreamWriter { int last = this.endElements.size() - 1; EndElement oldEndElement = this.endElements.get(last); Iterator oldNamespaces = oldEndElement.getNamespaces(); - List newNamespaces = new ArrayList(); + List newNamespaces = new ArrayList<>(); while (oldNamespaces.hasNext()) { Namespace oldNamespace = (Namespace) oldNamespaces.next(); newNamespaces.add(oldNamespace); diff --git a/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java b/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java index fb93162fa96..6e004999dba 100644 --- a/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java +++ b/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,7 +170,7 @@ public class CollectionFactoryTests { @Test public void createApproximateCollectionFromNonEmptyHashSet() { - HashSet hashSet = new HashSet(); + HashSet hashSet = new HashSet<>(); hashSet.add("foo"); Collection set = createApproximateCollection(hashSet, 2); assertThat(set.size(), is(0)); @@ -196,7 +196,7 @@ public class CollectionFactoryTests { @Test public void createApproximateMapFromNonEmptyHashMap() { - Map hashMap = new HashMap(); + Map hashMap = new HashMap<>(); hashMap.put("foo", "bar"); Map map = createApproximateMap(hashMap, 2); assertThat(map.size(), is(0)); @@ -210,7 +210,7 @@ public class CollectionFactoryTests { @Test public void createApproximateMapFromNonEmptyEnumMap() { - EnumMap enumMap = new EnumMap(Color.class); + EnumMap enumMap = new EnumMap<>(Color.class); enumMap.put(Color.BLUE, "blue"); Map colors = createApproximateMap(enumMap, 2); assertThat(colors.size(), is(0)); diff --git a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java index 7e7c3d5bece..78e5eb84875 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class GenericTypeResolverTests { @Test public void nullIfNotResolvable() { - GenericClass obj = new GenericClass(); + GenericClass obj = new GenericClass<>(); assertNull(resolveTypeArgument(obj.getClass(), GenericClass.class)); } @@ -82,13 +82,13 @@ public class GenericTypeResolverTests { Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class); MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0); assertEquals(MyInterfaceType.class, - resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap())); + resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<>())); Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage", MyInterfaceType[].class); MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0); assertEquals(MyInterfaceType[].class, - resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap())); + resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<>())); Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage", Object[].class); diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index 5c90f5cba91..f84d523e361 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -149,7 +149,7 @@ public class ResolvableTypeTests { @Test public void forInstanceProvider() { - ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType(String.class)); + ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<>(String.class)); assertThat(type.getRawClass(), equalTo(MyGenericInterfaceType.class)); assertThat(type.getGeneric().resolve(), equalTo(String.class)); } @@ -401,7 +401,7 @@ public class ResolvableTypeTests { public void getInterfaces() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.getInterfaces().length, equalTo(0)); - SortedSet interfaces = new TreeSet(); + SortedSet interfaces = new TreeSet<>(); for (ResolvableType interfaceType : type.getSuperType().getInterfaces()) { interfaces.add(interfaceType.toString()); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MapAnnotationAttributeExtractorTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MapAnnotationAttributeExtractorTests.java index d3b456023b4..bc133f98769 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MapAnnotationAttributeExtractorTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MapAnnotationAttributeExtractorTests.java @@ -51,7 +51,7 @@ public class MapAnnotationAttributeExtractorTests extends AbstractAliasAwareAnno @Test public void enrichAndValidateAttributesWithImplicitAliasesAndMinimalAttributes() { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); Map expectedAttributes = new HashMap() {{ put("groovyScript", ""); put("xmlFile", ""); @@ -127,7 +127,7 @@ public class MapAnnotationAttributeExtractorTests extends AbstractAliasAwareAnno // Declare aliases in an order that will cause enrichAndValidateAttributes() to // fail unless it considers all aliases in the set of implicit aliases. - MultiValueMap aliases = new LinkedMultiValueMap(); + MultiValueMap aliases = new LinkedMultiValueMap<>(); aliases.put("xmlFile", Arrays.asList("value", "groovyScript", "location1", "location2", "location3")); aliases.put("groovyScript", Arrays.asList("value", "xmlFile", "location1", "location2", "location3")); aliases.put("value", Arrays.asList("xmlFile", "groovyScript", "location1", "location2", "location3")); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java b/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java index 463e3b6ef7d..2ca2feafb8d 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class OrderSourceProviderTests { @Test public void plainComparator() { - List items = new ArrayList(); + List items = new ArrayList<>(); C c = new C(5); C c2 = new C(-5); items.add(c); diff --git a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java index 39184c2c778..abc1fff76e8 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -533,7 +533,7 @@ public class TypeDescriptorTests { public void elementTypePreserveContext() throws Exception { TypeDescriptor desc = new TypeDescriptor(getClass().getField("listPreserveContext")); assertEquals(Integer.class, desc.getElementTypeDescriptor().getElementTypeDescriptor().getType()); - List value = new ArrayList(3); + List value = new ArrayList<>(3); desc = desc.elementTypeDescriptor(value); assertEquals(Integer.class, desc.getElementTypeDescriptor().getType()); assertNotNull(desc.getAnnotation(FieldAnnotation.class)); @@ -551,7 +551,7 @@ public class TypeDescriptorTests { public void mapKeyTypePreserveContext() throws Exception { TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext")); assertEquals(Integer.class, desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType()); - List value = new ArrayList(3); + List value = new ArrayList<>(3); desc = desc.getMapKeyTypeDescriptor(value); assertEquals(Integer.class, desc.getElementTypeDescriptor().getType()); assertNotNull(desc.getAnnotation(FieldAnnotation.class)); @@ -569,7 +569,7 @@ public class TypeDescriptorTests { public void mapValueTypePreserveContext() throws Exception { TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext")); assertEquals(Integer.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType()); - List value = new ArrayList(3); + List value = new ArrayList<>(3); desc = desc.getMapValueTypeDescriptor(value); assertEquals(Integer.class, desc.getElementTypeDescriptor().getType()); assertNotNull(desc.getAnnotation(FieldAnnotation.class)); @@ -841,19 +841,19 @@ public class TypeDescriptorTests { public List listOfString; - public List> listOfListOfString = new ArrayList>(); + public List> listOfListOfString = new ArrayList<>(); - public List listOfListOfUnknown = new ArrayList(); + public List listOfListOfUnknown = new ArrayList<>(); public int[] intArray; public List[] arrayOfListOfString; - public List listField = new ArrayList(); + public List listField = new ArrayList<>(); - public Map mapField = new HashMap(); + public Map mapField = new HashMap<>(); - public Map> nestedMapField = new HashMap>(); + public Map> nestedMapField = new HashMap<>(); public Map, List> fieldMap; @@ -879,9 +879,9 @@ public class TypeDescriptorTests { public Map isAssignableMapKeyValueTypes; - public MultiValueMap multiValueMap = new LinkedMultiValueMap(); + public MultiValueMap multiValueMap = new LinkedMultiValueMap<>(); - public PassDownGeneric passDownGeneric = new PassDownGeneric(); + public PassDownGeneric passDownGeneric = new PassDownGeneric<>(); // Classes designed for test introspection diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java index 4cadfe7406f..30f58a8b34d 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class ConvertingComparatorTests { @Test(expected=IllegalArgumentException.class) public void shouldThrowOnNullComparator() throws Exception { - new ConvertingComparator(null, this.converter); + new ConvertingComparator<>(null, this.converter); } @Test(expected=IllegalArgumentException.class) @@ -68,21 +68,21 @@ public class ConvertingComparatorTests { @Test public void shouldUseConverterOnCompare() throws Exception { - ConvertingComparator convertingComparator = new ConvertingComparator( - this.comparator, this.converter); + ConvertingComparator convertingComparator = new ConvertingComparator<>( + this.comparator, this.converter); testConversion(convertingComparator); } @Test public void shouldUseConversionServiceOnCompare() throws Exception { - ConvertingComparator convertingComparator = new ConvertingComparator( - comparator, conversionService, Integer.class); + ConvertingComparator convertingComparator = new ConvertingComparator<>( + comparator, conversionService, Integer.class); testConversion(convertingComparator); } @Test public void shouldGetForConverter() throws Exception { - testConversion(new ConvertingComparator(comparator, converter)); + testConversion(new ConvertingComparator<>(comparator, converter)); } private void testConversion(ConvertingComparator convertingComparator) { @@ -109,11 +109,11 @@ public class ConvertingComparatorTests { } private ArrayList> createReverseOrderMapEntryList() { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); map.put("b", 2); map.put("a", 1); - ArrayList> list = new ArrayList>( - map.entrySet()); + ArrayList> list = new ArrayList<>( + map.entrySet()); assertThat(list.get(0).getKey(), is("b")); return list; } diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java index 86b5415875d..6a3ec5b780a 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class CollectionToCollectionConverterTests { @Test public void scalarList() throws Exception { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("9"); list.add("37"); TypeDescriptor sourceType = TypeDescriptor.forObject(list); @@ -85,7 +85,7 @@ public class CollectionToCollectionConverterTests { public void emptyListToList() throws Exception { conversionService.addConverter(new CollectionToCollectionConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); - List list = new ArrayList(); + List list = new ArrayList<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(list); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyListTarget")); assertTrue(conversionService.canConvert(sourceType, targetType)); @@ -96,7 +96,7 @@ public class CollectionToCollectionConverterTests { public void emptyListToListDifferentTargetType() throws Exception { conversionService.addConverter(new CollectionToCollectionConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); - List list = new ArrayList(); + List list = new ArrayList<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(list); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyListDifferentTarget")); assertTrue(conversionService.canConvert(sourceType, targetType)); @@ -108,7 +108,7 @@ public class CollectionToCollectionConverterTests { @Test public void collectionToObjectInteraction() throws Exception { - List> list = new ArrayList>(); + List> list = new ArrayList<>(); list.add(Arrays.asList("9", "12")); list.add(Arrays.asList("37", "23")); conversionService.addConverter(new CollectionToObjectConverter(conversionService)); @@ -131,7 +131,7 @@ public class CollectionToCollectionConverterTests { @Test @SuppressWarnings("unchecked") public void objectToCollection() throws Exception { - List> list = new ArrayList>(); + List> list = new ArrayList<>(); list.add(Arrays.asList("9", "12")); list.add(Arrays.asList("37", "23")); conversionService.addConverterFactory(new StringToNumberConverterFactory()); @@ -150,7 +150,7 @@ public class CollectionToCollectionConverterTests { @Test @SuppressWarnings("unchecked") public void stringToCollection() throws Exception { - List> list = new ArrayList>(); + List> list = new ArrayList<>(); list.add(Arrays.asList("9,12")); list.add(Arrays.asList("37,23")); conversionService.addConverterFactory(new StringToNumberConverterFactory()); @@ -169,14 +169,14 @@ public class CollectionToCollectionConverterTests { @Test public void convertEmptyVector_shouldReturnEmptyArrayList() { - Vector vector = new Vector(); + Vector vector = new Vector<>(); vector.add("Element"); testCollectionConversionToArrayList(vector); } @Test public void convertNonEmptyVector_shouldReturnNonEmptyArrayList() { - Vector vector = new Vector(); + Vector vector = new Vector<>(); vector.add("Element"); testCollectionConversionToArrayList(vector); } @@ -198,14 +198,14 @@ public class CollectionToCollectionConverterTests { @Test public void listToCollectionNoCopyRequired() throws NoSuchFieldException { - List input = new ArrayList(Arrays.asList("foo", "bar")); + List input = new ArrayList<>(Arrays.asList("foo", "bar")); assertSame(input, conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardCollection")))); } @Test public void differentImpls() throws Exception { - List resources = new ArrayList(); + List resources = new ArrayList<>(); resources.add(new ClassPathResource("test")); resources.add(new FileSystemResource("test")); resources.add(new TestResource()); @@ -215,7 +215,7 @@ public class CollectionToCollectionConverterTests { @Test public void mixedInNulls() throws Exception { - List resources = new ArrayList(); + List resources = new ArrayList<>(); resources.add(new ClassPathResource("test")); resources.add(null); resources.add(new FileSystemResource("test")); @@ -226,7 +226,7 @@ public class CollectionToCollectionConverterTests { @Test public void allNulls() throws Exception { - List resources = new ArrayList(); + List resources = new ArrayList<>(); resources.add(null); resources.add(null); TypeDescriptor sourceType = TypeDescriptor.forObject(resources); @@ -235,7 +235,7 @@ public class CollectionToCollectionConverterTests { @Test(expected = ConverterNotFoundException.class) public void elementTypesNotConvertible() throws Exception { - List resources = new ArrayList(); + List resources = new ArrayList<>(); resources.add(null); resources.add(null); TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("strings")); @@ -244,7 +244,7 @@ public class CollectionToCollectionConverterTests { @Test(expected = ConversionFailedException.class) public void nothingInCommon() throws Exception { - List resources = new ArrayList(); + List resources = new ArrayList<>(); resources.add(new ClassPathResource("test")); resources.add(3); TypeDescriptor sourceType = TypeDescriptor.forObject(resources); @@ -254,7 +254,7 @@ public class CollectionToCollectionConverterTests { @Test public void testStringToEnumSet() throws Exception { conversionService.addConverterFactory(new StringToEnumConverterFactory()); - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("A"); list.add("C"); assertEquals(EnumSet.of(MyEnum.A, MyEnum.C), diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionServiceTests.java index e7caf78bab8..9971d599922 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/DefaultConversionServiceTests.java @@ -477,7 +477,7 @@ public class DefaultConversionServiceTests { @Test public void convertCollectionToArray() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("1"); list.add("2"); list.add("3"); @@ -489,7 +489,7 @@ public class DefaultConversionServiceTests { @Test public void convertCollectionToArrayWithElementConversion() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("1"); list.add("2"); list.add("3"); @@ -558,7 +558,7 @@ public class DefaultConversionServiceTests { @Test public void convertCollectionToObjectAssignableTarget() throws Exception { - Collection source = new ArrayList(); + Collection source = new ArrayList<>(); source.add("foo"); Object result = conversionService.convert(source, new TypeDescriptor(getClass().getField("assignableTarget"))); assertEquals(source, result); @@ -567,7 +567,7 @@ public class DefaultConversionServiceTests { @Test @SuppressWarnings("rawtypes") public void convertCollectionToObjectWithCustomConverter() throws Exception { - List source = new ArrayList(); + List source = new ArrayList<>(); source.add("A"); source.add("B"); conversionService.addConverter(new Converter() { @@ -640,7 +640,7 @@ public class DefaultConversionServiceTests { @Test public void convertCollectionToCollection() throws Exception { - Set foo = new LinkedHashSet(); + Set foo = new LinkedHashSet<>(); foo.add("1"); foo.add("2"); foo.add("3"); @@ -663,7 +663,7 @@ public class DefaultConversionServiceTests { @Test @SuppressWarnings("rawtypes") public void convertCollectionToCollectionNotGeneric() throws Exception { - Set foo = new LinkedHashSet(); + Set foo = new LinkedHashSet<>(); foo.add("1"); foo.add("2"); foo.add("3"); @@ -692,7 +692,7 @@ public class DefaultConversionServiceTests { @Test public void collection() { - List strings = new ArrayList(); + List strings = new ArrayList<>(); strings.add("3"); strings.add("9"); @SuppressWarnings("unchecked") @@ -704,7 +704,7 @@ public class DefaultConversionServiceTests { @Test public void convertMapToMap() throws Exception { - Map foo = new HashMap(); + Map foo = new HashMap<>(); foo.put("1", "BAR"); foo.put("2", "BAZ"); @SuppressWarnings("unchecked") @@ -717,7 +717,7 @@ public class DefaultConversionServiceTests { @Test @SuppressWarnings("rawtypes") public void convertHashMapValuesToList() { - Map hashMap = new LinkedHashMap(); + Map hashMap = new LinkedHashMap<>(); hashMap.put("1", 1); hashMap.put("2", 2); List converted = conversionService.convert(hashMap.values(), List.class); @@ -726,7 +726,7 @@ public class DefaultConversionServiceTests { @Test public void map() { - Map strings = new HashMap(); + Map strings = new HashMap<>(); strings.put("3", "9"); strings.put("6", "31"); @SuppressWarnings("unchecked") @@ -941,11 +941,11 @@ public class DefaultConversionServiceTests { // test fields and helpers - public List genericList = new ArrayList(); + public List genericList = new ArrayList<>(); public Stream genericStream; - public Map genericMap = new HashMap(); + public Map genericMap = new HashMap<>(); public EnumSet enumSet; diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index 4b3183b65b8..259709ddd77 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -229,7 +229,7 @@ public class GenericConversionServiceTests { @Test public void testListToIterableConversion() { - List raw = new ArrayList(); + List raw = new ArrayList<>(); raw.add("one"); raw.add("two"); Object converted = conversionService.convert(raw, Iterable.class); @@ -238,7 +238,7 @@ public class GenericConversionServiceTests { @Test public void testListToObjectConversion() { - List raw = new ArrayList(); + List raw = new ArrayList<>(); raw.add("one"); raw.add("two"); Object converted = conversionService.convert(raw, Object.class); @@ -247,7 +247,7 @@ public class GenericConversionServiceTests { @Test public void testMapToObjectConversion() { - Map raw = new HashMap(); + Map raw = new HashMap<>(); raw.put("key", "value"); Object converted = conversionService.convert(raw, Object.class); assertSame(raw, converted); @@ -301,7 +301,7 @@ public class GenericConversionServiceTests { @Test public void testWildcardMap() throws Exception { - Map input = new LinkedHashMap(); + Map input = new LinkedHashMap<>(); input.put("key", "value"); Object converted = conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardMap"))); assertEquals(input, converted); @@ -333,7 +333,7 @@ public class GenericConversionServiceTests { Assume.group(TestGroup.PERFORMANCE); StopWatch watch = new StopWatch("list -> list conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); - List source = new LinkedList(); + List source = new LinkedList<>(); source.add("1"); source.add("2"); source.add("3"); @@ -344,7 +344,7 @@ public class GenericConversionServiceTests { watch.stop(); watch.start("convert 4,000,000 manually"); for (int i = 0; i < 4000000; i++) { - List target = new ArrayList(source.size()); + List target = new ArrayList<>(source.size()); for (String element : source) { target.add(Integer.valueOf(element)); } @@ -358,7 +358,7 @@ public class GenericConversionServiceTests { Assume.group(TestGroup.PERFORMANCE); StopWatch watch = new StopWatch("map -> map conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); - Map source = new HashMap(); + Map source = new HashMap<>(); source.put("1", "1"); source.put("2", "2"); source.put("3", "3"); @@ -369,7 +369,7 @@ public class GenericConversionServiceTests { watch.stop(); watch.start("convert 4,000,000 manually"); for (int i = 0; i < 4000000; i++) { - Map target = new HashMap(source.size()); + Map target = new HashMap<>(source.size()); for (Map.Entry entry : source.entrySet()) { target.put(entry.getKey(), Integer.valueOf(entry.getValue())); } @@ -382,7 +382,7 @@ public class GenericConversionServiceTests { public void emptyListToArray() { conversionService.addConverter(new CollectionToArrayConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); - List list = new ArrayList(); + List list = new ArrayList<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(list); TypeDescriptor targetType = TypeDescriptor.valueOf(String[].class); assertTrue(conversionService.canConvert(sourceType, targetType)); @@ -393,7 +393,7 @@ public class GenericConversionServiceTests { public void emptyListToObject() { conversionService.addConverter(new CollectionToObjectConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); - List list = new ArrayList(); + List list = new ArrayList<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(list); TypeDescriptor targetType = TypeDescriptor.valueOf(Integer.class); assertTrue(conversionService.canConvert(sourceType, targetType)); @@ -420,7 +420,7 @@ public class GenericConversionServiceTests { @Test public void testConvertiblePairsInSet() { - Set set = new HashSet(); + Set set = new HashSet<>(); set.add(new GenericConverter.ConvertiblePair(Number.class, String.class)); assert set.contains(new GenericConverter.ConvertiblePair(Number.class, String.class)); } @@ -771,7 +771,7 @@ public class GenericConversionServiceTests { private static class MyConditionalGenericConverter implements GenericConverter, ConditionalConverter { - private final List sourceTypes = new ArrayList(); + private final List sourceTypes = new ArrayList<>(); @Override public Set getConvertibleTypes() { diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java index 3757f5543a9..385a658caaa 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class MapToMapConverterTests { @Test public void scalarMap() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("1", "9"); map.put("2", "37"); TypeDescriptor sourceType = TypeDescriptor.forObject(map); @@ -79,7 +79,7 @@ public class MapToMapConverterTests { @Test public void scalarMapNotGenericTarget() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("1", "9"); map.put("2", "37"); @@ -89,7 +89,7 @@ public class MapToMapConverterTests { @Test public void scalarMapNotGenericSourceField() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("1", "9"); map.put("2", "37"); TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("notGenericMapSource")); @@ -114,7 +114,7 @@ public class MapToMapConverterTests { @Test public void collectionMap() throws Exception { - Map> map = new HashMap>(); + Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); TypeDescriptor sourceType = TypeDescriptor.forObject(map); @@ -140,7 +140,7 @@ public class MapToMapConverterTests { @Test public void collectionMapSourceTarget() throws Exception { - Map> map = new HashMap>(); + Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("sourceCollectionMapTarget")); @@ -167,7 +167,7 @@ public class MapToMapConverterTests { @Test public void collectionMapNotGenericTarget() throws Exception { - Map> map = new HashMap>(); + Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); @@ -177,7 +177,7 @@ public class MapToMapConverterTests { @Test public void collectionMapNotGenericTargetCollectionToObjectInteraction() throws Exception { - Map> map = new HashMap>(); + Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); conversionService.addConverter(new CollectionToCollectionConverter(conversionService)); @@ -189,7 +189,7 @@ public class MapToMapConverterTests { @Test public void emptyMap() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(map); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapTarget")); @@ -199,7 +199,7 @@ public class MapToMapConverterTests { @Test public void emptyMapNoTargetGenericInfo() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); assertTrue(conversionService.canConvert(Map.class, Map.class)); assertSame(map, conversionService.convert(map, Map.class)); @@ -207,7 +207,7 @@ public class MapToMapConverterTests { @Test public void emptyMapDifferentTargetImplType() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(map); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapDifferentTarget")); @@ -221,8 +221,8 @@ public class MapToMapConverterTests { @Test public void noDefaultConstructorCopyNotRequired() throws Exception { // SPR-9284 - NoDefaultConstructorMap map = new NoDefaultConstructorMap( - Collections. singletonMap("1", 1)); + NoDefaultConstructorMap map = new NoDefaultConstructorMap<>( + Collections.singletonMap("1", 1)); TypeDescriptor sourceType = TypeDescriptor.map(NoDefaultConstructorMap.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)); TypeDescriptor targetType = TypeDescriptor.map(NoDefaultConstructorMap.class, @@ -239,7 +239,7 @@ public class MapToMapConverterTests { @SuppressWarnings("unchecked") public void multiValueMapToMultiValueMap() throws Exception { DefaultConversionService.addDefaultConverters(conversionService); - MultiValueMap source = new LinkedMultiValueMap(); + MultiValueMap source = new LinkedMultiValueMap<>(); source.put("a", Arrays.asList(1, 2, 3)); source.put("b", Arrays.asList(4, 5, 6)); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("multiValueMapTarget")); @@ -254,7 +254,7 @@ public class MapToMapConverterTests { @SuppressWarnings("unchecked") public void mapToMultiValueMap() throws Exception { DefaultConversionService.addDefaultConverters(conversionService); - Map source = new HashMap(); + Map source = new HashMap<>(); source.put("a", 1); source.put("b", 2); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("multiValueMapTarget")); @@ -268,10 +268,10 @@ public class MapToMapConverterTests { @Test public void testStringToEnumMap() throws Exception { conversionService.addConverterFactory(new StringToEnumConverterFactory()); - Map source = new HashMap(); + Map source = new HashMap<>(); source.put("A", 1); source.put("C", 2); - EnumMap result = new EnumMap(MyEnum.class); + EnumMap result = new EnumMap<>(MyEnum.class); result.put(MyEnum.A, 1); result.put(MyEnum.C, 2); diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java index 9b31d5661a8..8eaff31d3a6 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public class PropertySourceTests { PropertySource ps1 = new MapPropertySource("ps1", map1); ps1.getSource(); - List> propertySources = new ArrayList>(); + List> propertySources = new ArrayList<>(); assertThat(propertySources.add(ps1), equalTo(true)); assertThat(propertySources.contains(ps1), is(true)); assertThat(propertySources.contains(PropertySource.named("ps1")), is(true)); diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java index 931f03cf931..d2ffe16da13 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java @@ -87,7 +87,7 @@ public class PropertySourcesPropertyResolverTests { @Test public void getProperty_withExplicitNullValue() { // java.util.Properties does not allow null values (because Hashtable does not) - Map nullableProperties = new HashMap(); + Map nullableProperties = new HashMap<>(); propertySources.addLast(new MapPropertySource("nullableProperties", nullableProperties)); nullableProperties.put("foo", null); assertThat(propertyResolver.getProperty("foo"), nullValue()); @@ -127,7 +127,7 @@ public class PropertySourcesPropertyResolverTests { String value1 = "bar"; String value2 = "biz"; - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); map.put(key, value1); // before construction MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MapPropertySource("testProperties", map)); @@ -139,7 +139,7 @@ public class PropertySourcesPropertyResolverTests { @Test public void getProperty_doesNotCache_addNewKeyPostConstruction() { - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MapPropertySource("testProperties", map)); PropertyResolver propertyResolver = new PropertySourcesPropertyResolver(propertySources); diff --git a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java index 935862b0508..68497bee277 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class SystemEnvironmentPropertySourceTests { @Before public void setUp() { - envMap = new HashMap(); + envMap = new HashMap<>(); ps = new SystemEnvironmentPropertySource("sysEnv", envMap); } @@ -158,7 +158,7 @@ public class SystemEnvironmentPropertySourceTests { } @Override public Set keySet() { - return new HashSet(super.keySet()); + return new HashSet<>(super.keySet()); } }; envMap.put("A_KEY", "a_value"); diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java index ad73395acba..42a8c075a2a 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ public class ResourceTests { assertEquals(resource, resource3); // Check whether equal/hashCode works in a HashSet. - HashSet resources = new HashSet(); + HashSet resources = new HashSet<>(); resources.add(resource); resources.add(resource2); assertEquals(1, resources.size()); diff --git a/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java b/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java index b53cefa1d81..fac1de29850 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class PathMatchingResourcePatternResolverTests { Resource[] resources = resolver.getResources("classpath*:org/springframework/core/io/sup*/*.class"); // Have to exclude Clover-generated class files here, // as we might be running as part of a Clover test run. - List noCloverResources = new ArrayList(); + List noCloverResources = new ArrayList<>(); for (Resource resource : resources) { if (!resource.getFilename().contains("$__CLOVER_")) { noCloverResources.add(resource); diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 5e4083e0fff..191192bc478 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -292,9 +292,9 @@ public class AnnotationMetadataTests { MethodMetadata method = methods.iterator().next(); assertEquals("direct", method.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")); List allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value"); - assertThat(new HashSet(allMeta), is(equalTo(new HashSet(Arrays.asList("direct", "meta"))))); + assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet(Arrays.asList("direct", "meta"))))); allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional"); - assertThat(new HashSet(allMeta), is(equalTo(new HashSet(Arrays.asList("direct"))))); + assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet(Arrays.asList("direct"))))); assertTrue(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())); @@ -334,9 +334,9 @@ public class AnnotationMetadataTests { assertEquals("direct", metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value")); allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value"); - assertThat(new HashSet(allMeta), is(equalTo(new HashSet(Arrays.asList("direct", "meta"))))); + assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet(Arrays.asList("direct", "meta"))))); allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional"); - assertThat(new HashSet(allMeta), is(equalTo(new HashSet(Arrays.asList("direct"))))); + assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet(Arrays.asList("direct"))))); } { // perform tests with classValuesAsString = true AnnotationAttributes specialAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes( @@ -365,7 +365,7 @@ public class AnnotationMetadataTests { assertEquals(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("value"), "direct"); allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value"); - assertThat(new HashSet(allMeta), is(equalTo(new HashSet(Arrays.asList("direct", "meta"))))); + assertThat(new HashSet<>(allMeta), is(equalTo(new HashSet(Arrays.asList("direct", "meta"))))); } } diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroup.java b/spring-core/src/test/java/org/springframework/tests/TestGroup.java index f7b8525bc6c..d1302963954 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroup.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroup.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public enum TestGroup { return EnumSet.allOf(TestGroup.class); } if (value.toUpperCase().startsWith("ALL-")) { - Set groups = new HashSet(EnumSet.allOf(TestGroup.class)); + Set groups = new HashSet<>(EnumSet.allOf(TestGroup.class)); groups.removeAll(parseGroups(value.substring(4))); return groups; } @@ -89,7 +89,7 @@ public enum TestGroup { } private static Set parseGroups(String value) { - Set groups = new HashSet(); + Set groups = new HashSet<>(); for (String group : value.split(",")) { try { groups.add(valueOf(group.trim().toUpperCase())); diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java index f756bb3176d..8c7d4de47ec 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java +++ b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ public class TestGroupTests { @Test public void parseAllExcept() throws Exception { - Set expected = new HashSet(EnumSet.allOf(TestGroup.class)); + Set expected = new HashSet<>(EnumSet.allOf(TestGroup.class)); expected.remove(TestGroup.CUSTOM_COMPILATION); expected.remove(TestGroup.PERFORMANCE); assertThat(TestGroup.parse("all-custom_compilation,performance"), equalTo(expected)); diff --git a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java index d810c330143..306bbfc3376 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -331,7 +331,7 @@ public class AntPathMatcherTests { assertEquals(Collections.singletonMap("hotel", "1"), result); result = pathMatcher.extractUriTemplateVariables("/hotels/{hotel}/bookings/{booking}", "/hotels/1/bookings/2"); - Map expected = new LinkedHashMap(); + Map expected = new LinkedHashMap<>(); expected.put("hotel", "1"); expected.put("booking", "2"); assertEquals(expected, result); @@ -349,7 +349,7 @@ public class AntPathMatcherTests { assertEquals(Collections.singletonMap("B", "b"), result); result = pathMatcher.extractUriTemplateVariables("/{name}.{extension}", "/test.html"); - expected = new LinkedHashMap(); + expected = new LinkedHashMap<>(); expected.put("name", "test"); expected.put("extension", "html"); assertEquals(expected, result); @@ -499,7 +499,7 @@ public class AntPathMatcherTests { @Test public void patternComparatorSort() { Comparator comparator = pathMatcher.getPatternComparator("/hotels/new"); - List paths = new ArrayList(3); + List paths = new ArrayList<>(3); paths.add(null); paths.add("/hotels/new"); diff --git a/spring-core/src/test/java/org/springframework/util/AssertTests.java b/spring-core/src/test/java/org/springframework/util/AssertTests.java index b3c5d433359..f547e03a592 100644 --- a/spring-core/src/test/java/org/springframework/util/AssertTests.java +++ b/spring-core/src/test/java/org/springframework/util/AssertTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,12 +45,12 @@ public class AssertTests { @Test public void instanceOf() { - Assert.isInstanceOf(HashSet.class, new HashSet()); + Assert.isInstanceOf(HashSet.class, new HashSet<>()); } @Test(expected = IllegalArgumentException.class) public void instanceOfWithTypeMismatch() { - Assert.isInstanceOf(HashMap.class, new HashSet()); + Assert.isInstanceOf(HashMap.class, new HashSet<>()); } @Test @@ -136,12 +136,12 @@ public class AssertTests { @Test(expected = IllegalArgumentException.class) public void assertNotEmptyWithEmptyCollectionThrowsException() throws Exception { - Assert.notEmpty(new ArrayList()); + Assert.notEmpty(new ArrayList<>()); } @Test public void assertNotEmptyWithCollectionSunnyDay() throws Exception { - List collection = new ArrayList(); + List collection = new ArrayList<>(); collection.add(""); Assert.notEmpty(collection); } @@ -153,12 +153,12 @@ public class AssertTests { @Test(expected = IllegalArgumentException.class) public void assertNotEmptyWithEmptyMapThrowsException() throws Exception { - Assert.notEmpty(new HashMap()); + Assert.notEmpty(new HashMap<>()); } @Test public void assertNotEmptyWithMapSunnyDay() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("", ""); Assert.notEmpty(map); } diff --git a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java index 21ce95621fd..d1cea354338 100644 --- a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java +++ b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,22 +32,22 @@ public class AutoPopulatingListTests { @Test public void withClass() throws Exception { - doTestWithClass(new AutoPopulatingList(TestObject.class)); + doTestWithClass(new AutoPopulatingList<>(TestObject.class)); } @Test public void withClassAndUserSuppliedBackingList() throws Exception { - doTestWithClass(new AutoPopulatingList(new LinkedList(), TestObject.class)); + doTestWithClass(new AutoPopulatingList(new LinkedList<>(), TestObject.class)); } @Test public void withElementFactory() throws Exception { - doTestWithElementFactory(new AutoPopulatingList(new MockElementFactory())); + doTestWithElementFactory(new AutoPopulatingList<>(new MockElementFactory())); } @Test public void withElementFactoryAndUserSuppliedBackingList() throws Exception { - doTestWithElementFactory(new AutoPopulatingList(new LinkedList(), new MockElementFactory())); + doTestWithElementFactory(new AutoPopulatingList(new LinkedList<>(), new MockElementFactory())); } private void doTestWithClass(AutoPopulatingList list) { diff --git a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java index 1451c390f8e..dccbdefa0ee 100644 --- a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,13 +44,13 @@ public class CollectionUtilsTests { assertTrue(CollectionUtils.isEmpty((Set) null)); assertTrue(CollectionUtils.isEmpty((Map) null)); assertTrue(CollectionUtils.isEmpty(new HashMap())); - assertTrue(CollectionUtils.isEmpty(new HashSet())); + assertTrue(CollectionUtils.isEmpty(new HashSet<>())); - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new Object()); assertFalse(CollectionUtils.isEmpty(list)); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo", "bar"); assertFalse(CollectionUtils.isEmpty(map)); } @@ -58,7 +58,7 @@ public class CollectionUtilsTests { @Test public void testMergeArrayIntoCollection() { Object[] arr = new Object[] {"value1", "value2"}; - List> list = new LinkedList>(); + List> list = new LinkedList<>(); list.add("value3"); CollectionUtils.mergeArrayIntoCollection(arr, list); @@ -70,7 +70,7 @@ public class CollectionUtilsTests { @Test public void testMergePrimitiveArrayIntoCollection() { int[] arr = new int[] {1, 2}; - List> list = new LinkedList>(); + List> list = new LinkedList<>(); list.add(new Integer(3)); CollectionUtils.mergeArrayIntoCollection(arr, list); @@ -87,7 +87,7 @@ public class CollectionUtilsTests { props.setProperty("prop2", "value2"); props.put("prop3", new Integer(3)); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("prop4", "value4"); CollectionUtils.mergePropertiesIntoMap(props, map); @@ -104,23 +104,23 @@ public class CollectionUtilsTests { assertFalse(CollectionUtils.contains(new LinkedList().iterator(), "myElement")); assertFalse(CollectionUtils.contains(new Hashtable().keys(), "myElement")); - List list = new LinkedList(); + List list = new LinkedList<>(); list.add("myElement"); assertTrue(CollectionUtils.contains(list.iterator(), "myElement")); - Hashtable ht = new Hashtable(); + Hashtable ht = new Hashtable<>(); ht.put("myElement", "myValue"); assertTrue(CollectionUtils.contains(ht.keys(), "myElement")); } @Test public void testContainsAny() throws Exception { - List source = new ArrayList(); + List source = new ArrayList<>(); source.add("abc"); source.add("def"); source.add("ghi"); - List candidates = new ArrayList(); + List candidates = new ArrayList<>(); candidates.add("xyz"); candidates.add("def"); candidates.add("abc"); @@ -140,7 +140,7 @@ public class CollectionUtilsTests { @Test public void testContainsInstanceWithInstancesThatAreEqualButDistinct() throws Exception { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(new Instance("fiona")); assertFalse("Must return false if instance is not in the supplied Collection argument", CollectionUtils.containsInstance(list, new Instance("fiona"))); @@ -148,7 +148,7 @@ public class CollectionUtilsTests { @Test public void testContainsInstanceWithSameInstance() throws Exception { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(new Instance("apple")); Instance instance = new Instance("fiona"); list.add(instance); @@ -158,7 +158,7 @@ public class CollectionUtilsTests { @Test public void testContainsInstanceWithNullInstance() throws Exception { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(new Instance("apple")); list.add(new Instance("fiona")); assertFalse("Must return false if null instance is supplied", @@ -167,12 +167,12 @@ public class CollectionUtilsTests { @Test public void testFindFirstMatch() throws Exception { - List source = new ArrayList(); + List source = new ArrayList<>(); source.add("abc"); source.add("def"); source.add("ghi"); - List candidates = new ArrayList(); + List candidates = new ArrayList<>(); candidates.add("xyz"); candidates.add("def"); candidates.add("abc"); @@ -182,35 +182,35 @@ public class CollectionUtilsTests { @Test public void testHasUniqueObject() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add("myElement"); list.add("myOtherElement"); assertFalse(CollectionUtils.hasUniqueObject(list)); - list = new LinkedList(); + list = new LinkedList<>(); list.add("myElement"); assertTrue(CollectionUtils.hasUniqueObject(list)); - list = new LinkedList(); + list = new LinkedList<>(); list.add("myElement"); list.add(null); assertFalse(CollectionUtils.hasUniqueObject(list)); - list = new LinkedList(); + list = new LinkedList<>(); list.add(null); list.add("myElement"); assertFalse(CollectionUtils.hasUniqueObject(list)); - list = new LinkedList(); + list = new LinkedList<>(); list.add(null); list.add(null); assertTrue(CollectionUtils.hasUniqueObject(list)); - list = new LinkedList(); + list = new LinkedList<>(); list.add(null); assertTrue(CollectionUtils.hasUniqueObject(list)); - list = new LinkedList(); + list = new LinkedList<>(); assertFalse(CollectionUtils.hasUniqueObject(list)); } diff --git a/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java b/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java index 124bc04a3fd..4cc6c54f9fc 100644 --- a/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java +++ b/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public class CompositeIteratorTests { @Test public void testNoIterators() { - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator<>(); assertFalse(it.hasNext()); try { it.next(); @@ -49,7 +49,7 @@ public class CompositeIteratorTests { @Test public void testSingleIterator() { - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator<>(); it.add(Arrays.asList("0", "1").iterator()); for (int i = 0; i < 2; i++) { assertTrue(it.hasNext()); @@ -67,7 +67,7 @@ public class CompositeIteratorTests { @Test public void testMultipleIterators() { - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator<>(); it.add(Arrays.asList("0", "1").iterator()); it.add(Arrays.asList("2").iterator()); it.add(Arrays.asList("3", "4").iterator()); @@ -88,7 +88,7 @@ public class CompositeIteratorTests { @Test public void testInUse() { List list = Arrays.asList("0", "1"); - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator<>(); it.add(list.iterator()); it.hasNext(); try { @@ -98,7 +98,7 @@ public class CompositeIteratorTests { catch (IllegalStateException ex) { // expected } - it = new CompositeIterator(); + it = new CompositeIterator<>(); it.add(list.iterator()); it.next(); try { @@ -114,7 +114,7 @@ public class CompositeIteratorTests { public void testDuplicateIterators() { List list = Arrays.asList("0", "1"); Iterator iterator = list.iterator(); - CompositeIterator it = new CompositeIterator(); + CompositeIterator it = new CompositeIterator<>(); it.add(iterator); it.add(list.iterator()); try { diff --git a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java index d585d0aef10..74dc6f59a00 100644 --- a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,12 +56,12 @@ public class ConcurrentReferenceHashMapTests { @Rule public ExpectedException thrown = ExpectedException.none(); - private TestWeakConcurrentCache map = new TestWeakConcurrentCache(); + private TestWeakConcurrentCache map = new TestWeakConcurrentCache<>(); @Test public void shouldCreateWithDefaults() throws Exception { - ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap(); + ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(); assertThat(map.getSegmentsSize(), is(16)); assertThat(map.getSegment(0).getSize(), is(1)); assertThat(map.getLoadFactor(), is(0.75f)); @@ -69,7 +69,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldCreateWithInitialCapacity() throws Exception { - ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap(32); + ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(32); assertThat(map.getSegmentsSize(), is(16)); assertThat(map.getSegment(0).getSize(), is(2)); assertThat(map.getLoadFactor(), is(0.75f)); @@ -77,7 +77,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldCreateWithInitialCapacityAndLoadFactor() throws Exception { - ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap(32, 0.5f); + ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(32, 0.5f); assertThat(map.getSegmentsSize(), is(16)); assertThat(map.getSegment(0).getSize(), is(2)); assertThat(map.getLoadFactor(), is(0.5f)); @@ -85,7 +85,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldCreateWithInitialCapacityAndConcurrenyLevel() throws Exception { - ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap(16, 2); + ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(16, 2); assertThat(map.getSegmentsSize(), is(2)); assertThat(map.getSegment(0).getSize(), is(8)); assertThat(map.getLoadFactor(), is(0.75f)); @@ -93,7 +93,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldCreateFullyCustom() throws Exception { - ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap(5, 0.5f, 3); + ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(5, 0.5f, 3); // concurrencyLevel of 3 ends up as 4 (nearest power of 2) assertThat(map.getSegmentsSize(), is(4)); // initialCapacity is 5/4 (rounded up, to nearest power of 2) @@ -174,7 +174,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldGetFollowingNexts() throws Exception { // Use loadFactor to disable resize - this.map = new TestWeakConcurrentCache(1, 10.0f, 1); + this.map = new TestWeakConcurrentCache<>(1, 10.0f, 1); this.map.put(1, "1"); this.map.put(2, "2"); this.map.put(3, "3"); @@ -187,7 +187,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldResize() throws Exception { - this.map = new TestWeakConcurrentCache(1, 0.75f, 1); + this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1); this.map.put(1, "1"); assertThat(this.map.getSegment(0).getSize(), is(1)); assertThat(this.map.get(1), is("1")); @@ -217,7 +217,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldPurgeOnGet() throws Exception { - this.map = new TestWeakConcurrentCache(1, 0.75f, 1); + this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1); for (int i = 1; i <= 5; i++) { this.map.put(i, String.valueOf(i)); } @@ -232,7 +232,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldPergeOnPut() throws Exception { - this.map = new TestWeakConcurrentCache(1, 0.75f, 1); + this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1); for (int i = 1; i <= 5; i++) { this.map.put(i, String.valueOf(i)); } @@ -377,7 +377,7 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldPutAll() throws Exception { - Map m = new HashMap(); + Map m = new HashMap<>(); m.put(123, "123"); m.put(456, null); m.put(null, "789"); @@ -405,7 +405,7 @@ public class ConcurrentReferenceHashMapTests { this.map.put(123, "123"); this.map.put(456, null); this.map.put(null, "789"); - Set expected = new HashSet(); + Set expected = new HashSet<>(); expected.add(123); expected.add(456); expected.add(null); @@ -417,8 +417,8 @@ public class ConcurrentReferenceHashMapTests { this.map.put(123, "123"); this.map.put(456, null); this.map.put(null, "789"); - List actual = new ArrayList(this.map.values()); - List expected = new ArrayList(); + List actual = new ArrayList<>(this.map.values()); + List expected = new ArrayList<>(); expected.add("123"); expected.add(null); expected.add("789"); @@ -432,7 +432,7 @@ public class ConcurrentReferenceHashMapTests { this.map.put(123, "123"); this.map.put(456, null); this.map.put(null, "789"); - HashMap expected = new HashMap(); + HashMap expected = new HashMap<>(); expected.put(123, "123"); expected.put(456, null); expected.put(null, "789"); @@ -442,11 +442,11 @@ public class ConcurrentReferenceHashMapTests { @Test public void shouldGetEntrySetFollowingNext() throws Exception { // Use loadFactor to disable resize - this.map = new TestWeakConcurrentCache(1, 10.0f, 1); + this.map = new TestWeakConcurrentCache<>(1, 10.0f, 1); this.map.put(1, "1"); this.map.put(2, "2"); this.map.put(3, "3"); - HashMap expected = new HashMap(); + HashMap expected = new HashMap<>(); expected.put(1, "1"); expected.put(2, "2"); expected.put(3, "3"); @@ -491,7 +491,7 @@ public class ConcurrentReferenceHashMapTests { @Override public WeakReference newValue(int v) { - return new WeakReference(String.valueOf(v)); + return new WeakReference<>(String.valueOf(v)); } }); System.out.println(mapTime.prettyPrint()); @@ -567,7 +567,7 @@ public class ConcurrentReferenceHashMapTests { private int supplimentalHash; - private final LinkedList> queue = new LinkedList>(); + private final LinkedList> queue = new LinkedList<>(); private boolean disableTestHooks; @@ -610,7 +610,7 @@ public class ConcurrentReferenceHashMapTests { if (TestWeakConcurrentCache.this.disableTestHooks) { return super.createReference(entry, hash, next); } - return new MockReference(entry, hash, next, TestWeakConcurrentCache.this.queue); + return new MockReference<>(entry, hash, next, TestWeakConcurrentCache.this.queue); } @Override public Reference pollForPurge() { diff --git a/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java b/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java index 12a6ce00e35..615e51de15a 100644 --- a/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java +++ b/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,14 +28,14 @@ public class InstanceFilterTests { @Test public void emptyFilterApplyMatchIfEmpty() { - InstanceFilter filter = new InstanceFilter(null, null, true); + InstanceFilter filter = new InstanceFilter<>(null, null, true); match(filter, "foo"); match(filter, "bar"); } @Test public void includesFilter() { - InstanceFilter filter = new InstanceFilter( + InstanceFilter filter = new InstanceFilter<>( asList("First", "Second"), null, true); match(filter, "Second"); doNotMatch(filter, "foo"); @@ -43,7 +43,7 @@ public class InstanceFilterTests { @Test public void excludesFilter() { - InstanceFilter filter = new InstanceFilter( + InstanceFilter filter = new InstanceFilter<>( null, asList("First", "Second"), true); doNotMatch(filter, "Second"); match(filter, "foo"); @@ -51,7 +51,7 @@ public class InstanceFilterTests { @Test public void includesAndExcludesFilters() { - InstanceFilter filter = new InstanceFilter( + InstanceFilter filter = new InstanceFilter<>( asList("foo", "Bar"), asList("First", "Second"), true); doNotMatch(filter, "Second"); match(filter, "foo"); @@ -59,7 +59,7 @@ public class InstanceFilterTests { @Test public void includesAndExcludesFiltersConflict() { - InstanceFilter filter = new InstanceFilter( + InstanceFilter filter = new InstanceFilter<>( asList("First"), asList("First"), true); doNotMatch(filter, "First"); } diff --git a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java index 4f4492ef5ae..dd2dc28e7da 100644 --- a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java @@ -25,7 +25,7 @@ import static org.junit.Assert.*; */ public class LinkedCaseInsensitiveMapTests { - private final LinkedCaseInsensitiveMap map = new LinkedCaseInsensitiveMap(); + private final LinkedCaseInsensitiveMap map = new LinkedCaseInsensitiveMap<>(); @Test diff --git a/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java b/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java index 00eb3db8521..8758a38c2c4 100644 --- a/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public class LinkedMultiValueMapTests { @Before public void setUp() { - map = new LinkedMultiValueMap(); + map = new LinkedMultiValueMap<>(); } @Test @@ -44,7 +44,7 @@ public class LinkedMultiValueMapTests { map.add("key", "value1"); map.add("key", "value2"); assertEquals(1, map.size()); - List expected = new ArrayList(2); + List expected = new ArrayList<>(2); expected.add("value1"); expected.add("value2"); assertEquals(expected, map.get("key")); @@ -52,7 +52,7 @@ public class LinkedMultiValueMapTests { @Test public void getFirst() { - List values = new ArrayList(2); + List values = new ArrayList<>(2); values.add("value1"); values.add("value2"); map.put("key", values); @@ -72,11 +72,11 @@ public class LinkedMultiValueMapTests { public void equals() { map.set("key1", "value1"); assertEquals(map, map); - MultiValueMap o1 = new LinkedMultiValueMap(); + MultiValueMap o1 = new LinkedMultiValueMap<>(); o1.set("key1", "value1"); assertEquals(map, o1); assertEquals(o1, map); - Map> o2 = new HashMap>(); + Map> o2 = new HashMap<>(); o2.put("key1", Collections.singletonList("value1")); assertEquals(map, o2); assertEquals(o2, map); diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index 07bc3a0d57f..71570eea61c 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,7 +110,7 @@ public class ObjectUtilsTests { assertTrue(isEmpty(Collections.emptyList())); assertTrue(isEmpty(Collections.emptySet())); - Set set = new HashSet(); + Set set = new HashSet<>(); set.add("foo"); assertFalse(isEmpty(set)); assertFalse(isEmpty(Arrays.asList("foo"))); @@ -120,7 +120,7 @@ public class ObjectUtilsTests { public void isEmptyMap() { assertTrue(isEmpty(Collections.emptyMap())); - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); map.put("foo", 42L); assertFalse(isEmpty(map)); } diff --git a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java index 3c0c8f84b81..af5efcbe10d 100644 --- a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -362,9 +362,9 @@ public class ReflectionUtilsTests { private static class ListSavingMethodCallback implements ReflectionUtils.MethodCallback { - private List methodNames = new LinkedList(); + private List methodNames = new LinkedList<>(); - private List methods = new LinkedList(); + private List methods = new LinkedList<>(); @Override public void doWith(Method m) throws IllegalArgumentException, IllegalAccessException { diff --git a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java index 2545d9b14c7..4c39291c642 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class ComparableComparatorTests { @Test public void testComparableComparator() { - Comparator c = new ComparableComparator(); + Comparator c = new ComparableComparator<>(); String s1 = "abc"; String s2 = "cde"; assertTrue(c.compare(s1, s2) < 0); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java index 10d5ca33c78..d8808c5d8fd 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public class CompoundComparatorTests { @Test public void shouldNeedAtLeastOneComparator() { - Comparator c = new CompoundComparator(); + Comparator c = new CompoundComparator<>(); thrown.expect(IllegalStateException.class); c.compare("foo", "bar"); } diff --git a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java index 24794f00b86..eb0d9035fcc 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class InstanceComparatorTests { @Test public void shouldCompareClasses() throws Exception { - Comparator comparator = new InstanceComparator(C1.class, C2.class); + Comparator comparator = new InstanceComparator<>(C1.class, C2.class); assertThat(comparator.compare(c1, c1), is(0)); assertThat(comparator.compare(c1, c2), is(-1)); assertThat(comparator.compare(c2, c1), is(1)); @@ -51,7 +51,7 @@ public class InstanceComparatorTests { @Test public void shouldCompareInterfaces() throws Exception { - Comparator comparator = new InstanceComparator(I1.class, I2.class); + Comparator comparator = new InstanceComparator<>(I1.class, I2.class); assertThat(comparator.compare(c1, c1), is(0)); assertThat(comparator.compare(c1, c2), is(0)); assertThat(comparator.compare(c2, c1), is(0)); @@ -62,7 +62,7 @@ public class InstanceComparatorTests { @Test public void shouldCompareMix() throws Exception { - Comparator comparator = new InstanceComparator(I1.class, C3.class); + Comparator comparator = new InstanceComparator<>(I1.class, C3.class); assertThat(comparator.compare(c1, c1), is(0)); assertThat(comparator.compare(c3, c4), is(-1)); assertThat(comparator.compare(c3, null), is(-1)); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java index c8afa7a690a..b53d7c5c4c3 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,22 +33,22 @@ import static org.junit.Assert.*; public class InvertibleComparatorTests { - private Comparator comparator = new ComparableComparator(); + private Comparator comparator = new ComparableComparator<>(); @Test(expected=IllegalArgumentException.class) public void shouldNeedComparator() throws Exception { - new InvertibleComparator(null); + new InvertibleComparator<>(null); } @Test(expected=IllegalArgumentException.class) public void shouldNeedComparatorWithAscending() throws Exception { - new InvertibleComparator(null, true); + new InvertibleComparator<>(null, true); } @Test public void shouldDefaultToAscending() throws Exception { InvertibleComparator invertibleComparator = - new InvertibleComparator(comparator); + new InvertibleComparator<>(comparator); assertThat(invertibleComparator.isAscending(), is(true)); assertThat(invertibleComparator.compare(1, 2), is(-1)); } @@ -56,7 +56,7 @@ public class InvertibleComparatorTests { @Test public void shouldInvert() throws Exception { InvertibleComparator invertibleComparator = - new InvertibleComparator(comparator); + new InvertibleComparator<>(comparator); assertThat(invertibleComparator.isAscending(), is(true)); assertThat(invertibleComparator.compare(1, 2), is(-1)); invertibleComparator.invertOrder(); @@ -67,14 +67,14 @@ public class InvertibleComparatorTests { @Test public void shouldCompareAscending() throws Exception { InvertibleComparator invertibleComparator = - new InvertibleComparator(comparator, true); + new InvertibleComparator<>(comparator, true); assertThat(invertibleComparator.compare(1, 2), is(-1)); } @Test public void shouldCompareDescending() throws Exception { InvertibleComparator invertibleComparator = - new InvertibleComparator(comparator, false); + new InvertibleComparator<>(comparator, false); assertThat(invertibleComparator.compare(1, 2), is(1)); } diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java index b868039a391..915cd841dc3 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class ListenableFutureTaskTests { return s; } }; - ListenableFutureTask task = new ListenableFutureTask(callable); + ListenableFutureTask task = new ListenableFutureTask<>(callable); task.addCallback(new ListenableFutureCallback() { @Override public void onSuccess(String result) { @@ -63,7 +63,7 @@ public class ListenableFutureTaskTests { throw new IOException(s); } }; - ListenableFutureTask task = new ListenableFutureTask(callable); + ListenableFutureTask task = new ListenableFutureTask<>(callable); task.addCallback(new ListenableFutureCallback() { @Override public void onSuccess(String result) { diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java index c8037cac862..c738ec3c76d 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java @@ -34,7 +34,7 @@ import static org.mockito.Mockito.*; @SuppressWarnings({ "rawtypes", "unchecked" }) public class SettableListenableFutureTests { - private final SettableListenableFuture settableListenableFuture = new SettableListenableFuture(); + private final SettableListenableFuture settableListenableFuture = new SettableListenableFuture<>(); @Test diff --git a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java index 4d191f676a9..2fe5773db64 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -179,7 +179,7 @@ public class SimpleNamespaceContextTests { private Set getItemSet(Iterator iterator) { - Set itemSet = new HashSet(); + Set itemSet = new HashSet<>(); while (iterator.hasNext()) { itemSet.add(iterator.next()); } @@ -187,7 +187,7 @@ public class SimpleNamespaceContextTests { } private Set makeSet(String... items) { - Set itemSet = new HashSet(); + Set itemSet = new HashSet<>(); for (String item : items) { itemSet.add(item); } diff --git a/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java b/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java index 1bfd482dd4c..f00055b6bf7 100644 --- a/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java +++ b/spring-expression/src/main/java/org/springframework/expression/common/TemplateAwareExpressionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser */ private Expression[] parseExpressions(String expressionString, ParserContext context) throws ParseException { - List expressions = new LinkedList(); + List expressions = new LinkedList<>(); String prefix = context.getExpressionPrefix(); String suffix = context.getExpressionSuffix(); int startIdx = 0; @@ -210,7 +210,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser if (nextSuffix == -1) { return -1; // the suffix is missing } - Stack stack = new Stack(); + Stack stack = new Stack<>(); while (pos < maxlen) { if (isSuffixHere(expressionString, pos, suffix) && stack.isEmpty()) { break; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java index 2d20e195d15..c503ea94a41 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,8 @@ public class CodeFlow implements Opcodes { private int nextFreeVariableId = 1; public CodeFlow(String clazzName, ClassWriter cw) { - this.compilationScopes = new Stack>(); - this.compilationScopes.add(new ArrayList()); + this.compilationScopes = new Stack<>(); + this.compilationScopes.add(new ArrayList<>()); this.cw = cw; this.clazzName = clazzName; } @@ -114,7 +114,7 @@ public class CodeFlow implements Opcodes { * each argument will be evaluated in a new scope. */ public void enterCompilationScope() { - this.compilationScopes.push(new ArrayList()); + this.compilationScopes.push(new ArrayList<>()); } /** @@ -809,7 +809,7 @@ public class CodeFlow implements Opcodes { */ public void registerNewField(FieldAdder fieldAdder) { if (fieldAdders == null) { - fieldAdders = new ArrayList(); + fieldAdders = new ArrayList<>(); } fieldAdders.add(fieldAdder); } @@ -821,7 +821,7 @@ public class CodeFlow implements Opcodes { */ public void registerNewClinit(ClinitAdder clinitAdder) { if (clinitAdders == null) { - clinitAdders = new ArrayList(); + clinitAdders = new ArrayList<>(); } clinitAdders.add(clinitAdder); } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java b/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java index 0b1ee9964b5..611e848b2d5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,12 +92,12 @@ public class ExpressionState { private void ensureVariableScopesInitialized() { if (this.variableScopes == null) { - this.variableScopes = new Stack(); + this.variableScopes = new Stack<>(); // top level empty variable scope this.variableScopes.add(new VariableScope()); } if (this.scopeRootObjects == null) { - this.scopeRootObjects = new Stack(); + this.scopeRootObjects = new Stack<>(); } } @@ -113,14 +113,14 @@ public class ExpressionState { public void pushActiveContextObject(TypedValue obj) { if (this.contextObjects == null) { - this.contextObjects = new Stack(); + this.contextObjects = new Stack<>(); } this.contextObjects.push(obj); } public void popActiveContextObject() { if (this.contextObjects == null) { - this.contextObjects = new Stack(); + this.contextObjects = new Stack<>(); } this.contextObjects.pop(); } @@ -250,7 +250,7 @@ public class ExpressionState { */ private static class VariableScope { - private final Map vars = new HashMap(); + private final Map vars = new HashMap<>(); public VariableScope() { } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java index 9762bddbfbc..d816f73656c 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,8 @@ public abstract class AstUtils { public static List getPropertyAccessorsToTry( Class targetType, List propertyAccessors) { - List specificAccessors = new ArrayList(); - List generalAccessors = new ArrayList(); + List specificAccessors = new ArrayList<>(); + List generalAccessors = new ArrayList<>(); for (PropertyAccessor resolver : propertyAccessors) { Class[] targets = resolver.getSpecificTargetClasses(); if (targets == null) { // generic resolver that says it can be used for any type @@ -67,7 +67,7 @@ public abstract class AstUtils { } } } - List resolvers = new LinkedList(); + List resolvers = new LinkedList<>(); resolvers.addAll(specificAccessors); resolvers.addAll(generalAccessors); return resolvers; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java index 526dc267122..70cf696b89f 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -107,7 +107,7 @@ public class ConstructorReference extends SpelNodeImpl { */ private TypedValue createNewInstance(ExpressionState state) throws EvaluationException { Object[] arguments = new Object[getChildCount() - 1]; - List argumentTypes = new ArrayList(getChildCount() - 1); + List argumentTypes = new ArrayList<>(getChildCount() - 1); for (int i = 0; i < arguments.length; i++) { TypedValue childValue = this.children[i + 1].getValueInternal(state); Object value = childValue.getValue(); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java index b4134b6351e..f2392e2b584 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineList.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class InlineList extends SpelNodeImpl { } } if (isConstant) { - List constantList = new ArrayList(); + List constantList = new ArrayList<>(); int childcount = getChildCount(); for (int c = 0; c < childcount; c++) { SpelNode child = getChild(c); @@ -89,7 +89,7 @@ public class InlineList extends SpelNodeImpl { return this.constant; } else { - List returnValue = new ArrayList(); + List returnValue = new ArrayList<>(); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { returnValue.add(getChild(c).getValue(expressionState)); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java index aa1233b5f66..202c97d8aa1 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/InlineMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public class InlineMap extends SpelNodeImpl { } } if (isConstant) { - Map constantMap = new LinkedHashMap(); + Map constantMap = new LinkedHashMap<>(); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { SpelNode keyChild = getChild(c++); @@ -111,7 +111,7 @@ public class InlineMap extends SpelNodeImpl { return this.constant; } else { - Map returnValue = new LinkedHashMap(); + Map returnValue = new LinkedHashMap<>(); int childcount = getChildCount(); for (int c = 0; c < childcount; c++) { // TODO allow for key being PropertyOrFieldReference like Indexer on maps diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java index 6ad79b25a1d..63831a5ab0e 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -161,7 +161,7 @@ public class MethodReference extends SpelNodeImpl { } private List getArgumentTypes(Object... arguments) { - List descriptors = new ArrayList(arguments.length); + List descriptors = new ArrayList<>(arguments.length); for (Object argument : arguments) { descriptors.add(TypeDescriptor.forObject(argument)); } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java index 60767cd5e2f..173cf429a1a 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorMatches.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ import org.springframework.expression.spel.support.BooleanTypedValue; */ public class OperatorMatches extends Operator { - private final ConcurrentMap patternCache = new ConcurrentHashMap(); + private final ConcurrentMap patternCache = new ConcurrentHashMap<>(); public OperatorMatches(int pos, SpelNodeImpl... operands) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Projection.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Projection.java index 1473f52e0e1..4bc5d903d40 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Projection.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Projection.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public class Projection extends SpelNodeImpl { // eg. {'a':'y','b':'n'}.![value=='y'?key:null]" == ['a', null] if (operand instanceof Map) { Map mapData = (Map) operand; - List result = new ArrayList(); + List result = new ArrayList<>(); for (Map.Entry entry : mapData.entrySet()) { try { state.pushActiveContextObject(new TypedValue(entry)); @@ -90,7 +90,7 @@ public class Projection extends SpelNodeImpl { Iterable data = (operand instanceof Iterable ? (Iterable) operand : Arrays.asList(ObjectUtils.toObjectArray(operand))); - List result = new ArrayList(); + List result = new ArrayList<>(); int idx = 0; Class arrayElementType = null; for (Object element : data) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java index 89b9081db7e..67e2fc8fa16 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -306,8 +306,8 @@ public class PropertyOrFieldReference extends SpelNodeImpl { private List getPropertyAccessorsToTry(Object contextObject, List propertyAccessors) { Class targetType = (contextObject != null ? contextObject.getClass() : null); - List specificAccessors = new ArrayList(); - List generalAccessors = new ArrayList(); + List specificAccessors = new ArrayList<>(); + List generalAccessors = new ArrayList<>(); for (PropertyAccessor resolver : propertyAccessors) { Class[] targets = resolver.getSpecificTargetClasses(); if (targets == null) { @@ -326,7 +326,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl { } } } - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); resolvers.addAll(specificAccessors); generalAccessors.removeAll(specificAccessors); resolvers.addAll(generalAccessors); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java index 232613398e1..a789f19d667 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,7 +80,7 @@ public class Selection extends SpelNodeImpl { if (operand instanceof Map) { Map mapdata = (Map) operand; // TODO don't lose generic info for the new map - Map result = new HashMap(); + Map result = new HashMap<>(); Object lastKey = null; for (Map.Entry entry : mapdata.entrySet()) { @@ -115,7 +115,7 @@ public class Selection extends SpelNodeImpl { } if (this.variant == LAST) { - Map resultMap = new HashMap(); + Map resultMap = new HashMap<>(); Object lastValue = result.get(lastKey); resultMap.put(lastKey,lastValue); return new ValueRef.TypedValueHolderValueRef(new TypedValue(resultMap),this); @@ -128,7 +128,7 @@ public class Selection extends SpelNodeImpl { Iterable data = (operand instanceof Iterable ? (Iterable) operand : Arrays.asList(ObjectUtils.toObjectArray(operand))); - List result = new ArrayList(); + List result = new ArrayList<>(); int index = 0; for (Object element : data) { try { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java index 600ffda6b51..1257501d6c8 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java @@ -90,7 +90,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { private final SpelParserConfiguration configuration; // For rules that build nodes, they are stacked here for return - private final Stack constructedNodes = new Stack(); + private final Stack constructedNodes = new Stack<>(); // The expression being parsed private String expressionString; @@ -339,7 +339,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { // primaryExpression : startNode (node)? -> ^(EXPRESSION startNode (node)?); private SpelNodeImpl eatPrimaryExpression() { - List nodes = new ArrayList(); + List nodes = new ArrayList<>(); SpelNodeImpl start = eatStartNode(); // always a start node nodes.add(start); while (maybeEatNode()) { @@ -439,7 +439,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { if (!peekToken(TokenKind.LPAREN)) { return null; } - List args = new ArrayList(); + List args = new ArrayList<>(); consumeArguments(args); eatToken(TokenKind.RPAREN); return args.toArray(new SpelNodeImpl[args.size()]); @@ -637,13 +637,13 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { // ':' - this is a map! if (peekToken(TokenKind.RCURLY)) { // list with one item in it - List listElements = new ArrayList(); + List listElements = new ArrayList<>(); listElements.add(firstExpression); closingCurly = eatToken(TokenKind.RCURLY); expr = new InlineList(toPos(t.startPos,closingCurly.endPos),listElements.toArray(new SpelNodeImpl[listElements.size()])); } else if (peekToken(TokenKind.COMMA, true)) { // multi item list - List listElements = new ArrayList(); + List listElements = new ArrayList<>(); listElements.add(firstExpression); do { listElements.add(eatExpression()); @@ -654,7 +654,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { } else if (peekToken(TokenKind.COLON, true)) { // map! - List mapElements = new ArrayList(); + List mapElements = new ArrayList<>(); mapElements.add(firstExpression); mapElements.add(eatExpression()); while (peekToken(TokenKind.COMMA,true)) { @@ -712,7 +712,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { * TODO AndyC Could create complete identifiers (a.b.c) here rather than a sequence of them? (a, b, c) */ private SpelNodeImpl eatPossiblyQualifiedId() { - LinkedList qualifiedIdPieces = new LinkedList(); + LinkedList qualifiedIdPieces = new LinkedList<>(); Token node = peekToken(); while (isValidQualifiedId(node)) { nextToken(); @@ -774,11 +774,11 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser { return true; } SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId(); - List nodes = new ArrayList(); + List nodes = new ArrayList<>(); nodes.add(possiblyQualifiedConstructorName); if (peekToken(TokenKind.LSQUARE)) { // array initializer - List dimensions = new ArrayList(); + List dimensions = new ArrayList<>(); while (peekToken(TokenKind.LSQUARE,true)) { if (!peekToken(TokenKind.RSQUARE)) { dimensions.add(eatExpression()); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java index faa14f3d42b..1af6019aac5 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public class SpelCompiler implements Opcodes { // A compiler is created for each classloader, it manages a child class loader of that // classloader and the child is used to load the compiled expressions. private static final Map compilers = - new ConcurrentReferenceHashMap(); + new ConcurrentReferenceHashMap<>(); // The child ClassLoader used to load the compiled expression classes diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java index e0408f10db3..ce227875ac9 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java @@ -73,7 +73,7 @@ class Tokenizer { int max; - List tokens = new ArrayList(); + List tokens = new ArrayList<>(); public Tokenizer(String inputData) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java index e9eacdf67f0..5a455a850a3 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public class ReflectiveConstructorResolver implements ConstructorResolver { for (Constructor ctor : ctors) { Class[] paramTypes = ctor.getParameterTypes(); - List paramDescriptors = new ArrayList(paramTypes.length); + List paramDescriptors = new ArrayList<>(paramTypes.length); for (int i = 0; i < paramTypes.length; i++) { paramDescriptors.add(new TypeDescriptor(new MethodParameter(ctor, i))); } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java index ffd64c70604..663a73c66e4 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public class ReflectiveMethodResolver implements MethodResolver { public void registerMethodFilter(Class type, MethodFilter filter) { if (this.filters == null) { - this.filters = new HashMap, MethodFilter>(); + this.filters = new HashMap<>(); } if (filter != null) { this.filters.put(type, filter); @@ -109,13 +109,13 @@ public class ReflectiveMethodResolver implements MethodResolver { try { TypeConverter typeConverter = context.getTypeConverter(); Class type = (targetObject instanceof Class ? (Class) targetObject : targetObject.getClass()); - List methods = new ArrayList(getMethods(type, targetObject)); + List methods = new ArrayList<>(getMethods(type, targetObject)); // If a filter is registered for this type, call it MethodFilter filter = (this.filters != null ? this.filters.get(type) : null); if (filter != null) { List filtered = filter.filter(methods); - methods = (filtered instanceof ArrayList ? filtered : new ArrayList(filtered)); + methods = (filtered instanceof ArrayList ? filtered : new ArrayList<>(filtered)); } // Sort methods into a sensible order @@ -148,7 +148,7 @@ public class ReflectiveMethodResolver implements MethodResolver { } // Remove duplicate methods (possible due to resolved bridge methods) - Set methodsToIterate = new LinkedHashSet(methods); + Set methodsToIterate = new LinkedHashSet<>(methods); Method closeMatch = null; int closeMatchDistance = Integer.MAX_VALUE; @@ -158,7 +158,7 @@ public class ReflectiveMethodResolver implements MethodResolver { for (Method method : methodsToIterate) { if (method.getName().equals(name)) { Class[] paramTypes = method.getParameterTypes(); - List paramDescriptors = new ArrayList(paramTypes.length); + List paramDescriptors = new ArrayList<>(paramTypes.length); for (int i = 0; i < paramTypes.length; i++) { paramDescriptors.add(new TypeDescriptor(new MethodParameter(method, i))); } @@ -220,7 +220,7 @@ public class ReflectiveMethodResolver implements MethodResolver { private Collection getMethods(Class type, Object targetObject) { if (targetObject instanceof Class) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); // Add these so that static methods are invocable on the type: e.g. Float.valueOf(..) Method[] methods = getMethods(type); for (Method method : methods) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java index 8cb54e8f0a8..e9842e6ab7f 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java @@ -62,7 +62,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { private static final Set> BOOLEAN_TYPES; static { - Set> booleanTypes = new HashSet>(); + Set> booleanTypes = new HashSet<>(); booleanTypes.add(Boolean.class); booleanTypes.add(Boolean.TYPE); BOOLEAN_TYPES = Collections.unmodifiableSet(booleanTypes); @@ -70,13 +70,13 @@ public class ReflectivePropertyAccessor implements PropertyAccessor { private final Map readerCache = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); private final Map writerCache = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); private final Map typeDescriptorCache = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); private InvokerPair lastReadInvokerPair; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardEvaluationContext.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardEvaluationContext.java index 5efc4456160..57edae520df 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardEvaluationContext.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardEvaluationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class StandardEvaluationContext implements EvaluationContext { private OperatorOverloader operatorOverloader = new StandardOperatorOverloader(); - private final Map variables = new HashMap(); + private final Map variables = new HashMap<>(); public StandardEvaluationContext() { @@ -252,7 +252,7 @@ public class StandardEvaluationContext implements EvaluationContext { private synchronized void initializePropertyAccessors() { if (this.propertyAccessors == null) { - List defaultAccessors = new ArrayList(); + List defaultAccessors = new ArrayList<>(); defaultAccessors.add(new ReflectivePropertyAccessor()); this.propertyAccessors = defaultAccessors; } @@ -266,7 +266,7 @@ public class StandardEvaluationContext implements EvaluationContext { private synchronized void initializeMethodResolvers() { if (this.methodResolvers == null) { - List defaultResolvers = new ArrayList(); + List defaultResolvers = new ArrayList<>(); this.reflectiveMethodResolver = new ReflectiveMethodResolver(); defaultResolvers.add(this.reflectiveMethodResolver); this.methodResolvers = defaultResolvers; @@ -281,7 +281,7 @@ public class StandardEvaluationContext implements EvaluationContext { private synchronized void initializeConstructorResolvers() { if (this.constructorResolvers == null) { - List defaultResolvers = new ArrayList(); + List defaultResolvers = new ArrayList<>(); defaultResolvers.add(new ReflectiveConstructorResolver()); this.constructorResolvers = defaultResolvers; } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java index 9c5b0af5b2b..fe8543b2458 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class StandardTypeLocator implements TypeLocator { private final ClassLoader classLoader; - private final List knownPackagePrefixes = new LinkedList(); + private final List knownPackagePrefixes = new LinkedList<>(); /** diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java index 2d027a4b60f..b0083e1c906 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -174,7 +174,7 @@ public class ConstructorInvocationTests extends AbstractExpressionTests { ctx.addConstructorResolver(dummy); assertEquals(2, ctx.getConstructorResolvers().size()); - List copy = new ArrayList(); + List copy = new ArrayList<>(); copy.addAll(ctx.getConstructorResolvers()); assertTrue(ctx.removeConstructorResolver(dummy)); assertFalse(ctx.removeConstructorResolver(dummy)); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java index fe583605411..78aa545bce0 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -625,7 +625,7 @@ public class EvaluationTests extends AbstractExpressionTests { StandardEvaluationContext context = new StandardEvaluationContext(); // Register a custom MethodResolver... - List customResolvers = new ArrayList(); + List customResolvers = new ArrayList<>(); customResolvers.add(new CustomMethodResolver()); context.setMethodResolvers(customResolvers); @@ -694,7 +694,7 @@ public class EvaluationTests extends AbstractExpressionTests { integerArray[2] = 3; integerArray[3] = 4; integerArray[4] = 5; - listOfStrings = new ArrayList(); + listOfStrings = new ArrayList<>(); listOfStrings.add("abc"); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java index 87530cd5bbd..72ffad73dae 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,7 +100,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests { // Use the standard evaluation context StandardEvaluationContext ctx = new StandardEvaluationContext(); ctx.setVariable("favouriteColour","blue"); - List primes = new ArrayList(); + List primes = new ArrayList<>(); primes.addAll(Arrays.asList(2,3,5,7,11,13,17)); ctx.setVariable("primes",primes); @@ -251,7 +251,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests { */ private static class FruitColourAccessor implements PropertyAccessor { - private static Map propertyMap = new HashMap(); + private static Map propertyMap = new HashMap<>(); static { propertyMap.put("banana",Color.yellow); @@ -296,7 +296,7 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests { */ private static class VegetableColourAccessor implements PropertyAccessor { - private static Map propertyMap = new HashMap(); + private static Map propertyMap = new HashMap<>(); static { propertyMap.put("carrot",Color.orange); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java index 8b2e6afa981..e616bb43d3b 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -197,7 +197,7 @@ public class ExpressionStateTests extends AbstractExpressionTests { assertNull(state.lookupLocalVariable("foo")); assertNull(state.lookupLocalVariable("goo")); - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("foo",34); m.put("goo","abc"); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java index c4b1df90bcf..4839fffb9f0 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,9 +44,9 @@ import static org.junit.Assert.*; */ public class ExpressionWithConversionTests extends AbstractExpressionTests { - private static List listOfString = new ArrayList(); + private static List listOfString = new ArrayList<>(); private static TypeDescriptor typeDescriptorForListOfString = null; - private static List listOfInteger = new ArrayList(); + private static List listOfInteger = new ArrayList<>(); private static TypeDescriptor typeDescriptorForListOfInteger = null; static { diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java index f8281212b80..961ca5aabca 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public class IndexingTests { @Test public void indexIntoGenericPropertyContainingMap() { - Map property = new HashMap(); + Map property = new HashMap<>(); property.put("foo", "bar"); this.property = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -61,8 +61,8 @@ public class IndexingTests { @Test public void indexIntoGenericPropertyContainingMapObject() { - Map> property = new HashMap>(); - Map map = new HashMap(); + Map> property = new HashMap<>(); + Map map = new HashMap<>(); map.put("foo", "bar"); property.put("property", map); SpelExpressionParser parser = new SpelExpressionParser(); @@ -110,7 +110,7 @@ public class IndexingTests { @Test public void setGenericPropertyContainingMap() { - Map property = new HashMap(); + Map property = new HashMap<>(); property.put("foo", "bar"); this.property = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -125,7 +125,7 @@ public class IndexingTests { @Test public void setPropertyContainingMap() { - Map property = new HashMap(); + Map property = new HashMap<>(); property.put(9, 3); this.parameterizedMap = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -154,7 +154,7 @@ public class IndexingTests { @Test public void indexIntoGenericPropertyContainingList() { - List property = new ArrayList(); + List property = new ArrayList<>(); property.add("bar"); this.property = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -167,7 +167,7 @@ public class IndexingTests { @Test public void setGenericPropertyContainingList() { - List property = new ArrayList(); + List property = new ArrayList<>(); property.add(3); this.property = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -182,7 +182,7 @@ public class IndexingTests { @Test public void setGenericPropertyContainingListAutogrow() { - List property = new ArrayList(); + List property = new ArrayList<>(); this.property = property; SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true)); Expression expression = parser.parseExpression("property"); @@ -199,7 +199,7 @@ public class IndexingTests { @Test public void indexIntoPropertyContainingList() { - List property = new ArrayList(); + List property = new ArrayList<>(); property.add(3); this.parameterizedList = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -214,7 +214,7 @@ public class IndexingTests { @Test public void indexIntoPropertyContainingListOfList() { - List> property = new ArrayList>(); + List> property = new ArrayList<>(); property.add(Arrays.asList(3)); this.parameterizedListOfList = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -229,7 +229,7 @@ public class IndexingTests { @Test public void setPropertyContainingList() { - List property = new ArrayList(); + List property = new ArrayList<>(); property.add(3); this.parameterizedList = property; SpelExpressionParser parser = new SpelExpressionParser(); @@ -260,7 +260,7 @@ public class IndexingTests { @Test public void indexIntoGenericPropertyContainingGrowingList() { - List property = new ArrayList(); + List property = new ArrayList<>(); this.property = property; SpelParserConfiguration configuration = new SpelParserConfiguration(true, true); SpelExpressionParser parser = new SpelExpressionParser(configuration); @@ -278,7 +278,7 @@ public class IndexingTests { @Test public void indexIntoGenericPropertyContainingGrowingList2() { - List property2 = new ArrayList(); + List property2 = new ArrayList<>(); this.property2 = property2; SpelParserConfiguration configuration = new SpelParserConfiguration(true, true); SpelExpressionParser parser = new SpelExpressionParser(configuration); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java index a0ed0f34d10..7d3ad4346ff 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class ListTests extends AbstractExpressionTests { // if the list is full of literals then it will be of the type unmodifiableClass // rather than ArrayList - Class unmodifiableClass = Collections.unmodifiableList(new ArrayList()).getClass(); + Class unmodifiableClass = Collections.unmodifiableList(new ArrayList<>()).getClass(); @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java index e492c16f8cb..12493f06c43 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ public class MapAccessTests extends AbstractExpressionTests { @Test public void testGetValue(){ - Map props1 = new HashMap(); + Map props1 = new HashMap<>(); props1.put("key1", "value1"); props1.put("key2", "value2"); props1.put("key3", "value3"); @@ -91,7 +91,7 @@ public class MapAccessTests extends AbstractExpressionTests { @Test public void testGetValueFromRootMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key", "value"); ExpressionParser spelExpressionParser = new SpelExpressionParser(); @@ -102,7 +102,7 @@ public class MapAccessTests extends AbstractExpressionTests { @Test public void testGetValuePerformance() throws Exception { Assume.group(TestGroup.PERFORMANCE); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key", "value"); EvaluationContext context = new StandardEvaluationContext(map); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java index 37d6d8237e4..fa0d73acba3 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class MapTests extends AbstractExpressionTests { // if the list is full of literals then it will be of the type unmodifiableClass // rather than HashMap (or similar) - Class unmodifiableClass = Collections.unmodifiableMap(new LinkedHashMap()).getClass(); + Class unmodifiableClass = Collections.unmodifiableMap(new LinkedHashMap<>()).getClass(); @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java index a09169f3e93..2b0f9c1e4f6 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -251,7 +251,7 @@ public class MethodInvocationTests extends AbstractExpressionTests { ctx.addMethodResolver(dummy); assertEquals(2, ctx.getMethodResolvers().size()); - List copy = new ArrayList(); + List copy = new ArrayList<>(); copy.addAll(ctx.getMethodResolvers()); assertTrue(ctx.removeMethodResolver(dummy)); assertFalse(ctx.removeMethodResolver(dummy)); @@ -341,7 +341,7 @@ public class MethodInvocationTests extends AbstractExpressionTests { @Override public List filter(List methods) { filterCalled = true; - List forRemoval = new ArrayList(); + List forRemoval = new ArrayList<>(); for (Method method: methods) { if (removeIfNotAnnotated && !isAnnotated(method)) { forRemoval.add(method); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java index 63919fce440..f585b8cb582 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -150,7 +150,7 @@ public class PropertyAccessTests extends AbstractExpressionTests { ctx.addPropertyAccessor(spa); assertEquals(2,ctx.getPropertyAccessors().size()); - List copy = new ArrayList(); + List copy = new ArrayList<>(); copy.addAll(ctx.getPropertyAccessors()); assertTrue(ctx.removePropertyAccessor(spa)); assertFalse(ctx.removePropertyAccessor(spa)); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java index 3c8ec310280..e102bed1053 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -292,7 +292,7 @@ public class SelectionAndProjectionTests { static class ListTestBean { - private final List integers = new ArrayList(); + private final List integers = new ArrayList<>(); ListTestBean() { for (int i = 0; i < 10; i++) { @@ -308,7 +308,7 @@ public class SelectionAndProjectionTests { static class SetTestBean { - private final Set integers = new LinkedHashSet(); + private final Set integers = new LinkedHashSet<>(); SetTestBean() { for (int i = 0; i < 10; i++) { @@ -324,7 +324,7 @@ public class SelectionAndProjectionTests { static class IterableTestBean { - private final Set integers = new LinkedHashSet(); + private final Set integers = new LinkedHashSet<>(); IterableTestBean() { for (int i = 0; i < 10; i++) { @@ -368,7 +368,7 @@ public class SelectionAndProjectionTests { static class MapTestBean { - private final Map colors = new TreeMap(); + private final Map colors = new TreeMap<>(); MapTestBean() { // colors.put("black", "schwarz"); @@ -398,7 +398,7 @@ public class SelectionAndProjectionTests { } static List createList() { - List list = new ArrayList(); + List list = new ArrayList<>(); for (int i = 0; i < 3; i++) { list.add(new IntegerTestBean(i + 5)); } @@ -406,7 +406,7 @@ public class SelectionAndProjectionTests { } static Set createSet() { - Set set = new LinkedHashSet(); + Set set = new LinkedHashSet<>(); for (int i = 0; i < 3; i++) { set.add(new IntegerTestBean(i + 5)); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java index cfde694a64f..f5a0c199440 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java @@ -198,7 +198,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertCanCompile(expression); assertEquals(false,expression.getValue()); - List list = new ArrayList(); + List list = new ArrayList<>(); expression = parse("#root instanceof T(java.util.List)"); assertEquals(true,expression.getValue(list)); assertCanCompile(expression); @@ -2923,11 +2923,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals(0,expression.getValue()); expression = parse("payload%2==0"); - assertTrue(expression.getValue(new GenericMessageTestHelper(4),Boolean.TYPE)); - assertFalse(expression.getValue(new GenericMessageTestHelper(5),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(5),Boolean.TYPE)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper(4),Boolean.TYPE)); - assertFalse(expression.getValue(new GenericMessageTestHelper(5),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(5),Boolean.TYPE)); expression = parse("8%3"); assertEquals(2,expression.getValue()); @@ -3897,7 +3897,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @Test public void mixingItUp_indexerOpEqTernary() throws Exception { - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("andy","778"); expression = parse("['andy']==null?1:2"); @@ -4028,7 +4028,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("C",getAst().getExitDescriptor()); // Collections - List strings = new ArrayList(); + List strings = new ArrayList<>(); strings.add("aaa"); strings.add("bbb"); strings.add("ccc"); @@ -4038,7 +4038,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("bbb",expression.getValue(strings)); assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); - List ints = new ArrayList(); + List ints = new ArrayList<>(); ints.add(123); ints.add(456); ints.add(789); @@ -4049,7 +4049,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); // Maps - Map map1 = new HashMap(); + Map map1 = new HashMap<>(); map1.put("aaa", 111); map1.put("bbb", 222); map1.put("ccc", 333); @@ -4082,7 +4082,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { // list of arrays - List listOfStringArrays = new ArrayList(); + List listOfStringArrays = new ArrayList<>(); listOfStringArrays.add(new String[]{"a","b","c"}); listOfStringArrays.add(new String[]{"d","e","f"}); expression = parser.parseExpression("[1]"); @@ -4097,7 +4097,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("d",stringify(expression.getValue(listOfStringArrays))); assertEquals("Ljava/lang/String",getAst().getExitDescriptor()); - List listOfIntegerArrays = new ArrayList(); + List listOfIntegerArrays = new ArrayList<>(); listOfIntegerArrays.add(new Integer[]{1,2,3}); listOfIntegerArrays.add(new Integer[]{4,5,6}); expression = parser.parseExpression("[0]"); @@ -4114,11 +4114,11 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { // array of lists List[] stringArrayOfLists = new ArrayList[2]; - stringArrayOfLists[0] = new ArrayList(); + stringArrayOfLists[0] = new ArrayList<>(); stringArrayOfLists[0].add("a"); stringArrayOfLists[0].add("b"); stringArrayOfLists[0].add("c"); - stringArrayOfLists[1] = new ArrayList(); + stringArrayOfLists[1] = new ArrayList<>(); stringArrayOfLists[1].add("d"); stringArrayOfLists[1].add("e"); stringArrayOfLists[1].add("f"); @@ -4163,13 +4163,13 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("I",getAst().getExitDescriptor()); // list of lists of reference types - List> listOfListOfStrings = new ArrayList>(); - List list = new ArrayList(); + List> listOfListOfStrings = new ArrayList<>(); + List list = new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); listOfListOfStrings.add(list); - list = new ArrayList(); + list = new ArrayList<>(); list.add("d"); list.add("e"); list.add("f"); @@ -4189,8 +4189,8 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); // Map of lists - Map> mapToLists = new HashMap>(); - list = new ArrayList(); + Map> mapToLists = new HashMap<>(); + list = new ArrayList<>(); list.add("a"); list.add("b"); list.add("c"); @@ -4209,7 +4209,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { assertEquals("Ljava/lang/Object",getAst().getExitDescriptor()); // Map to array - Map mapToIntArray = new HashMap(); + Map mapToIntArray = new HashMap<>(); StandardEvaluationContext ctx = new StandardEvaluationContext(); ctx.addPropertyAccessor(new CompilableMapAccessor()); mapToIntArray.put("foo",new int[]{1,2,3}); @@ -4244,7 +4244,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { // Map array Map[] mapArray = new Map[1]; - mapArray[0] = new HashMap(); + mapArray[0] = new HashMap<>(); mapArray[0].put("key", "value1"); expression = parser.parseExpression("[0]"); assertEquals("{key=value1}",stringify(expression.getValue(mapArray))); @@ -4334,197 +4334,197 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @Test public void compilerWithGenerics_12040() { expression = parser.parseExpression("payload!=2"); - assertTrue(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class)); assertCanCompile(expression); - assertFalse(expression.getValue(new GenericMessageTestHelper(2),Boolean.class)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class)); expression = parser.parseExpression("2!=payload"); - assertTrue(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class)); assertCanCompile(expression); - assertFalse(expression.getValue(new GenericMessageTestHelper(2),Boolean.class)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class)); expression = parser.parseExpression("payload!=6L"); - assertTrue(expression.getValue(new GenericMessageTestHelper(4L),Boolean.class)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(4L),Boolean.class)); assertCanCompile(expression); - assertFalse(expression.getValue(new GenericMessageTestHelper(6L),Boolean.class)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(6L),Boolean.class)); expression = parser.parseExpression("payload==2"); - assertFalse(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper(2),Boolean.class)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class)); expression = parser.parseExpression("2==payload"); - assertFalse(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper(2),Boolean.class)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class)); expression = parser.parseExpression("payload==6L"); - assertFalse(expression.getValue(new GenericMessageTestHelper(4L),Boolean.class)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(4L),Boolean.class)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper(6L),Boolean.class)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(6L),Boolean.class)); expression = parser.parseExpression("2==payload"); - assertFalse(expression.getValue(new GenericMessageTestHelper(4),Boolean.class)); + assertFalse(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper(2),Boolean.class)); + assertTrue(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class)); expression = parser.parseExpression("payload/2"); - assertEquals(2,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(2,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(3,expression.getValue(new GenericMessageTestHelper(6))); + assertEquals(3,expression.getValue(new GenericMessageTestHelper<>(6))); expression = parser.parseExpression("100/payload"); - assertEquals(25,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(25,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(10,expression.getValue(new GenericMessageTestHelper(10))); + assertEquals(10,expression.getValue(new GenericMessageTestHelper<>(10))); expression = parser.parseExpression("payload+2"); - assertEquals(6,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(6,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(8,expression.getValue(new GenericMessageTestHelper(6))); + assertEquals(8,expression.getValue(new GenericMessageTestHelper<>(6))); expression = parser.parseExpression("100+payload"); - assertEquals(104,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(104,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(110,expression.getValue(new GenericMessageTestHelper(10))); + assertEquals(110,expression.getValue(new GenericMessageTestHelper<>(10))); expression = parser.parseExpression("payload-2"); - assertEquals(2,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(2,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(4,expression.getValue(new GenericMessageTestHelper(6))); + assertEquals(4,expression.getValue(new GenericMessageTestHelper<>(6))); expression = parser.parseExpression("100-payload"); - assertEquals(96,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(96,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(90,expression.getValue(new GenericMessageTestHelper(10))); + assertEquals(90,expression.getValue(new GenericMessageTestHelper<>(10))); expression = parser.parseExpression("payload*2"); - assertEquals(8,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(8,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(12,expression.getValue(new GenericMessageTestHelper(6))); + assertEquals(12,expression.getValue(new GenericMessageTestHelper<>(6))); expression = parser.parseExpression("100*payload"); - assertEquals(400,expression.getValue(new GenericMessageTestHelper(4))); + assertEquals(400,expression.getValue(new GenericMessageTestHelper<>(4))); assertCanCompile(expression); - assertEquals(1000,expression.getValue(new GenericMessageTestHelper(10))); + assertEquals(1000,expression.getValue(new GenericMessageTestHelper<>(10))); expression = parser.parseExpression("payload/2L"); - assertEquals(2L,expression.getValue(new GenericMessageTestHelper(4L))); + assertEquals(2L,expression.getValue(new GenericMessageTestHelper<>(4L))); assertCanCompile(expression); - assertEquals(3L,expression.getValue(new GenericMessageTestHelper(6L))); + assertEquals(3L,expression.getValue(new GenericMessageTestHelper<>(6L))); expression = parser.parseExpression("100L/payload"); - assertEquals(25L,expression.getValue(new GenericMessageTestHelper(4L))); + assertEquals(25L,expression.getValue(new GenericMessageTestHelper<>(4L))); assertCanCompile(expression); - assertEquals(10L,expression.getValue(new GenericMessageTestHelper(10L))); + assertEquals(10L,expression.getValue(new GenericMessageTestHelper<>(10L))); expression = parser.parseExpression("payload/2f"); - assertEquals(2f,expression.getValue(new GenericMessageTestHelper(4f))); + assertEquals(2f,expression.getValue(new GenericMessageTestHelper<>(4f))); assertCanCompile(expression); - assertEquals(3f,expression.getValue(new GenericMessageTestHelper(6f))); + assertEquals(3f,expression.getValue(new GenericMessageTestHelper<>(6f))); expression = parser.parseExpression("100f/payload"); - assertEquals(25f,expression.getValue(new GenericMessageTestHelper(4f))); + assertEquals(25f,expression.getValue(new GenericMessageTestHelper<>(4f))); assertCanCompile(expression); - assertEquals(10f,expression.getValue(new GenericMessageTestHelper(10f))); + assertEquals(10f,expression.getValue(new GenericMessageTestHelper<>(10f))); expression = parser.parseExpression("payload/2d"); - assertEquals(2d,expression.getValue(new GenericMessageTestHelper(4d))); + assertEquals(2d,expression.getValue(new GenericMessageTestHelper<>(4d))); assertCanCompile(expression); - assertEquals(3d,expression.getValue(new GenericMessageTestHelper(6d))); + assertEquals(3d,expression.getValue(new GenericMessageTestHelper<>(6d))); expression = parser.parseExpression("100d/payload"); - assertEquals(25d,expression.getValue(new GenericMessageTestHelper(4d))); + assertEquals(25d,expression.getValue(new GenericMessageTestHelper<>(4d))); assertCanCompile(expression); - assertEquals(10d,expression.getValue(new GenericMessageTestHelper(10d))); + assertEquals(10d,expression.getValue(new GenericMessageTestHelper<>(10d))); } // The new helper class here uses an upper bound on the generic @Test public void compilerWithGenerics_12040_2() { expression = parser.parseExpression("payload/2"); - assertEquals(2,expression.getValue(new GenericMessageTestHelper2(4))); + assertEquals(2,expression.getValue(new GenericMessageTestHelper2<>(4))); assertCanCompile(expression); - assertEquals(3,expression.getValue(new GenericMessageTestHelper2(6))); + assertEquals(3,expression.getValue(new GenericMessageTestHelper2<>(6))); expression = parser.parseExpression("9/payload"); - assertEquals(1,expression.getValue(new GenericMessageTestHelper2(9))); + assertEquals(1,expression.getValue(new GenericMessageTestHelper2<>(9))); assertCanCompile(expression); - assertEquals(3,expression.getValue(new GenericMessageTestHelper2(3))); + assertEquals(3,expression.getValue(new GenericMessageTestHelper2<>(3))); expression = parser.parseExpression("payload+2"); - assertEquals(6,expression.getValue(new GenericMessageTestHelper2(4))); + assertEquals(6,expression.getValue(new GenericMessageTestHelper2<>(4))); assertCanCompile(expression); - assertEquals(8,expression.getValue(new GenericMessageTestHelper2(6))); + assertEquals(8,expression.getValue(new GenericMessageTestHelper2<>(6))); expression = parser.parseExpression("100+payload"); - assertEquals(104,expression.getValue(new GenericMessageTestHelper2(4))); + assertEquals(104,expression.getValue(new GenericMessageTestHelper2<>(4))); assertCanCompile(expression); - assertEquals(110,expression.getValue(new GenericMessageTestHelper2(10))); + assertEquals(110,expression.getValue(new GenericMessageTestHelper2<>(10))); expression = parser.parseExpression("payload-2"); - assertEquals(2,expression.getValue(new GenericMessageTestHelper2(4))); + assertEquals(2,expression.getValue(new GenericMessageTestHelper2<>(4))); assertCanCompile(expression); - assertEquals(4,expression.getValue(new GenericMessageTestHelper2(6))); + assertEquals(4,expression.getValue(new GenericMessageTestHelper2<>(6))); expression = parser.parseExpression("100-payload"); - assertEquals(96,expression.getValue(new GenericMessageTestHelper2(4))); + assertEquals(96,expression.getValue(new GenericMessageTestHelper2<>(4))); assertCanCompile(expression); - assertEquals(90,expression.getValue(new GenericMessageTestHelper2(10))); + assertEquals(90,expression.getValue(new GenericMessageTestHelper2<>(10))); expression = parser.parseExpression("payload*2"); - assertEquals(8,expression.getValue(new GenericMessageTestHelper2(4))); + assertEquals(8,expression.getValue(new GenericMessageTestHelper2<>(4))); assertCanCompile(expression); - assertEquals(12,expression.getValue(new GenericMessageTestHelper2(6))); + assertEquals(12,expression.getValue(new GenericMessageTestHelper2<>(6))); expression = parser.parseExpression("100*payload"); - assertEquals(400,expression.getValue(new GenericMessageTestHelper2(4))); + assertEquals(400,expression.getValue(new GenericMessageTestHelper2<>(4))); assertCanCompile(expression); - assertEquals(1000,expression.getValue(new GenericMessageTestHelper2(10))); + assertEquals(1000,expression.getValue(new GenericMessageTestHelper2<>(10))); } // The other numeric operators @Test public void compilerWithGenerics_12040_3() { expression = parser.parseExpression("payload >= 2"); - assertTrue(expression.getValue(new GenericMessageTestHelper2(4),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(4),Boolean.TYPE)); assertCanCompile(expression); - assertFalse(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); expression = parser.parseExpression("2 >= payload"); - assertFalse(expression.getValue(new GenericMessageTestHelper2(5),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(5),Boolean.TYPE)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); expression = parser.parseExpression("payload > 2"); - assertTrue(expression.getValue(new GenericMessageTestHelper2(4),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(4),Boolean.TYPE)); assertCanCompile(expression); - assertFalse(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); expression = parser.parseExpression("2 > payload"); - assertFalse(expression.getValue(new GenericMessageTestHelper2(5),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(5),Boolean.TYPE)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); expression = parser.parseExpression("payload <=2"); - assertTrue(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); assertCanCompile(expression); - assertFalse(expression.getValue(new GenericMessageTestHelper2(6),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE)); expression = parser.parseExpression("2 <= payload"); - assertFalse(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper2(6),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE)); expression = parser.parseExpression("payload < 2"); - assertTrue(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); assertCanCompile(expression); - assertFalse(expression.getValue(new GenericMessageTestHelper2(6),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE)); expression = parser.parseExpression("2 < payload"); - assertFalse(expression.getValue(new GenericMessageTestHelper2(1),Boolean.TYPE)); + assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE)); assertCanCompile(expression); - assertTrue(expression.getValue(new GenericMessageTestHelper2(6),Boolean.TYPE)); + assertTrue(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE)); } @Test diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java index 0d9dd7cff1c..2a4f7bcdfa1 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,9 +70,9 @@ public class SpelDocumentationTests extends AbstractExpressionTests { public Inventor[] Members = new Inventor[1]; public List Members2 = new ArrayList(); - public Map officers = new HashMap(); + public Map officers = new HashMap<>(); - public List> reverse = new ArrayList>(); + public List> reverse = new ArrayList<>(); @SuppressWarnings("unchecked") IEEE() { @@ -419,7 +419,7 @@ public class SpelDocumentationTests extends AbstractExpressionTests { @Test public void testSpecialVariables() throws Exception { // create an array of integers - List primes = new ArrayList(); + List primes = new ArrayList<>(); primes.addAll(Arrays.asList(2,3,5,7,11,13,17)); // create parser and set variable 'primes' as the array of integers diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index 81e7e2ad373..b080a57f431 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -228,7 +228,7 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void SPR5804() throws Exception { - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("foo", "bar"); StandardEvaluationContext eContext = new StandardEvaluationContext(m); // root is a map instance eContext.addPropertyAccessor(new MapAccessor()); @@ -550,7 +550,7 @@ public class SpelReproTests extends AbstractExpressionTests { public String floo = "bar"; public XX() { - m = new HashMap(); + m = new HashMap<>(); m.put("$foo", "wibble"); m.put("bar", "siddle"); } @@ -579,7 +579,7 @@ public class SpelReproTests extends AbstractExpressionTests { static class Holder { - public Map map = new HashMap(); + public Map map = new HashMap<>(); } @@ -783,9 +783,9 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void mapOfMap_SPR7244() throws Exception { - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); map.put("uri", "http:"); - Map nameMap = new LinkedHashMap(); + Map nameMap = new LinkedHashMap<>(); nameMap.put("givenName", "Arthur"); map.put("value", nameMap); @@ -849,11 +849,11 @@ public class SpelReproTests extends AbstractExpressionTests { public Map ms; C() { - ls = new ArrayList(); + ls = new ArrayList<>(); ls.add("abc"); ls.add("def"); as = new String[] { "abc", "def" }; - ms = new HashMap(); + ms = new HashMap<>(); ms.put("abc", "xyz"); ms.put("def", "pqr"); } @@ -877,7 +877,7 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void greaterThanWithNulls_SPR7840() throws Exception { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(new D("aaa")); list.add(new D("bbb")); list.add(new D(null)); @@ -937,7 +937,7 @@ public class SpelReproTests extends AbstractExpressionTests { EvaluationContext emptyEvalContext = new StandardEvaluationContext(); - List args = new ArrayList(); + List args = new ArrayList<>(); args.add(TypeDescriptor.forObject(new Integer(42))); ConversionPriority1 target = new ConversionPriority1(); @@ -977,7 +977,7 @@ public class SpelReproTests extends AbstractExpressionTests { WideningPrimitiveConversion target = new WideningPrimitiveConversion(); EvaluationContext emptyEvalContext = new StandardEvaluationContext(); - List args = new ArrayList(); + List args = new ArrayList<>(); args.add(TypeDescriptor.forObject(INTEGER_VALUE)); MethodExecutor me = new ReflectiveMethodResolver(true).resolve(emptyEvalContext, target, "getX", args); @@ -990,10 +990,10 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void varargsAndPrimitives_SPR8174() throws Exception { EvaluationContext emptyEvalContext = new StandardEvaluationContext(); - List args = new ArrayList(); + List args = new ArrayList<>(); args.add(TypeDescriptor.forObject(34L)); - ReflectionUtil ru = new ReflectionUtil(); + ReflectionUtil ru = new ReflectionUtil<>(); MethodExecutor me = new ReflectiveMethodResolver().resolve(emptyEvalContext, ru, "methodToCall", args); args.set(0, TypeDescriptor.forObject(23)); @@ -1113,7 +1113,7 @@ public class SpelReproTests extends AbstractExpressionTests { public int DIV = 1; public int div = 3; - public Map m = new HashMap(); + public Map m = new HashMap<>(); Reserver() { m.put("NE", "xyz"); @@ -1229,10 +1229,10 @@ public class SpelReproTests extends AbstractExpressionTests { class ContextObject { - public Map firstContext = new HashMap(); - public Map secondContext = new HashMap(); - public Map thirdContext = new HashMap(); - public Map fourthContext = new HashMap(); + public Map firstContext = new HashMap<>(); + public Map secondContext = new HashMap<>(); + public Map thirdContext = new HashMap<>(); + public Map fourthContext = new HashMap<>(); public ContextObject() { firstContext.put("shouldBeFirst", "first"); @@ -1276,7 +1276,7 @@ public class SpelReproTests extends AbstractExpressionTests { public void customStaticFunctions_SPR9038() { ExpressionParser parser = new SpelExpressionParser(); StandardEvaluationContext context = new StandardEvaluationContext(); - List methodResolvers = new ArrayList(); + List methodResolvers = new ArrayList<>(); methodResolvers.add(new ReflectiveMethodResolver() { @Override protected Method[] getMethods(Class type) { @@ -1802,7 +1802,7 @@ public class SpelReproTests extends AbstractExpressionTests { public void SPR9194() { TestClass2 one = new TestClass2("abc"); TestClass2 two = new TestClass2("abc"); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("one", one); map.put("two", two); @@ -1813,7 +1813,7 @@ public class SpelReproTests extends AbstractExpressionTests { @Test public void SPR11348() { - Collection coll = new LinkedHashSet(); + Collection coll = new LinkedHashSet<>(); coll.add("one"); coll.add("two"); coll = Collections.unmodifiableCollection(coll); @@ -1927,10 +1927,10 @@ public class SpelReproTests extends AbstractExpressionTests { @Test @SuppressWarnings("rawtypes") public void SPR13055() throws Exception { - List> myPayload = new ArrayList>(); + List> myPayload = new ArrayList<>(); - Map v1 = new HashMap(); - Map v2 = new HashMap(); + Map v1 = new HashMap<>(); + Map v2 = new HashMap<>(); v1.put("test11", "test11"); v1.put("test12", "test12"); @@ -2269,7 +2269,7 @@ public class SpelReproTests extends AbstractExpressionTests { private String name; - private List children = new ArrayList(); + private List children = new ArrayList<>(); public void setName(String name) { this.name = name; @@ -2411,7 +2411,7 @@ public class SpelReproTests extends AbstractExpressionTests { public static class GuavaLists { public static List newArrayList(Iterable iterable) { - return new ArrayList(); + return new ArrayList<>(); } public static List newArrayList(Object... elements) { diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java index daa128363e5..0ca7c4b6cd5 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class PropertiesConversionSpelTests { @Test public void mapWithAllStringValues() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("x", "1"); map.put("y", "2"); map.put("z", "3"); @@ -63,7 +63,7 @@ public class PropertiesConversionSpelTests { @Test public void mapWithNonStringValue() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("x", "1"); map.put("y", 2); map.put("z", "3"); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java index c02949d1970..bcd5dbb362e 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -535,7 +535,7 @@ public class ReflectionHelperTests extends AbstractExpressionTests { } private List getTypeDescriptors(Class... types) { - List typeDescriptors = new ArrayList(types.length); + List typeDescriptors = new ArrayList<>(types.length); for (Class type : types) { typeDescriptors.add(TypeDescriptor.valueOf(type)); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Inventor.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Inventor.java index efc60ba973c..59b60e6562b 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Inventor.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Inventor.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.expression.spel.testresources; import java.util.ArrayList; @@ -25,16 +41,16 @@ public class Inventor { public Map testMap; private boolean wonNobelPrize; private PlaceOfBirth[] placesLived; - private List placesLivedList = new ArrayList(); + private List placesLivedList = new ArrayList<>(); public ArrayContainer arrayContainer; public boolean publicBoolean; private boolean accessedThroughGetSet; - public List listOfInteger = new ArrayList(); - public List booleanList = new ArrayList(); - public Map mapOfStringToBoolean = new LinkedHashMap(); - public Map mapOfNumbersUpToTen = new LinkedHashMap(); - public List listOfNumbersUpToTen = new ArrayList(); - public List listOneFive = new ArrayList(); + public List listOfInteger = new ArrayList<>(); + public List booleanList = new ArrayList<>(); + public Map mapOfStringToBoolean = new LinkedHashMap<>(); + public Map mapOfNumbersUpToTen = new LinkedHashMap<>(); + public List listOfNumbersUpToTen = new ArrayList<>(); + public List listOneFive = new ArrayList<>(); public String[] stringArrayOfThreeItems = new String[]{"1","2","3"}; private String foo; public int counter; @@ -46,7 +62,7 @@ public class Inventor { this.birthdate = birthdate; this.nationality = nationality; this.arrayContainer = new ArrayContainer(); - testMap = new HashMap(); + testMap = new HashMap<>(); testMap.put("monday", "montag"); testMap.put("tuesday", "dienstag"); testMap.put("wednesday", "mittwoch"); @@ -164,7 +180,7 @@ public class Inventor { } public List getDoublesAsStringList() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.add("14.35"); result.add("15.45"); return result; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java index 384cb0c8596..276b8bfa0c3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java @@ -51,7 +51,7 @@ class DatabasePopulatorConfigUtils { boolean ignoreFailedDrops = element.getAttribute("ignore-failures").equals("DROPS"); boolean continueOnError = element.getAttribute("ignore-failures").equals("ALL"); - ManagedList delegates = new ManagedList(); + ManagedList delegates = new ManagedList<>(); for (Element scriptElement : scripts) { String executionAttr = scriptElement.getAttribute("execution"); if (!StringUtils.hasText(executionAttr)) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/config/SortedResourcesFactoryBean.java b/spring-jdbc/src/main/java/org/springframework/jdbc/config/SortedResourcesFactoryBean.java index 6f20b20a9e2..72723febb21 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/config/SortedResourcesFactoryBean.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/config/SortedResourcesFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,9 +72,9 @@ public class SortedResourcesFactoryBean extends AbstractFactoryBean @Override protected Resource[] createInstance() throws Exception { - List scripts = new ArrayList(); + List scripts = new ArrayList<>(); for (String location : this.locations) { - List resources = new ArrayList( + List resources = new ArrayList<>( Arrays.asList(this.resourcePatternResolver.getResources(location))); Collections.sort(resources, new Comparator() { @Override diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java index af71c8763f9..331583633ee 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java @@ -212,8 +212,8 @@ public class BeanPropertyRowMapper implements RowMapper { */ protected void initialize(Class mappedClass) { this.mappedClass = mappedClass; - this.mappedFields = new HashMap(); - this.mappedProperties = new HashSet(); + this.mappedFields = new HashMap<>(); + this.mappedProperties = new HashSet<>(); PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(mappedClass); for (PropertyDescriptor pd : pds) { if (pd.getWriteMethod() != null) { @@ -280,7 +280,7 @@ public class BeanPropertyRowMapper implements RowMapper { ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); - Set populatedProperties = (isCheckFullyPopulated() ? new HashSet() : null); + Set populatedProperties = (isCheckFullyPopulated() ? new HashSet<>() : null); for (int index = 1; index <= columnCount; index++) { String column = JdbcUtils.lookupColumnName(rsmd, index); @@ -377,7 +377,7 @@ public class BeanPropertyRowMapper implements RowMapper { * @param mappedClass the class that each row should be mapped to */ public static BeanPropertyRowMapper newInstance(Class mappedClass) { - return new BeanPropertyRowMapper(mappedClass); + return new BeanPropertyRowMapper<>(mappedClass); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/CallableStatementCreatorFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/CallableStatementCreatorFactory.java index c4cdb8ab264..642894871af 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/CallableStatementCreatorFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/CallableStatementCreatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class CallableStatementCreatorFactory { */ public CallableStatementCreatorFactory(String callString) { this.callString = callString; - this.declaredParameters = new LinkedList(); + this.declaredParameters = new LinkedList<>(); } /** @@ -113,7 +113,7 @@ public class CallableStatementCreatorFactory { * @param params list of parameters (may be {@code null}) */ public CallableStatementCreator newCallableStatementCreator(Map params) { - return new CallableStatementCreatorImpl(params != null ? params : new HashMap()); + return new CallableStatementCreatorImpl(params != null ? params : new HashMap<>()); } /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/ColumnMapRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/ColumnMapRowMapper.java index 1a0ac8277fd..ad5e92817fb 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/ColumnMapRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/ColumnMapRowMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ public class ColumnMapRowMapper implements RowMapper> { * @see org.springframework.util.LinkedCaseInsensitiveMap */ protected Map createColumnMap(int columnCount) { - return new LinkedCaseInsensitiveMap(columnCount); + return new LinkedCaseInsensitiveMap<>(columnCount); } /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java index ec716dd5134..25070d8fa19 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java @@ -481,7 +481,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { @Override public List query(String sql, RowMapper rowMapper) throws DataAccessException { - return query(sql, new RowMapperResultSetExtractor(rowMapper)); + return query(sql, new RowMapperResultSetExtractor<>(rowMapper)); } @Override @@ -758,46 +758,46 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { @Override public List query(PreparedStatementCreator psc, RowMapper rowMapper) throws DataAccessException { - return query(psc, new RowMapperResultSetExtractor(rowMapper)); + return query(psc, new RowMapperResultSetExtractor<>(rowMapper)); } @Override public List query(String sql, PreparedStatementSetter pss, RowMapper rowMapper) throws DataAccessException { - return query(sql, pss, new RowMapperResultSetExtractor(rowMapper)); + return query(sql, pss, new RowMapperResultSetExtractor<>(rowMapper)); } @Override public List query(String sql, Object[] args, int[] argTypes, RowMapper rowMapper) throws DataAccessException { - return query(sql, args, argTypes, new RowMapperResultSetExtractor(rowMapper)); + return query(sql, args, argTypes, new RowMapperResultSetExtractor<>(rowMapper)); } @Override public List query(String sql, Object[] args, RowMapper rowMapper) throws DataAccessException { - return query(sql, args, new RowMapperResultSetExtractor(rowMapper)); + return query(sql, args, new RowMapperResultSetExtractor<>(rowMapper)); } @Override public List query(String sql, RowMapper rowMapper, Object... args) throws DataAccessException { - return query(sql, args, new RowMapperResultSetExtractor(rowMapper)); + return query(sql, args, new RowMapperResultSetExtractor<>(rowMapper)); } @Override public T queryForObject(String sql, Object[] args, int[] argTypes, RowMapper rowMapper) throws DataAccessException { - List results = query(sql, args, argTypes, new RowMapperResultSetExtractor(rowMapper, 1)); + List results = query(sql, args, argTypes, new RowMapperResultSetExtractor<>(rowMapper, 1)); return DataAccessUtils.requiredSingleResult(results); } @Override public T queryForObject(String sql, Object[] args, RowMapper rowMapper) throws DataAccessException { - List results = query(sql, args, new RowMapperResultSetExtractor(rowMapper, 1)); + List results = query(sql, args, new RowMapperResultSetExtractor<>(rowMapper, 1)); return DataAccessUtils.requiredSingleResult(results); } @Override public T queryForObject(String sql, RowMapper rowMapper, Object... args) throws DataAccessException { - List results = query(sql, args, new RowMapperResultSetExtractor(rowMapper, 1)); + List results = query(sql, args, new RowMapperResultSetExtractor<>(rowMapper, 1)); return DataAccessUtils.requiredSingleResult(results); } @@ -911,7 +911,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { if (keys != null) { try { RowMapperResultSetExtractor> rse = - new RowMapperResultSetExtractor>(getColumnMapRowMapper(), 1); + new RowMapperResultSetExtractor<>(getColumnMapRowMapper(), 1); generatedKeys.addAll(rse.extractData(keys)); } finally { @@ -966,7 +966,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return ps.executeBatch(); } else { - List rowsAffected = new ArrayList(); + List rowsAffected = new ArrayList<>(); for (int i = 0; i < batchSize; i++) { pss.setValues(ps, i); if (ipss != null && ipss.isBatchExhausted(i)) { @@ -1010,7 +1010,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return execute(sql, new PreparedStatementCallback() { @Override public int[][] doInPreparedStatement(PreparedStatement ps) throws SQLException { - List rowsAffected = new ArrayList(); + List rowsAffected = new ArrayList<>(); try { boolean batchSupported = true; if (!JdbcUtils.supportsBatchUpdates(ps.getConnection())) { @@ -1116,9 +1116,9 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { public Map call(CallableStatementCreator csc, List declaredParameters) throws DataAccessException { - final List updateCountParameters = new ArrayList(); - final List resultSetParameters = new ArrayList(); - final List callParameters = new ArrayList(); + final List updateCountParameters = new ArrayList<>(); + final List resultSetParameters = new ArrayList<>(); + final List callParameters = new ArrayList<>(); for (SqlParameter parameter : declaredParameters) { if (parameter.isResultsParameter()) { if (parameter instanceof SqlReturnResultSet) { @@ -1162,7 +1162,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { List updateCountParameters, List resultSetParameters, int updateCount) throws SQLException { - Map returnedResults = new HashMap(); + Map returnedResults = new HashMap<>(); int rsIndex = 0; int updateIndex = 0; boolean moreResults; @@ -1224,7 +1224,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { protected Map extractOutputParameters(CallableStatement cs, List parameters) throws SQLException { - Map returnedResults = new HashMap(); + Map returnedResults = new HashMap<>(); int sqlColIndex = 1; for (SqlParameter param : parameters) { if (param instanceof SqlOutParameter) { @@ -1272,7 +1272,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { if (rs == null) { return Collections.emptyMap(); } - Map returnedResults = new HashMap(); + Map returnedResults = new HashMap<>(); try { ResultSet rsToUse = rs; if (this.nativeJdbcExtractor != null) { @@ -1320,7 +1320,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { * @see SingleColumnRowMapper */ protected RowMapper getSingleColumnRowMapper(Class requiredType) { - return new SingleColumnRowMapper(requiredType); + return new SingleColumnRowMapper<>(requiredType); } /** @@ -1334,10 +1334,10 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { */ protected Map createResultsMap() { if (isResultsMapCaseInsensitive()) { - return new LinkedCaseInsensitiveMap(); + return new LinkedCaseInsensitiveMap<>(); } else { - return new LinkedHashMap(); + return new LinkedHashMap<>(); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java index 8ef34479be5..cb1a2389c67 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public class PreparedStatementCreatorFactory { */ public PreparedStatementCreatorFactory(String sql) { this.sql = sql; - this.declaredParameters = new LinkedList(); + this.declaredParameters = new LinkedList<>(); } /** @@ -205,7 +205,7 @@ public class PreparedStatementCreatorFactory { this.parameters = parameters; if (this.parameters.size() != declaredParameters.size()) { // account for named parameters being used multiple times - Set names = new HashSet(); + Set names = new HashSet<>(); for (int i = 0; i < parameters.size(); i++) { Object param = parameters.get(i); if (param instanceof SqlParameterValue) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowMapperResultSetExtractor.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowMapperResultSetExtractor.java index 98043f57b82..810ea8c1f88 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowMapperResultSetExtractor.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/RowMapperResultSetExtractor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ public class RowMapperResultSetExtractor implements ResultSetExtractor extractData(ResultSet rs) throws SQLException { - List results = (this.rowsExpected > 0 ? new ArrayList(this.rowsExpected) : new ArrayList()); + List results = (this.rowsExpected > 0 ? new ArrayList<>(this.rowsExpected) : new ArrayList()); int rowNum = 0; while (rs.next()) { results.add(this.rowMapper.mapRow(rs, rowNum++)); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java index 69e4154b97b..25456d9e927 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SingleColumnRowMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -197,7 +197,7 @@ public class SingleColumnRowMapper implements RowMapper { * @since 4.1 */ public static SingleColumnRowMapper newInstance(Class requiredType) { - return new SingleColumnRowMapper(requiredType); + return new SingleColumnRowMapper<>(requiredType); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java index 82a82962704..929b6c39605 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -177,7 +177,7 @@ public class SqlParameter { * to a List of SqlParameter objects as used in this package. */ public static List sqlTypesToAnonymousParameterList(int... types) { - List result = new LinkedList(); + List result = new LinkedList<>(); if (types != null) { for (int type : types) { result.add(new SqlParameter(type)); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java index c7b754d25ba..689fc270ad3 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java @@ -86,7 +86,7 @@ public abstract class StatementCreatorUtils { private static final Log logger = LogFactory.getLog(StatementCreatorUtils.class); - private static final Map, Integer> javaTypeToSqlTypeMap = new HashMap, Integer>(32); + private static final Map, Integer> javaTypeToSqlTypeMap = new HashMap<>(32); static { javaTypeToSqlTypeMap.put(boolean.class, Types.BOOLEAN); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java index effb5b8bbe3..708a7fcb935 100755 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,16 +64,16 @@ public class CallMetaDataContext { private String schemaName; /** List of SqlParameter objects to be used in call execution */ - private List callParameters = new ArrayList(); + private List callParameters = new ArrayList<>(); /** Actual name to use for the return value in the output map */ private String actualFunctionReturnName; /** Set of in parameter names to exclude use for any not listed */ - private Set limitedInParameterNames = new HashSet(); + private Set limitedInParameterNames = new HashSet<>(); /** List of SqlParameter names for out parameters */ - private List outParameterNames = new ArrayList(); + private List outParameterNames = new ArrayList<>(); /** Indicates whether this is a procedure or a function **/ private boolean function = false; @@ -300,11 +300,11 @@ public class CallMetaDataContext { * Reconcile the provided parameters with available metadata and add new ones where appropriate. */ protected List reconcileParameters(List parameters) { - final List declaredReturnParams = new ArrayList(); - final Map declaredParams = new LinkedHashMap(); + final List declaredReturnParams = new ArrayList<>(); + final Map declaredParams = new LinkedHashMap<>(); boolean returnDeclared = false; - List outParamNames = new ArrayList(); - List metaDataParamNames = new ArrayList(); + List outParamNames = new ArrayList<>(); + List metaDataParamNames = new ArrayList<>(); // Get the names of the meta data parameters for (CallParameterMetaData meta : this.metaDataProvider.getCallParameterMetaData()) { @@ -343,7 +343,7 @@ public class CallMetaDataContext { } setOutParameterNames(outParamNames); - List workParams = new ArrayList(); + List workParams = new ArrayList<>(); workParams.addAll(declaredReturnParams); if (!this.metaDataProvider.isProcedureColumnMetaDataUsed()) { @@ -351,7 +351,7 @@ public class CallMetaDataContext { return workParams; } - Map limitedInParamNamesMap = new HashMap(this.limitedInParameterNames.size()); + Map limitedInParamNamesMap = new HashMap<>(this.limitedInParameterNames.size()); for (String limitedParamName : this.limitedInParameterNames) { limitedInParamNamesMap.put( this.metaDataProvider.parameterNameToUse(limitedParamName).toLowerCase(), limitedParamName); @@ -460,8 +460,8 @@ public class CallMetaDataContext { Map caseInsensitiveParameterNames = SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource); - Map callParameterNames = new HashMap(this.callParameters.size()); - Map matchedParameters = new HashMap(this.callParameters.size()); + Map callParameterNames = new HashMap<>(this.callParameters.size()); + Map matchedParameters = new HashMap<>(this.callParameters.size()); for (SqlParameter parameter : this.callParameters) { if (parameter.isInputValueProvided()) { String parameterName = parameter.getName(); @@ -521,7 +521,7 @@ public class CallMetaDataContext { if (!this.metaDataProvider.isProcedureColumnMetaDataUsed()) { return inParameters; } - Map callParameterNames = new HashMap(this.callParameters.size()); + Map callParameterNames = new HashMap<>(this.callParameters.size()); for (SqlParameter parameter : this.callParameters) { if (parameter.isInputValueProvided()) { String parameterName = parameter.getName(); @@ -531,7 +531,7 @@ public class CallMetaDataContext { } } } - Map matchedParameters = new HashMap(inParameters.size()); + Map matchedParameters = new HashMap<>(inParameters.size()); for (String parameterName : inParameters.keySet()) { String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName); String callParameterName = callParameterNames.get(parameterNameToMatch.toLowerCase()); @@ -569,7 +569,7 @@ public class CallMetaDataContext { } public Map matchInParameterValuesWithCallParameters(Object[] parameterValues) { - Map matchedParameters = new HashMap(parameterValues.length); + Map matchedParameters = new HashMap<>(parameterValues.length); int i = 0; for (SqlParameter parameter : this.callParameters) { if (parameter.isInputValueProvided()) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java index ebee53ab79c..7865848f91f 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericCallMetaDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { private boolean storesLowerCaseIdentifiers = false; - private List callParameterMetaData = new ArrayList(); + private List callParameterMetaData = new ArrayList<>(); /** @@ -323,7 +323,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider { ResultSet procs = null; try { procs = databaseMetaData.getProcedures(metaDataCatalogName, metaDataSchemaName, metaDataProcedureName); - List found = new ArrayList(); + List found = new ArrayList<>(); while (procs.next()) { found.add(procs.getString("PROCEDURE_CAT") + "." + procs.getString("PROCEDURE_SCHEM") + "." + procs.getString("PROCEDURE_NAME")); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java index ebc4ec87fc2..c6d6e589c0a 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/GenericTableMetaDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { Arrays.asList("Apache Derby", "HSQL Database Engine"); /** Collection of TableParameterMetaData objects */ - private List tableParameterMetaData = new ArrayList(); + private List tableParameterMetaData = new ArrayList<>(); /** NativeJdbcExtractor that can be used to retrieve the native connection */ private NativeJdbcExtractor nativeJdbcExtractor; @@ -294,7 +294,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider { private void locateTableAndProcessMetaData(DatabaseMetaData databaseMetaData, String catalogName, String schemaName, String tableName) { - Map tableMeta = new HashMap(); + Map tableMeta = new HashMap<>(); ResultSet tables = null; try { tables = databaseMetaData.getTables( diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java index 0a2e6d63998..9c4c8335deb 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class TableMetaDataContext { private String schemaName; /** List of columns objects to be used in this context */ - private List tableColumns = new ArrayList(); + private List tableColumns = new ArrayList<>(); /** should we access insert parameter meta data info or not */ private boolean accessTableColumnMetaData = true; @@ -217,13 +217,13 @@ public class TableMetaDataContext { this.generatedKeyColumnsUsed = true; } if (declaredColumns.size() > 0) { - return new ArrayList(declaredColumns); + return new ArrayList<>(declaredColumns); } - Set keys = new LinkedHashSet(generatedKeyNames.length); + Set keys = new LinkedHashSet<>(generatedKeyNames.length); for (String key : generatedKeyNames) { keys.add(key.toUpperCase()); } - List columns = new ArrayList(); + List columns = new ArrayList<>(); for (TableParameterMetaData meta : metaDataProvider.getTableParameterMetaData()) { if (!keys.contains(meta.getParameterName().toUpperCase())) { columns.add(meta.getParameterName()); @@ -237,7 +237,7 @@ public class TableMetaDataContext { * @param parameterSource the parameter names and values */ public List matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) { - List values = new ArrayList(); + List values = new ArrayList<>(); // for parameter source lookups we need to provide caseinsensitive lookup support since the // database metadata is not necessarily providing case sensitive column names Map caseInsensitiveParameterNames = @@ -277,8 +277,8 @@ public class TableMetaDataContext { * @param inParameters the parameter names and values */ public List matchInParameterValuesWithInsertColumns(Map inParameters) { - List values = new ArrayList(); - Map source = new LinkedHashMap(inParameters.size()); + List values = new ArrayList<>(); + Map source = new LinkedHashMap<>(inParameters.size()); for (String key : inParameters.keySet()) { source.put(key.toLowerCase(), inParameters.get(key)); } @@ -294,7 +294,7 @@ public class TableMetaDataContext { * @return the insert string to be used */ public String createInsertString(String... generatedKeyNames) { - Set keys = new LinkedHashSet(generatedKeyNames.length); + Set keys = new LinkedHashSet<>(generatedKeyNames.length); for (String key : generatedKeyNames) { keys.add(key.toUpperCase()); } @@ -345,7 +345,7 @@ public class TableMetaDataContext { int[] types = new int[getTableColumns().size()]; List parameters = this.metaDataProvider.getTableParameterMetaData(); Map parameterMap = - new LinkedHashMap(parameters.size()); + new LinkedHashMap<>(parameters.size()); for (TableParameterMetaData tpmd : parameters) { parameterMap.put(tpmd.getParameterName().toUpperCase(), tpmd); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/AbstractSqlParameterSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/AbstractSqlParameterSource.java index 79526492fbd..7ca10b94408 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/AbstractSqlParameterSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/AbstractSqlParameterSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ import org.springframework.util.Assert; */ public abstract class AbstractSqlParameterSource implements SqlParameterSource { - private final Map sqlTypes = new HashMap(); + private final Map sqlTypes = new HashMap<>(); - private final Map typeNames = new HashMap(); + private final Map typeNames = new HashMap<>(); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java index 1726eabf3ff..50cb90632ec 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ public class BeanPropertySqlParameterSource extends AbstractSqlParameterSource { */ public String[] getReadablePropertyNames() { if (this.propertyNames == null) { - List names = new ArrayList(); + List names = new ArrayList<>(); PropertyDescriptor[] props = this.beanWrapper.getPropertyDescriptors(); for (PropertyDescriptor pd : props) { if (this.beanWrapper.isReadableProperty(pd.getName())) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java index af40df75f30..53dd6eca6fb 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import org.springframework.util.Assert; */ public class MapSqlParameterSource extends AbstractSqlParameterSource { - private final Map values = new LinkedHashMap(); + private final Map values = new LinkedHashMap<>(); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java index 94263807d9c..5bfb345f983 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -223,14 +223,14 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations public T queryForObject(String sql, SqlParameterSource paramSource, Class requiredType) throws DataAccessException { - return queryForObject(sql, paramSource, new SingleColumnRowMapper(requiredType)); + return queryForObject(sql, paramSource, new SingleColumnRowMapper<>(requiredType)); } @Override public T queryForObject(String sql, Map paramMap, Class requiredType) throws DataAccessException { - return queryForObject(sql, paramMap, new SingleColumnRowMapper(requiredType)); + return queryForObject(sql, paramMap, new SingleColumnRowMapper<>(requiredType)); } @Override @@ -247,7 +247,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations public List queryForList(String sql, SqlParameterSource paramSource, Class elementType) throws DataAccessException { - return query(sql, paramSource, new SingleColumnRowMapper(elementType)); + return query(sql, paramSource, new SingleColumnRowMapper<>(elementType)); } @Override diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterUtils.java index 79ff7d8a1f6..cbde6f799df 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,9 +74,9 @@ public abstract class NamedParameterUtils { public static ParsedSql parseSqlStatement(final String sql) { Assert.notNull(sql, "SQL must not be null"); - Set namedParameters = new HashSet(); + Set namedParameters = new HashSet<>(); String sqlToUse = sql; - List parameterList = new ArrayList(); + List parameterList = new ArrayList<>(); char[] statement = sql.toCharArray(); int namedParameterCount = 0; @@ -416,7 +416,7 @@ public abstract class NamedParameterUtils { */ public static List buildSqlParameterList(ParsedSql parsedSql, SqlParameterSource paramSource) { List paramNames = parsedSql.getParameterNames(); - List params = new LinkedList(); + List params = new LinkedList<>(); for (String paramName : paramNames) { params.add(new SqlParameter(paramName, paramSource.getSqlType(paramName), paramSource.getTypeName(paramName))); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/ParsedSql.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/ParsedSql.java index c60164afff0..dd9e8fc18e4 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/ParsedSql.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/ParsedSql.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ public class ParsedSql { private String originalSql; - private List parameterNames = new ArrayList(); + private List parameterNames = new ArrayList<>(); - private List parameterIndexes = new ArrayList(); + private List parameterIndexes = new ArrayList<>(); private int namedParameterCount; diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java index 89ebde23da4..f8c92a4a99a 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ public class SqlParameterSourceUtils { * @return the Map that can be used for case insensitive matching of parameter names */ public static Map extractCaseInsensitiveParameterNames(SqlParameterSource parameterSource) { - Map caseInsensitiveParameterNames = new HashMap(); + Map caseInsensitiveParameterNames = new HashMap<>(); if (parameterSource instanceof BeanPropertySqlParameterSource) { String[] propertyNames = ((BeanPropertySqlParameterSource)parameterSource).getReadablePropertyNames(); for (int i = 0; i < propertyNames.length; i++) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java index b55dbaa8f75..956b0e62ad5 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,10 +58,10 @@ public abstract class AbstractJdbcCall { private final CallMetaDataContext callMetaDataContext = new CallMetaDataContext(); /** List of SqlParameter objects */ - private final List declaredParameters = new ArrayList(); + private final List declaredParameters = new ArrayList<>(); /** List of RefCursor/ResultSet RowMapper objects */ - private final Map> declaredRowMappers = new LinkedHashMap>(); + private final Map> declaredRowMappers = new LinkedHashMap<>(); /** * Has this operation been compiled? Compilation means at least checking diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java index 3d7c25f1d3d..6da8212d1fa 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java @@ -71,7 +71,7 @@ public abstract class AbstractJdbcInsert { private final TableMetaDataContext tableMetaDataContext = new TableMetaDataContext(); /** List of columns objects to be used in insert statement */ - private final List declaredColumns = new ArrayList(); + private final List declaredColumns = new ArrayList<>(); /** The names of the columns holding the generated key */ private String[] generatedKeyNames = new String[0]; @@ -467,7 +467,7 @@ public abstract class AbstractJdbcInsert { if (keyQuery.toUpperCase().startsWith("RETURNING")) { Long key = getJdbcTemplate().queryForObject(getInsertString() + " " + keyQuery, values.toArray(new Object[values.size()]), Long.class); - Map keys = new HashMap(1); + Map keys = new HashMap<>(1); keys.put(getGeneratedKeyNames()[0], key); keyHolder.getKeyList().add(keys); } @@ -488,7 +488,7 @@ public abstract class AbstractJdbcInsert { //Get the key Statement keyStmt = null; ResultSet rs = null; - Map keys = new HashMap(1); + Map keys = new HashMap<>(1); try { keyStmt = con.createStatement(); rs = keyStmt.executeQuery(keyQuery); @@ -545,7 +545,7 @@ public abstract class AbstractJdbcInsert { @SuppressWarnings("unchecked") protected int[] doExecuteBatch(Map... batch) { checkCompiled(); - List> batchValues = new ArrayList>(batch.length); + List> batchValues = new ArrayList<>(batch.length); for (Map args : batch) { batchValues.add(matchInParameterValuesWithInsertColumns(args)); } @@ -559,7 +559,7 @@ public abstract class AbstractJdbcInsert { */ protected int[] doExecuteBatch(SqlParameterSource... batch) { checkCompiled(); - List> batchValues = new ArrayList>(batch.length); + List> batchValues = new ArrayList<>(batch.length); for (SqlParameterSource parameterSource : batch) { batchValues.add(matchInParameterValuesWithInsertColumns(parameterSource)); } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java index e08be0acd66..0786308e210 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -125,7 +125,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp @Override public SimpleJdbcCall useInParameterNames(String... inParameterNames) { - setInParameterNames(new LinkedHashSet(Arrays.asList(inParameterNames))); + setInParameterNames(new LinkedHashSet<>(Arrays.asList(inParameterNames))); return this; } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java index cfcaca4db7b..00d06cbcef4 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource { private String password; private final ThreadLocal threadBoundCredentials = - new NamedThreadLocal("Current JDBC user credentials"); + new NamedThreadLocal<>("Current JDBC user credentials"); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulator.java index 0ae78488185..3f7cd1d1b77 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulator.java @@ -35,7 +35,7 @@ import java.util.List; */ public class CompositeDatabasePopulator implements DatabasePopulator { - private final List populators = new ArrayList(4); + private final List populators = new ArrayList<>(4); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java index 75a668d516f..8b412426355 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java @@ -52,7 +52,7 @@ import org.springframework.util.StringUtils; */ public class ResourceDatabasePopulator implements DatabasePopulator { - private List scripts = new ArrayList(); + private List scripts = new ArrayList<>(); private String sqlScriptEncoding; @@ -137,7 +137,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator { public void setScripts(Resource... scripts) { assertContentsOfScriptArray(scripts); // Ensure that the list is modifiable - this.scripts = new ArrayList(Arrays.asList(scripts)); + this.scripts = new ArrayList<>(Arrays.asList(scripts)); } /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java index da4125421b1..be2b71fc552 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java @@ -460,7 +460,7 @@ public abstract class ScriptUtils { separator = FALLBACK_STATEMENT_SEPARATOR; } - List statements = new LinkedList(); + List statements = new LinkedList<>(); splitSqlScript(resource, script, separator, commentPrefix, blockCommentStartDelimiter, blockCommentEndDelimiter, statements); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java index 7e688c6afe2..0e9b06ca2d1 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple if (this.targetDataSources == null) { throw new IllegalArgumentException("Property 'targetDataSources' is required"); } - this.resolvedDataSources = new HashMap(this.targetDataSources.size()); + this.resolvedDataSources = new HashMap<>(this.targetDataSources.size()); for (Map.Entry entry : this.targetDataSources.entrySet()) { Object lookupKey = resolveSpecifiedLookupKey(entry.getKey()); DataSource dataSource = resolveSpecifiedDataSource(entry.getValue()); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookup.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookup.java index e392303e798..24cfdfbe789 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookup.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookup.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.util.Assert; */ public class MapDataSourceLookup implements DataSourceLookup { - private final Map dataSources = new HashMap(4); + private final Map dataSources = new HashMap<>(4); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java index c8b0484652b..1fcf29d0941 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java @@ -55,9 +55,9 @@ public class BatchSqlUpdate extends SqlUpdate { private boolean trackRowsAffected = true; - private final LinkedList parameterQueue = new LinkedList(); + private final LinkedList parameterQueue = new LinkedList<>(); - private final List rowsAffected = new ArrayList(); + private final List rowsAffected = new ArrayList<>(); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java index 7392219062d..a1d71e1ff60 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public abstract class RdbmsOperation implements InitializingBean { private String sql; - private final List declaredParameters = new LinkedList(); + private final List declaredParameters = new LinkedList<>(); /** * Has this operation been compiled? Compilation means at diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java index 455e884ca70..a9ec921912e 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ import org.springframework.jdbc.core.SingleColumnRowMapper; */ public class SqlFunction extends MappingSqlQuery { - private final SingleColumnRowMapper rowMapper = new SingleColumnRowMapper(); + private final SingleColumnRowMapper rowMapper = new SingleColumnRowMapper<>(); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java index 077a59e2e7a..30e08b29e7f 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,7 +110,7 @@ public abstract class StoredProcedure extends SqlCall { * stored procedure has been called. */ public Map execute(Object... inParams) { - Map paramsToUse = new HashMap(); + Map paramsToUse = new HashMap<>(); validateParameters(inParams); int i = 0; for (SqlParameter sqlParameter : getDeclaredParameters()) { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrar.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrar.java index 2faaaba18eb..02ebbfc1adb 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrar.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class CustomSQLExceptionTranslatorRegistrar implements InitializingBean { * Key is the database product name as defined in the * {@link org.springframework.jdbc.support.SQLErrorCodesFactory}. */ - private final Map translators = new HashMap(); + private final Map translators = new HashMap<>(); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java index d41d7624b6b..19801eb5920 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class CustomSQLExceptionTranslatorRegistry { * Key is the database product name as defined in the * {@link org.springframework.jdbc.support.SQLErrorCodesFactory}. */ - private final Map translatorMap = new HashMap(); + private final Map translatorMap = new HashMap<>(); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java index abdab1e872f..0de3fcfc43d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/GeneratedKeyHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public class GeneratedKeyHolder implements KeyHolder { * Create a new GeneratedKeyHolder with a default list. */ public GeneratedKeyHolder() { - this.keyList = new LinkedList>(); + this.keyList = new LinkedList<>(); } /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java index e3b81f6c4ee..cfa8506bd32 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class SQLErrorCodesFactory { /** * Map to cache the SQLErrorCodes instance per DataSource. */ - private final Map dataSourceCache = new WeakHashMap(16); + private final Map dataSourceCache = new WeakHashMap<>(16); /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.java index 1cd9144ff3d..30f4f582e82 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,15 +45,15 @@ import org.springframework.jdbc.BadSqlGrammarException; */ public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator { - private static final Set BAD_SQL_GRAMMAR_CODES = new HashSet(8); + private static final Set BAD_SQL_GRAMMAR_CODES = new HashSet<>(8); - private static final Set DATA_INTEGRITY_VIOLATION_CODES = new HashSet(8); + private static final Set DATA_INTEGRITY_VIOLATION_CODES = new HashSet<>(8); - private static final Set DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet(8); + private static final Set DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet<>(8); - private static final Set TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet(8); + private static final Set TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet<>(8); - private static final Set CONCURRENCY_FAILURE_CODES = new HashSet(4); + private static final Set CONCURRENCY_FAILURE_CODES = new HashSet<>(4); static { diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java index fbe1b55744a..e41154b7b15 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/lob/TemporaryLobCreator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,9 +50,9 @@ public class TemporaryLobCreator implements LobCreator { protected static final Log logger = LogFactory.getLog(TemporaryLobCreator.class); - private final Set temporaryBlobs = new LinkedHashSet(1); + private final Set temporaryBlobs = new LinkedHashSet<>(1); - private final Set temporaryClobs = new LinkedHashSet(1); + private final Set temporaryClobs = new LinkedHashSet<>(1); @Override diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java index 0f07b94b302..714b7effd0d 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java @@ -96,7 +96,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet { ResultSetMetaData rsmd = resultSet.getMetaData(); if (rsmd != null) { int columnCount = rsmd.getColumnCount(); - this.columnLabelMap = new HashMap(columnCount); + this.columnLabelMap = new HashMap<>(columnCount); for (int i = 1; i <= columnCount; i++) { String key = rsmd.getColumnLabel(i); // Make sure to preserve first matching column for any given name, diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java index fd9421a91c5..078350629ad 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests { @Test public void testOverridingSameClassDefinedForMapping() { - BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class); + BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(Person.class); mapper.setMappedClass(Person.class); } @@ -59,7 +59,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests { Mock mock = new Mock(); List result = mock.getJdbcTemplate().query( "select name, age, birth_date, balance from people", - new BeanPropertyRowMapper(Person.class)); + new BeanPropertyRowMapper<>(Person.class)); assertEquals(1, result.size()); verifyPerson(result.get(0)); mock.verifyClosed(); @@ -70,7 +70,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests { Mock mock = new Mock(); List result = mock.getJdbcTemplate().query( "select name, age, birth_date, balance from people", - new BeanPropertyRowMapper(ConcretePerson.class)); + new BeanPropertyRowMapper<>(ConcretePerson.class)); assertEquals(1, result.size()); verifyConcretePerson(result.get(0)); mock.verifyClosed(); @@ -81,7 +81,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests { Mock mock = new Mock(); List result = mock.getJdbcTemplate().query( "select name, age, birth_date, balance from people", - new BeanPropertyRowMapper(ConcretePerson.class, true)); + new BeanPropertyRowMapper<>(ConcretePerson.class, true)); assertEquals(1, result.size()); verifyConcretePerson(result.get(0)); mock.verifyClosed(); @@ -92,7 +92,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests { Mock mock = new Mock(); List result = mock.getJdbcTemplate().query( "select name, age, birth_date, balance from people", - new BeanPropertyRowMapper(ExtendedPerson.class)); + new BeanPropertyRowMapper<>(ExtendedPerson.class)); assertEquals(1, result.size()); ExtendedPerson bean = result.get(0); verifyConcretePerson(bean); @@ -105,12 +105,12 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests { thrown.expect(InvalidDataAccessApiUsageException.class); mock.getJdbcTemplate().query( "select name, age, birth_date, balance from people", - new BeanPropertyRowMapper(ExtendedPerson.class, true)); + new BeanPropertyRowMapper<>(ExtendedPerson.class, true)); } @Test public void testMappingNullValue() throws Exception { - BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class); + BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(Person.class); Mock mock = new Mock(MockType.TWO); thrown.expect(TypeMismatchException.class); mock.getJdbcTemplate().query( @@ -122,7 +122,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests { Mock mock = new Mock(MockType.THREE); List result = mock.getJdbcTemplate().query( "select last_name as \"Last Name\", age, birth_date, balance from people", - new BeanPropertyRowMapper(SpacePerson.class)); + new BeanPropertyRowMapper<>(SpacePerson.class)); assertEquals(1, result.size()); verifySpacePerson(result.get(0)); mock.verifyClosed(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java index 0008db7992b..b7c38059707 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -224,7 +224,7 @@ public class JdbcTemplateTests { String[] results = { "rod", "gary", " portia" }; class StringHandler implements RowCallbackHandler { - private List list = new LinkedList(); + private List list = new LinkedList<>(); @Override public void processRow(ResultSet rs) throws SQLException { this.list.add(rs.getString(1)); @@ -742,7 +742,7 @@ public class JdbcTemplateTests { public void testBatchUpdateWithListOfObjectArrays() throws Exception { final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?"; - final List ids = new ArrayList(); + final List ids = new ArrayList<>(); ids.add(new Object[] {100}); ids.add(new Object[] {200}); final int[] rowsAffected = new int[] { 1, 2 }; @@ -768,7 +768,7 @@ public class JdbcTemplateTests { @Test public void testBatchUpdateWithListOfObjectArraysPlusTypeInfo() throws Exception { final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?"; - final List ids = new ArrayList(); + final List ids = new ArrayList<>(); ids.add(new Object[] {100}); ids.add(new Object[] {200}); final int[] sqlTypes = new int[] {Types.NUMERIC}; @@ -1185,7 +1185,7 @@ public class JdbcTemplateTests { public CallableStatement createCallableStatement(Connection con) { return callableStatement; } - }, new ArrayList()); + }, new ArrayList<>()); verify(this.resultSet, times(2)).close(); verify(this.statement).close(); @@ -1246,7 +1246,7 @@ public class JdbcTemplateTests { given(this.callableStatement.execute()).willReturn(true); given(this.callableStatement.getUpdateCount()).willReturn(-1); - List params = new ArrayList(); + List params = new ArrayList<>(); params.add(new SqlReturnResultSet("", new RowCallbackHandler() { @Override public void processRow(ResultSet rs) { @@ -1286,7 +1286,7 @@ public class JdbcTemplateTests { assertTrue("now it should have been set to case insensitive", this.template.isResultsMapCaseInsensitive()); - List params = new ArrayList(); + List params = new ArrayList<>(); params.add(new SqlOutParameter("a", 12)); Map out = this.template.call(new CallableStatementCreator() { diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java index 56a3bbf46dd..a64f85e7ac6 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ public class NamedParameterJdbcTemplateTests { private PreparedStatement preparedStatement; private ResultSet resultSet; private DatabaseMetaData databaseMetaData; - private Map params = new HashMap(); + private Map params = new HashMap<>(); private NamedParameterJdbcTemplate namedParameterTemplate; @Before @@ -242,7 +242,7 @@ public class NamedParameterJdbcTemplateTests { params.put("id", new SqlParameterValue(Types.DECIMAL, 1)); params.put("country", "UK"); - final List customers = new LinkedList(); + final List customers = new LinkedList<>(); namedParameterTemplate.query(SELECT_NAMED_PARAMETERS, params, new RowCallbackHandler() { @Override public void processRow(ResultSet rs) throws SQLException { @@ -269,7 +269,7 @@ public class NamedParameterJdbcTemplateTests { given(resultSet.getInt("id")).willReturn(1); given(resultSet.getString("forename")).willReturn("rod"); - final List customers = new LinkedList(); + final List customers = new LinkedList<>(); namedParameterTemplate.query(SELECT_NO_PARAMETERS, new RowCallbackHandler() { @Override public void processRow(ResultSet rs) throws SQLException { diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java index d4d2cb61e48..71f5f322129 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -190,7 +190,7 @@ public class NamedParameterQueryTests { given(resultSet.next()).willReturn(true, false); given(resultSet.getInt(1)).willReturn(22); - Map parms = new HashMap(); + Map parms = new HashMap<>(); parms.put("id", 3); Object o = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID = :id", parms, Integer.class); @@ -240,7 +240,7 @@ public class NamedParameterQueryTests { given(resultSet.getInt(1)).willReturn(22); MapSqlParameterSource parms = new MapSqlParameterSource(); - List l1 = new ArrayList(); + List l1 = new ArrayList<>(); l1.add(new Object[] {3, "Rod"}); l1.add(new Object[] {4, "Juergen"}); parms.addValue("multiExpressionList", l1); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java index 339704d036f..acac10e94c7 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ public class NamedParameterUtilsTests { @Test public void convertParamMapToArray() { - Map paramMap = new HashMap(); + Map paramMap = new HashMap<>(); paramMap.put("a", "a"); paramMap.put("b", "b"); paramMap.put("c", "c"); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java index 64729db886d..46999861b3b 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,7 +76,7 @@ public class CallMetaDataContextTests { given(databaseMetaData.getUserName()).willReturn(USER); given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true); - List parameters = new ArrayList(); + List parameters = new ArrayList<>(); parameters.add(new SqlParameter("id", Types.NUMERIC)); parameters.add(new SqlInOutParameter("name", Types.NUMERIC)); parameters.add(new SqlOutParameter("customer_no", Types.NUMERIC)); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java index aaa6a87e83c..1255246f3bf 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ public class SimpleJdbcInsertTests { // Shouldn't succeed in inserting into table which doesn't exist thrown.expect(InvalidDataAccessApiUsageException.class); try { - insert.execute(new HashMap()); + insert.execute(new HashMap<>()); } finally { verify(resultSet).close(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java index d7bf27e37fb..a4cba4be47e 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class TableMetaDataContextTests { map.registerSqlType("version", Types.NUMERIC); context.setTableName(TABLE); - context.processMetaData(dataSource, new ArrayList(), new String[] {}); + context.processMetaData(dataSource, new ArrayList<>(), new String[] {}); List values = context.matchInParameterValuesWithInsertColumns(map); @@ -142,7 +142,7 @@ public class TableMetaDataContextTests { MapSqlParameterSource map = new MapSqlParameterSource(); String[] keyCols = new String[] { "id" }; context.setTableName(TABLE); - context.processMetaData(dataSource, new ArrayList(), keyCols); + context.processMetaData(dataSource, new ArrayList<>(), keyCols); List values = context.matchInParameterValuesWithInsertColumns(map); String insertString = context.createInsertString(keyCols); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java index 5338428b171..f2d4522ad94 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public class JdbcDaoSupportTests { @Test public void testJdbcDaoSupportWithDataSource() throws Exception { DataSource ds = mock(DataSource.class); - final List test = new ArrayList(); + final List test = new ArrayList<>(); JdbcDaoSupport dao = new JdbcDaoSupport() { @Override protected void initDao() { @@ -53,7 +53,7 @@ public class JdbcDaoSupportTests { @Test public void testJdbcDaoSupportWithJdbcTemplate() throws Exception { JdbcTemplate template = new JdbcTemplate(); - final List test = new ArrayList(); + final List test = new ArrayList<>(); JdbcDaoSupport dao = new JdbcDaoSupport() { @Override protected void initDao() { diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java index 3cda75ea57c..e8fe56391e5 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -672,7 +672,7 @@ given( userTransaction.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, St given(dataSource2.getConnection()).willReturn(connection2); final IsolationLevelDataSourceRouter dsToUse = new IsolationLevelDataSourceRouter(); - Map targetDataSources = new HashMap(); + Map targetDataSources = new HashMap<>(); if (dataSourceLookup) { targetDataSources.put("ISOLATION_REPEATABLE_READ", "ds2"); dsToUse.setDefaultTargetDataSource("ds1"); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java index ab9a5a5eb92..7275cccc7c2 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class ScriptUtilsUnitTests { String cleanedStatement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)"; char delim = ';'; String script = rawStatement1 + delim + rawStatement2 + delim + rawStatement3 + delim; - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, delim, statements); assertEquals("wrong number of statements", 3, statements.size()); assertEquals("statement 1 not split correctly", cleanedStatement1, statements.get(0)); @@ -65,7 +65,7 @@ public class ScriptUtilsUnitTests { String statement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)"; char delim = '\n'; String script = statement1 + delim + statement2 + delim + statement3 + delim; - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, delim, statements); assertEquals("wrong number of statements", 3, statements.size()); assertEquals("statement 1 not split correctly", statement1, statements.get(0)); @@ -79,7 +79,7 @@ public class ScriptUtilsUnitTests { String statement2 = "do something else"; char delim = '\n'; String script = statement1 + delim + statement2 + delim; - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, DEFAULT_STATEMENT_SEPARATOR, statements); assertEquals("wrong number of statements", 1, statements.size()); assertEquals("script should have been 'stripped' but not actually 'split'", script.replace('\n', ' '), @@ -95,7 +95,7 @@ public class ScriptUtilsUnitTests { String statement2 = "select '2' as \"Dilbert's\" from dual"; char delim = ';'; String script = statement1 + delim + statement2 + delim; - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, ';', statements); assertEquals("wrong number of statements", 2, statements.size()); assertEquals("statement 1 not split correctly", statement1, statements.get(0)); @@ -108,7 +108,7 @@ public class ScriptUtilsUnitTests { @Test public void readAndSplitScriptWithMultipleNewlinesAsSeparator() throws Exception { String script = readScript("db-test-data-multi-newline.sql"); - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, "\n\n", statements); String statement1 = "insert into T_TEST (NAME) values ('Keith')"; @@ -122,7 +122,7 @@ public class ScriptUtilsUnitTests { @Test public void readAndSplitScriptContainingComments() throws Exception { String script = readScript("test-data-with-comments.sql"); - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, ';', statements); String statement1 = "insert into customer (id, name) values (1, 'Rod; Johnson'), (2, 'Adrian Collier')"; @@ -144,7 +144,7 @@ public class ScriptUtilsUnitTests { @Test public void readAndSplitScriptContainingCommentsWithLeadingTabs() throws Exception { String script = readScript("test-data-with-comments-and-leading-tabs.sql"); - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, ';', statements); String statement1 = "insert into customer (id, name) values (1, 'Sam Brannen')"; @@ -163,7 +163,7 @@ public class ScriptUtilsUnitTests { @Test public void readAndSplitScriptContainingMuliLineComments() throws Exception { String script = readScript("test-data-with-multi-line-comments.sql"); - List statements = new ArrayList(); + List statements = new ArrayList<>(); splitSqlScript(script, ';', statements); String statement1 = "INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller')"; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java index e458e29d0d2..2e61ea223d7 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public final class MapDataSourceLookupTests { @Test public void lookupSunnyDay() throws Exception { - Map dataSources = new HashMap(); + Map dataSources = new HashMap<>(); StubDataSource expectedDataSource = new StubDataSource(); dataSources.put(DATA_SOURCE_NAME, expectedDataSource); MapDataSourceLookup lookup = new MapDataSourceLookup(); @@ -62,7 +62,7 @@ public final class MapDataSourceLookupTests { @Test public void setDataSourcesIsAnIdempotentOperation() throws Exception { - Map dataSources = new HashMap(); + Map dataSources = new HashMap<>(); StubDataSource expectedDataSource = new StubDataSource(); dataSources.put(DATA_SOURCE_NAME, expectedDataSource); MapDataSourceLookup lookup = new MapDataSourceLookup(); @@ -75,7 +75,7 @@ public final class MapDataSourceLookupTests { @Test public void addingDataSourcePermitsOverride() throws Exception { - Map dataSources = new HashMap(); + Map dataSources = new HashMap<>(); StubDataSource overridenDataSource = new StubDataSource(); StubDataSource expectedDataSource = new StubDataSource(); dataSources.put(DATA_SOURCE_NAME, overridenDataSource); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java index ed32b628ad8..66a0432538a 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,7 +93,7 @@ public class GenericSqlQueryTests { List queryResults; if (namedParameters) { - Map params = new HashMap(2); + Map params = new HashMap<>(2); params.put("id", 1); params.put("country", "UK"); queryResults = query.executeByNamedParam(params); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java index 7471cf0a538..8bec210b569 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class GenericStoredProcedureTests { given(connection.prepareCall("{call " + "add_invoice" + "(?, ?, ?)}")).willReturn(callableStatement); StoredProcedure adder = (StoredProcedure) bf.getBean("genericProcedure"); - Map in = new HashMap(2); + Map in = new HashMap<>(2); in.put("amount", 1106); in.put("custid", 3); Map out = adder.execute(in); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java index 9a0307d5253..9220a8a5d09 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,7 +109,7 @@ public class RdbmsOperationTests { @Test public void unspecifiedMapParameters() { operation.setSql("select * from mytable"); - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("col1", "value"); exception.expect(InvalidDataAccessApiUsageException.class); operation.validateNamedParameters(params); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java index aee77476b65..60e79cd3b9d 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -498,7 +498,7 @@ public class SqlQueryTests { } public Customer findCustomer(int id) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("id", id); return executeByNamedParam(params).get(0); } @@ -556,7 +556,7 @@ public class SqlQueryTests { } public Customer findCustomer(int id, String country) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("id", id); params.put("country", country); return executeByNamedParam(params).get(0); @@ -602,14 +602,14 @@ public class SqlQueryTests { } public List findCustomers(List ids) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("ids", ids); return executeByNamedParam(params); } } CustomerQuery query = new CustomerQuery(dataSource); - List ids = new ArrayList(); + List ids = new ArrayList<>(); ids.add(1); ids.add(2); List cust = query.findCustomers(ids); @@ -654,7 +654,7 @@ public class SqlQueryTests { } public List findCustomers(Integer id) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("id1", id); return executeByNamedParam(params); } @@ -701,7 +701,7 @@ public class SqlQueryTests { } public List findCustomers(Integer id1) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("id1", id1); return executeByNamedParam(params); } @@ -737,7 +737,7 @@ public class SqlQueryTests { } CustomerUpdateQuery query = new CustomerUpdateQuery(dataSource); - Map values = new HashMap(2); + Map values = new HashMap<>(2); values.put(1, "Rod"); values.put(2, "Thomas"); query.execute(2, values); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java index dad295b2fa0..949eee6952b 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java @@ -166,7 +166,7 @@ public class SqlUpdateTests { } public int run(int performanceId, int type) { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("perfId", performanceId); params.put("priceId", type); return updateByNamedParam(params); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java index 4c40aa9952b..573fe14ef33 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -447,7 +447,7 @@ public class StoredProcedureTests { } public int execute(int intIn) { - Map in = new HashMap(); + Map in = new HashMap<>(); in.put("intIn", intIn); Map out = execute(in); return ((Number) out.get("intOut")).intValue(); @@ -468,7 +468,7 @@ public class StoredProcedureTests { } public int execute(int amount, int custid) { - Map in = new HashMap(); + Map in = new HashMap<>(); in.put("amount", amount); in.put("custid", custid); Map out = execute(in); @@ -507,7 +507,7 @@ public class StoredProcedureTests { } public void execute(String s) { - Map in = new HashMap(); + Map in = new HashMap<>(); in.put("ptest", s); execute(in); } @@ -524,7 +524,7 @@ public class StoredProcedureTests { } public void execute() { - execute(new HashMap()); + execute(new HashMap<>()); } } @@ -548,7 +548,7 @@ public class StoredProcedureTests { } public void execute() { - execute(new HashMap()); + execute(new HashMap<>()); } } @@ -566,7 +566,7 @@ public class StoredProcedureTests { } public void execute() { - execute(new HashMap()); + execute(new HashMap<>()); } public int getCount() { @@ -593,7 +593,7 @@ public class StoredProcedureTests { } public Map execute() { - return execute(new HashMap()); + return execute(new HashMap<>()); } private static class RowMapperImpl implements RowMapper { @@ -628,7 +628,7 @@ public class StoredProcedureTests { @Override public Map createMap(Connection con) throws SQLException { - Map inParms = new HashMap(); + Map inParms = new HashMap<>(); String testValue = con.toString(); inParms.put("in", testValue); return inParms; @@ -649,7 +649,7 @@ public class StoredProcedureTests { } public Map executeTest(final int[] inValue) { - Map in = new HashMap(); + Map in = new HashMap<>(); in.put("in", new AbstractSqlTypeValue() { @Override public Object createTypeValue(Connection con, int type, String typeName) { @@ -675,7 +675,7 @@ public class StoredProcedureTests { } public Map executeTest() { - return execute(new HashMap()); + return execute(new HashMap<>()); } } @@ -699,7 +699,7 @@ public class StoredProcedureTests { } public void execute() { - execute(new HashMap()); + execute(new HashMap<>()); } } diff --git a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java index af540e59a7b..26bf2cf041e 100644 --- a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java +++ b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistrar.java @@ -49,7 +49,7 @@ public class JmsListenerEndpointRegistrar implements BeanFactoryAware, Initializ private BeanFactory beanFactory; private final List endpointDescriptors = - new ArrayList(); + new ArrayList<>(); private boolean startImmediately; diff --git a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistry.java b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistry.java index 4d48fb31fed..f6d798c8dd3 100644 --- a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistry.java +++ b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerEndpointRegistry.java @@ -63,7 +63,7 @@ public class JmsListenerEndpointRegistry implements DisposableBean, SmartLifecyc protected final Log logger = LogFactory.getLog(getClass()); private final Map listenerContainers = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); private int phase = Integer.MAX_VALUE; diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java index 14eb99ff3d8..bc2aa5c050a 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java @@ -96,7 +96,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory { private volatile boolean active = true; private final Map> cachedSessions = - new HashMap>(); + new HashMap<>(); /** @@ -216,7 +216,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory { synchronized (this.cachedSessions) { sessionList = this.cachedSessions.get(mode); if (sessionList == null) { - sessionList = new LinkedList(); + sessionList = new LinkedList<>(); this.cachedSessions.put(mode, sessionList); } } @@ -251,7 +251,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory { * @return the wrapped Session */ protected Session getCachedSessionProxy(Session target, LinkedList sessionList) { - List> classes = new ArrayList>(3); + List> classes = new ArrayList<>(3); classes.add(SessionProxy.class); if (target instanceof QueueSession) { classes.add(QueueSession.class); @@ -276,10 +276,10 @@ public class CachingConnectionFactory extends SingleConnectionFactory { private final LinkedList sessionList; private final Map cachedProducers = - new HashMap(); + new HashMap<>(); private final Map cachedConsumers = - new HashMap(); + new HashMap<>(); private boolean transactionOpen = false; diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/ChainedExceptionListener.java b/spring-jms/src/main/java/org/springframework/jms/connection/ChainedExceptionListener.java index 4ca40d842cc..19d29cfbdfc 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/ChainedExceptionListener.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/ChainedExceptionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.util.Assert; public class ChainedExceptionListener implements ExceptionListener { /** List of ExceptionListeners */ - private final List delegates = new ArrayList(2); + private final List delegates = new ArrayList<>(2); /** diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java b/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java index 98c4b60a5e9..b97a8a26dad 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,12 +56,12 @@ public class JmsResourceHolder extends ResourceHolderSupport { private boolean frozen = false; - private final List connections = new LinkedList(); + private final List connections = new LinkedList<>(); - private final List sessions = new LinkedList(); + private final List sessions = new LinkedList<>(); private final Map> sessionsPerConnection = - new HashMap>(); + new HashMap<>(); /** @@ -140,7 +140,7 @@ public class JmsResourceHolder extends ResourceHolderSupport { if (connection != null) { List sessions = this.sessionsPerConnection.get(connection); if (sessions == null) { - sessions = new LinkedList(); + sessions = new LinkedList<>(); this.sessionsPerConnection.put(connection, sessions); } sessions.add(session); diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java index 05c28ae6efb..a780a0363ea 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -473,7 +473,7 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti * @return the wrapped Connection */ protected Connection getSharedConnectionProxy(Connection target) { - List> classes = new ArrayList>(3); + List> classes = new ArrayList<>(3); classes.add(Connection.class); if (target instanceof QueueConnection) { classes.add(QueueConnection.class); @@ -662,14 +662,14 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti */ private class AggregatedExceptionListener implements ExceptionListener { - final Set delegates = new LinkedHashSet(2); + final Set delegates = new LinkedHashSet<>(2); @Override public void onException(JMSException ex) { synchronized (connectionMonitor) { // Iterate over temporary copy in order to avoid ConcurrentModificationException, // since listener invocations may in turn trigger registration of listeners... - for (ExceptionListener listener : new LinkedHashSet(this.delegates)) { + for (ExceptionListener listener : new LinkedHashSet<>(this.delegates)) { listener.onException(ex); } } diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java b/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java index 50c61409252..b2b07689685 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -196,7 +196,7 @@ public class TransactionAwareConnectionFactoryProxy * @return the wrapped Connection */ protected Connection getTransactionAwareConnectionProxy(Connection target) { - List> classes = new ArrayList>(3); + List> classes = new ArrayList<>(3); classes.add(Connection.class); if (target instanceof QueueConnection) { classes.add(QueueConnection.class); @@ -268,7 +268,7 @@ public class TransactionAwareConnectionFactoryProxy } private Session getCloseSuppressingSessionProxy(Session target) { - List> classes = new ArrayList>(3); + List> classes = new ArrayList<>(3); classes.add(SessionProxy.class); if (target instanceof QueueSession) { classes.add(QueueSession.class); diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java b/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java index 3e912ea0a69..bc5f1e69e83 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ public class UserCredentialsConnectionFactoryAdapter private String password; private final ThreadLocal threadBoundCredentials = - new NamedThreadLocal("Current JMS user credentials"); + new NamedThreadLocal<>("Current JMS user credentials"); /** diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java index 0de5f39a8db..6083cdaa343 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java @@ -78,7 +78,7 @@ public abstract class AbstractJmsListeningContainer extends JmsDestinationAccess private boolean running = false; - private final List pausedTasks = new LinkedList(); + private final List pausedTasks = new LinkedList<>(); protected final Object lifecycleMonitor = new Object(); diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java index f9f6479fc21..09695dcd261 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java @@ -189,7 +189,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe private int idleTaskExecutionLimit = 1; - private final Set scheduledInvokers = new HashSet(); + private final Set scheduledInvokers = new HashSet<>(); private int activeInvokerCount = 0; diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java b/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java index c784eb5a12f..dd70e1ad181 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -258,8 +258,8 @@ public class SimpleMessageListenerContainer extends AbstractMessageListenerConta // Register Sessions and MessageConsumers. synchronized (this.consumersMonitor) { if (this.consumers == null) { - this.sessions = new HashSet(this.concurrentConsumers); - this.consumers = new HashSet(this.concurrentConsumers); + this.sessions = new HashSet<>(this.concurrentConsumers); + this.consumers = new HashSet<>(this.concurrentConsumers); Connection con = getSharedConnection(); for (int i = 0; i < this.concurrentConsumers; i++) { Session session = createSession(con); diff --git a/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java b/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java index 0ba0e326d74..02f45670ed5 100644 --- a/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java +++ b/spring-jms/src/main/java/org/springframework/jms/listener/adapter/JmsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,7 +111,7 @@ public class JmsResponse { */ public static JmsResponse forQueue(T result, String queueName) { Assert.notNull(queueName, "Queue name must not be null"); - return new JmsResponse(result, new DestinationNameHolder(queueName, false)); + return new JmsResponse<>(result, new DestinationNameHolder(queueName, false)); } /** @@ -119,7 +119,7 @@ public class JmsResponse { */ public static JmsResponse forTopic(T result, String topicName) { Assert.notNull(topicName, "Topic name must not be null"); - return new JmsResponse(result, new DestinationNameHolder(topicName, true)); + return new JmsResponse<>(result, new DestinationNameHolder(topicName, true)); } /** @@ -127,7 +127,7 @@ public class JmsResponse { */ public static JmsResponse forDestination(T result, Destination destination) { Assert.notNull(destination, "Destination must not be null"); - return new JmsResponse(result, destination); + return new JmsResponse<>(result, destination); } diff --git a/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java b/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java index 2cb4e3c47a0..e752f4ea053 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ import org.springframework.util.StringUtils; */ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper implements JmsHeaderMapper { - private static Set> SUPPORTED_PROPERTY_TYPES = new HashSet>(Arrays.asList(new Class[] { + private static Set> SUPPORTED_PROPERTY_TYPES = new HashSet<>(Arrays.asList(new Class[] { Boolean.class, Byte.class, Double.class, Float.class, Integer.class, Long.class, Short.class, String.class})); @@ -124,7 +124,7 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper impleme @Override public MessageHeaders toHeaders(javax.jms.Message jmsMessage) { - Map headers = new HashMap(); + Map headers = new HashMap<>(); try { try { String correlationId = jmsMessage.getJMSCorrelationID(); diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java index 2565773a5f6..dc18cf29555 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java @@ -79,9 +79,9 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B private String typeIdPropertyName; - private Map> idClassMappings = new HashMap>(); + private Map> idClassMappings = new HashMap<>(); - private Map, String> classIdMappings = new HashMap, String>(); + private Map, String> classIdMappings = new HashMap<>(); private ClassLoader beanClassLoader; @@ -156,7 +156,7 @@ public class MappingJackson2MessageConverter implements SmartMessageConverter, B * @param typeIdMappings a Map with type id values as keys and Java classes as values */ public void setTypeIdMappings(Map> typeIdMappings) { - this.idClassMappings = new HashMap>(); + this.idClassMappings = new HashMap<>(); for (Map.Entry> entry : typeIdMappings.entrySet()) { String id = entry.getKey(); Class clazz = entry.getValue(); diff --git a/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java b/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java index b64ae749d10..18dabab78ba 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -199,7 +199,7 @@ public class SimpleMessageConverter implements MessageConverter { */ @SuppressWarnings("unchecked") protected Map extractMapFromMessage(MapMessage message) throws JMSException { - Map map = new HashMap(); + Map map = new HashMap<>(); Enumeration en = message.getMapNames(); while (en.hasMoreElements()) { String key = en.nextElement(); diff --git a/spring-jms/src/main/java/org/springframework/jms/support/destination/JndiDestinationResolver.java b/spring-jms/src/main/java/org/springframework/jms/support/destination/JndiDestinationResolver.java index ccd7c141661..2a5baa6bcbc 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/destination/JndiDestinationResolver.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/destination/JndiDestinationResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class JndiDestinationResolver extends JndiLocatorSupport implements Cachi private DestinationResolver dynamicDestinationResolver = new DynamicDestinationResolver(); - private final Map destinationCache = new ConcurrentHashMap(16); + private final Map destinationCache = new ConcurrentHashMap<>(16); /** diff --git a/spring-jms/src/test/java/org/springframework/jms/StubTextMessage.java b/spring-jms/src/test/java/org/springframework/jms/StubTextMessage.java index b2341406f04..58bd47a288b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/StubTextMessage.java +++ b/spring-jms/src/test/java/org/springframework/jms/StubTextMessage.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class StubTextMessage implements TextMessage { private boolean redelivered; - private ConcurrentHashMap properties = new ConcurrentHashMap(); + private ConcurrentHashMap properties = new ConcurrentHashMap<>(); public StubTextMessage() { diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java index dcfceb82659..0d851939d91 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java @@ -164,7 +164,7 @@ public class JmsListenerContainerFactoryIntegrationTests { static class JmsEndpointSampleBean implements JmsEndpointSampleInterface { - private final Map invocations = new HashMap(); + private final Map invocations = new HashMap<>(); public void handleIt(@Payload String msg, @Header("my-header") String myHeader) { invocations.put("handleIt", true); diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java index 26610dc0cb3..72c091d120f 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -402,7 +402,7 @@ public class JmsNamespaceHandlerTests { @Override protected void initBeanDefinitionReader(XmlBeanDefinitionReader beanDefinitionReader) { - this.registeredComponents = new HashSet(); + this.registeredComponents = new HashSet<>(); beanDefinitionReader.setEventListener(new StoringReaderEventListener(this.registeredComponents)); beanDefinitionReader.setSourceExtractor(new PassThroughSourceExtractor()); } diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java index 53c6f7bd8fc..19bcaacd81b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -208,7 +208,7 @@ public class JmsMessagingTemplateTests { @Test public void convertAndSendPayloadAndHeaders() throws JMSException { Destination destination = new Destination() {}; - Map headers = new HashMap(); + Map headers = new HashMap<>(); headers.put("foo", "bar"); messagingTemplate.convertAndSend(destination, "Hello", headers); @@ -218,7 +218,7 @@ public class JmsMessagingTemplateTests { @Test public void convertAndSendPayloadAndHeadersName() throws JMSException { - Map headers = new HashMap(); + Map headers = new HashMap<>(); headers.put("foo", "bar"); messagingTemplate.convertAndSend("myQueue", "Hello", headers); diff --git a/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java b/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java index d8d1f27a914..e3a33b29884 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class JmsGatewaySupportTests { @Test public void testJmsGatewaySupportWithConnectionFactory() throws Exception { ConnectionFactory mockConnectionFactory = mock(ConnectionFactory.class); - final List test = new ArrayList(1); + final List test = new ArrayList<>(1); JmsGatewaySupport gateway = new JmsGatewaySupport() { @Override protected void initGateway() { @@ -52,7 +52,7 @@ public class JmsGatewaySupportTests { @Test public void testJmsGatewaySupportWithJmsTemplate() throws Exception { JmsTemplate template = new JmsTemplate(); - final List test = new ArrayList(1); + final List test = new ArrayList<>(1); JmsGatewaySupport gateway = new JmsGatewaySupport() { @Override protected void initGateway() { diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java index 962c7e0bf95..fefd92cb5b3 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,7 +170,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener final ConnectionFactory connectionFactory = mock(ConnectionFactory.class); given(connectionFactory.createConnection()).willReturn(connection); - final Set failure = new HashSet(1); + final Set failure = new HashSet<>(1); this.container.setConnectionFactory(connectionFactory); this.container.setDestinationName(DESTINATION_NAME); diff --git a/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java index 91bafe01752..e04bc3b799f 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java @@ -92,7 +92,7 @@ public class SimpleMessageConverterTests { Session session = mock(Session.class); MapMessage message = mock(MapMessage.class); - Map content = new HashMap(2); + Map content = new HashMap<>(2); content.put("key1", "value1"); content.put("key2", "value2"); @@ -159,7 +159,7 @@ public class SimpleMessageConverterTests { Session session = mock(Session.class); given(session.createMapMessage()).willReturn(message); - Map content = new HashMap(1); + Map content = new HashMap<>(1); content.put(1, "value1"); SimpleMessageConverter converter = new SimpleMessageConverter(); @@ -176,7 +176,7 @@ public class SimpleMessageConverterTests { Session session = mock(Session.class); given(session.createMapMessage()).willReturn(message); - Map content = new HashMap(1); + Map content = new HashMap<>(1); content.put(null, "value1"); SimpleMessageConverter converter = new SimpleMessageConverter(); diff --git a/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java index fcf8ed16b17..e98fefdeddf 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java @@ -117,7 +117,7 @@ public class MappingJackson2MessageConverterTests { public void toTextMessageWithMap() throws Exception { converter.setTargetType(MessageType.TEXT); TextMessage textMessageMock = mock(TextMessage.class); - Map toBeMarshalled = new HashMap(); + Map toBeMarshalled = new HashMap<>(); toBeMarshalled.put("foo", "bar"); given(sessionMock.createTextMessage(isA(String.class))).willReturn(textMessageMock); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java b/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java index 85697ea437f..dfce6979041 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,7 +117,7 @@ public class MessageHeaders implements Map, Serializable { * @param timestamp the {@link #TIMESTAMP} header value */ protected MessageHeaders(Map headers, UUID id, Long timestamp) { - this.headers = (headers != null ? new HashMap(headers) : new HashMap()); + this.headers = (headers != null ? new HashMap<>(headers) : new HashMap()); if (id == null) { this.headers.put(ID, getIdGenerator().generateId()); @@ -147,7 +147,7 @@ public class MessageHeaders implements Map, Serializable { * @param keysToIgnore the keys of the entries to ignore */ private MessageHeaders(MessageHeaders original, Set keysToIgnore) { - this.headers = new HashMap(original.headers.size() - keysToIgnore.size()); + this.headers = new HashMap<>(original.headers.size() - keysToIgnore.size()); for (Map.Entry entry : original.headers.entrySet()) { if (!keysToIgnore.contains(entry.getKey())) { this.headers.put(entry.getKey(), entry.getValue()); @@ -268,7 +268,7 @@ public class MessageHeaders implements Map, Serializable { // Serialization methods private void writeObject(ObjectOutputStream out) throws IOException { - Set keysToIgnore = new HashSet(); + Set keysToIgnore = new HashSet<>(); for (Map.Entry entry : this.headers.entrySet()) { if (!(entry.getValue() instanceof Serializable)) { keysToIgnore.add(entry.getKey()); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java index c12af1b6f0b..9f30bcbe48b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/AbstractMessageConverter.java @@ -70,7 +70,7 @@ public abstract class AbstractMessageConverter implements SmartMessageConverter */ protected AbstractMessageConverter(Collection supportedMimeTypes) { Assert.notNull(supportedMimeTypes, "supportedMimeTypes must not be null"); - this.supportedMimeTypes = new ArrayList(supportedMimeTypes); + this.supportedMimeTypes = new ArrayList<>(supportedMimeTypes); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/CompositeMessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/CompositeMessageConverter.java index ee393759311..f9d324bcdd2 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/CompositeMessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/CompositeMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public class CompositeMessageConverter implements SmartMessageConverter { */ public CompositeMessageConverter(Collection converters) { Assert.notEmpty(converters, "Converters must not be empty"); - this.converters = new ArrayList(converters); + this.converters = new ArrayList<>(converters); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java b/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java index 490b6f6a915..0311f675af5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java @@ -145,7 +145,7 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter { if (!logger.isWarnEnabled()) { return this.objectMapper.canDeserialize(javaType); } - AtomicReference causeRef = new AtomicReference(); + AtomicReference causeRef = new AtomicReference<>(); if (this.objectMapper.canDeserialize(javaType, causeRef)) { return true; } @@ -161,7 +161,7 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter { if (!logger.isWarnEnabled()) { return this.objectMapper.canSerialize(payload.getClass()); } - AtomicReference causeRef = new AtomicReference(); + AtomicReference causeRef = new AtomicReference<>(); if (this.objectMapper.canSerialize(payload.getClass(), causeRef)) { return true; } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java b/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java index eef37572788..d163041499b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/core/CachingDestinationResolverProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import org.springframework.util.Assert; */ public class CachingDestinationResolverProxy implements DestinationResolver, InitializingBean { - private final Map resolvedDestinationCache = new ConcurrentHashMap(); + private final Map resolvedDestinationCache = new ConcurrentHashMap<>(); private DestinationResolver targetDestinationResolver; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java index 058f05a44e8..69c4f7e5287 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public class DestinationPatternsMessageCondition extends AbstractMessageConditio return Collections.emptySet(); } boolean slashSeparator = pathMatcher.combine("a", "a").equals("a/a"); - Set result = new LinkedHashSet(patterns.size()); + Set result = new LinkedHashSet<>(patterns.size()); for (String pattern : patterns) { if (slashSeparator) { if (StringUtils.hasLength(pattern) && !pattern.startsWith("/")) { @@ -121,7 +121,7 @@ public class DestinationPatternsMessageCondition extends AbstractMessageConditio */ @Override public DestinationPatternsMessageCondition combine(DestinationPatternsMessageCondition other) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); if (!this.patterns.isEmpty() && !other.patterns.isEmpty()) { for (String pattern1 : this.patterns) { for (String pattern2 : other.patterns) { @@ -161,7 +161,7 @@ public class DestinationPatternsMessageCondition extends AbstractMessageConditio return this; } - List matches = new ArrayList(); + List matches = new ArrayList<>(); for (String pattern : this.patterns) { if (pattern.equals(destination) || this.pathMatcher.match(pattern, destination)) { matches.add(pattern); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java index dcf20f8381e..ea033b7ef50 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AbstractNamedValueMethodArgumentResolver.java @@ -64,7 +64,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle private final BeanExpressionContext expressionContext; private final Map namedValueInfoCache = - new ConcurrentHashMap(256); + new ConcurrentHashMap<>(256); /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java index 23e17872393..0f0df98cb1a 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolver.java @@ -57,10 +57,10 @@ public class AnnotationExceptionHandlerMethodResolver extends AbstractExceptionH } }); - Map, Method> result = new HashMap, Method>(); + Map, Method> result = new HashMap<>(); for (Map.Entry entry : methods.entrySet()) { Method method = entry.getKey(); - List> exceptionTypes = new ArrayList>(); + List> exceptionTypes = new ArrayList<>(); exceptionTypes.addAll(Arrays.asList(entry.getValue().value())); if (exceptionTypes.isEmpty()) { exceptionTypes.addAll(getExceptionsFromMethodSignature(method)); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java index 8d83f5eddf4..607b6ee7f29 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactory.java @@ -149,7 +149,7 @@ public class DefaultMessageHandlerMethodFactory implements MessageHandlerMethodF } protected List initArgumentResolvers() { - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); ConfigurableBeanFactory cbf = (this.beanFactory instanceof ConfigurableBeanFactory ? (ConfigurableBeanFactory) this.beanFactory : null); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java index a7f7cf9f560..723d7f25d94 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java @@ -40,9 +40,9 @@ public abstract class AbstractExceptionHandlerMethodResolver { private static final Method NO_METHOD_FOUND = ClassUtils.getMethodIfAvailable(System.class, "currentTimeMillis"); - private final Map, Method> mappedMethods = new ConcurrentHashMap, Method>(16); + private final Map, Method> mappedMethods = new ConcurrentHashMap<>(16); - private final Map, Method> exceptionLookupCache = new ConcurrentHashMap, Method>(16); + private final Map, Method> exceptionLookupCache = new ConcurrentHashMap<>(16); /** @@ -60,7 +60,7 @@ public abstract class AbstractExceptionHandlerMethodResolver { */ @SuppressWarnings("unchecked") protected static List> getExceptionsFromMethodSignature(Method method) { - List> result = new ArrayList>(); + List> result = new ArrayList<>(); for (Class paramType : method.getParameterTypes()) { if (Throwable.class.isAssignableFrom(paramType)) { result.add((Class) paramType); @@ -115,7 +115,7 @@ public abstract class AbstractExceptionHandlerMethodResolver { * Return the {@link Method} mapped to the given exception type, or {@code null} if none. */ private Method getMappedMethod(Class exceptionType) { - List> matches = new ArrayList>(); + List> matches = new ArrayList<>(); for (Class mappedException : this.mappedMethods.keySet()) { if (mappedException.isAssignableFrom(exceptionType)) { matches.add(mappedException); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java index 004d25ed119..fa923770d75 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractMethodMessageHandler.java @@ -83,13 +83,13 @@ public abstract class AbstractMethodMessageHandler protected final Log logger = LogFactory.getLog(getClass()); - private Collection destinationPrefixes = new ArrayList(); + private Collection destinationPrefixes = new ArrayList<>(); private final List customArgumentResolvers = - new ArrayList(4); + new ArrayList<>(4); private final List customReturnValueHandlers = - new ArrayList(4); + new ArrayList<>(4); private final HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite(); @@ -99,15 +99,15 @@ public abstract class AbstractMethodMessageHandler private ApplicationContext applicationContext; - private final Map handlerMethods = new LinkedHashMap(64); + private final Map handlerMethods = new LinkedHashMap<>(64); - private final MultiValueMap destinationLookup = new LinkedMultiValueMap(64); + private final MultiValueMap destinationLookup = new LinkedMultiValueMap<>(64); private final Map, AbstractExceptionHandlerMethodResolver> exceptionHandlerCache = - new ConcurrentHashMap, AbstractExceptionHandlerMethodResolver>(64); + new ConcurrentHashMap<>(64); private final Map exceptionHandlerAdviceCache = - new LinkedHashMap(64); + new LinkedHashMap<>(64); /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java index 6a0454dee2c..8fb0ff59c83 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/CompletableFutureReturnValueHandler.java @@ -38,7 +38,7 @@ public class CompletableFutureReturnValueHandler extends AbstractAsyncReturnValu @Override @SuppressWarnings("unchecked") public ListenableFuture toListenableFuture(Object returnValue, MethodParameter returnType) { - return new CompletableToListenableFutureAdapter((CompletableFuture) returnValue); + return new CompletableToListenableFutureAdapter<>((CompletableFuture) returnValue); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java index 1d55191f1f2..aacbd9492de 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodArgumentResolverComposite.java @@ -37,10 +37,10 @@ import org.springframework.util.Assert; */ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentResolver { - private final List argumentResolvers = new LinkedList(); + private final List argumentResolvers = new LinkedList<>(); private final Map argumentResolverCache = - new ConcurrentHashMap(256); + new ConcurrentHashMap<>(256); /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java index a09214e90fc..bc2d01d5bcb 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/HandlerMethodReturnValueHandlerComposite.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class HandlerMethodReturnValueHandlerComposite implements AsyncHandlerMet private static final Log logger = LogFactory.getLog(HandlerMethodReturnValueHandlerComposite.class); - private final List returnValueHandlers = new ArrayList(); + private final List returnValueHandlers = new ArrayList<>(); /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributesContextHolder.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributesContextHolder.java index b7136e96600..512641d2c71 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributesContextHolder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpAttributesContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import org.springframework.messaging.Message; public abstract class SimpAttributesContextHolder { private static final ThreadLocal attributesHolder = - new NamedThreadLocal("SiMP session attributes"); + new NamedThreadLocal<>("SiMP session attributes"); /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java index 0817a7362d9..83ef7bf4856 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandler.java @@ -129,7 +129,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan this.clientMessagingTemplate = new SimpMessagingTemplate(clientOutboundChannel); this.brokerTemplate = brokerTemplate; - Collection converters = new ArrayList(); + Collection converters = new ArrayList<>(); converters.add(new StringMessageConverter()); converters.add(new ByteArrayMessageConverter()); this.messageConverter = new CompositeMessageConverter(converters); @@ -154,7 +154,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan if (CollectionUtils.isEmpty(prefixes)) { return prefixes; } - Collection result = new ArrayList(prefixes.size()); + Collection result = new ArrayList<>(prefixes.size()); for (String prefix : prefixes) { if (!prefix.endsWith("/")) { prefix = prefix + "/"; @@ -303,7 +303,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan ConfigurableBeanFactory beanFactory = (getApplicationContext() instanceof ConfigurableApplicationContext ? ((ConfigurableApplicationContext) getApplicationContext()).getBeanFactory() : null); - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); // Annotation-based argument resolution resolvers.add(new HeaderMethodArgumentResolver(this.conversionService, beanFactory)); @@ -322,7 +322,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan @Override protected List initReturnValueHandlers() { - List handlers = new ArrayList(); + List handlers = new ArrayList<>(); // Single-purpose return value types handlers.add(new ListenableFutureReturnValueHandler()); @@ -419,7 +419,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan @Override protected Set getDirectLookupDestinations(SimpMessageMappingInfo mapping) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (String pattern : mapping.getDestinationConditions().getPatterns()) { if (!this.pathMatcher.isPattern(pattern)) { result.add(pattern); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java index 97afc43f908..e679a46a0f9 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -192,7 +192,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { return allMatches; } EvaluationContext context = null; - MultiValueMap result = new LinkedMultiValueMap(allMatches.size()); + MultiValueMap result = new LinkedMultiValueMap<>(allMatches.size()); for (String sessionId : allMatches.keySet()) { for (String subId : allMatches.get(sessionId)) { SessionSubscriptionInfo info = this.subscriptionRegistry.getSubscriptions(sessionId); @@ -244,7 +244,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { /** Map from destination -> for fast look-ups */ private final Map> accessCache = - new ConcurrentHashMap>(DEFAULT_CACHE_LIMIT); + new ConcurrentHashMap<>(DEFAULT_CACHE_LIMIT); /** Map from destination -> with locking */ @SuppressWarnings("serial") @@ -267,7 +267,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { LinkedMultiValueMap result = this.accessCache.get(destination); if (result == null) { synchronized (this.updateCache) { - result = new LinkedMultiValueMap(); + result = new LinkedMultiValueMap<>(); for (SessionSubscriptionInfo info : subscriptionRegistry.getAllSubscriptions()) { for (String destinationPattern : info.getDestinations()) { if (getPathMatcher().match(destinationPattern, destination)) { @@ -301,7 +301,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { public void updateAfterRemovedSubscription(String sessionId, String subsId) { synchronized (this.updateCache) { - Set destinationsToRemove = new HashSet(); + Set destinationsToRemove = new HashSet<>(); for (Map.Entry> entry : this.updateCache.entrySet()) { String destination = entry.getKey(); LinkedMultiValueMap sessionMap = entry.getValue(); @@ -328,7 +328,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { public void updateAfterRemovedSession(SessionSubscriptionInfo info) { synchronized (this.updateCache) { - Set destinationsToRemove = new HashSet(); + Set destinationsToRemove = new HashSet<>(); for (Map.Entry> entry : this.updateCache.entrySet()) { String destination = entry.getKey(); LinkedMultiValueMap sessionMap = entry.getValue(); @@ -362,7 +362,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { // sessionId -> SessionSubscriptionInfo private final ConcurrentMap sessions = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); public SessionSubscriptionInfo getSubscriptions(String sessionId) { return this.sessions.get(sessionId); @@ -407,7 +407,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { // destination -> subscriptions private final Map> destinationLookup = - new ConcurrentHashMap>(4); + new ConcurrentHashMap<>(4); public SessionSubscriptionInfo(String sessionId) { Assert.notNull(sessionId, "sessionId must not be null"); @@ -446,7 +446,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry { synchronized (this.destinationLookup) { subs = this.destinationLookup.get(destination); if (subs == null) { - subs = new CopyOnWriteArraySet(); + subs = new CopyOnWriteArraySet<>(); this.destinationLookup.put(destination, subs); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandler.java index b78ab54a0f9..2b763970808 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandler.java @@ -48,7 +48,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { private static final byte[] EMPTY_PAYLOAD = new byte[0]; - private final Map sessions = new ConcurrentHashMap(); + private final Map sessions = new ConcurrentHashMap<>(); private SubscriptionRegistry subscriptionRegistry; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java index ec76b47986f..fd166d91084 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/AbstractMessageBrokerConfiguration.java @@ -245,11 +245,11 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC handler.setMessageConverter(brokerMessageConverter()); handler.setValidator(simpValidator()); - List argumentResolvers = new ArrayList(); + List argumentResolvers = new ArrayList<>(); addArgumentResolvers(argumentResolvers); handler.setCustomArgumentResolvers(argumentResolvers); - List returnValueHandlers = new ArrayList(); + List returnValueHandlers = new ArrayList<>(); addReturnValueHandlers(returnValueHandlers); handler.setCustomReturnValueHandlers(returnValueHandlers); @@ -289,7 +289,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC if (handler == null) { return new NoOpBrokerMessageHandler(); } - Map subscriptions = new HashMap(1); + Map subscriptions = new HashMap<>(1); String destination = getBrokerRegistry().getUserDestinationBroadcast(); if (destination != null) { subscriptions.put(destination, userDestinationMessageHandler()); @@ -347,7 +347,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC @Bean public CompositeMessageConverter brokerMessageConverter() { - List converters = new ArrayList(); + List converters = new ArrayList<>(); boolean registerDefaults = configureMessageConverters(converters); if (registerDefaults) { converters.add(new StringMessageConverter()); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/ChannelRegistration.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/ChannelRegistration.java index 626e1e9820b..1bea244f167 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/config/ChannelRegistration.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/config/ChannelRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public class ChannelRegistration { private TaskExecutorRegistration registration; - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java index bf5218749da..569afaf8401 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/BufferingStompDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class BufferingStompDecoder { private final int bufferSizeLimit; - private final Queue chunks = new LinkedBlockingQueue(); + private final Queue chunks = new LinkedBlockingQueue<>(); private volatile Integer expectedContentLength; @@ -129,7 +129,7 @@ public class BufferingStompDecoder { ByteBuffer bufferToDecode = assembleChunksAndReset(); - MultiValueMap headers = new LinkedMultiValueMap(); + MultiValueMap headers = new LinkedMultiValueMap<>(); List> messages = this.stompDecoder.decode(bufferToDecode, headers); if (bufferToDecode.hasRemaining()) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java index 44cb5f8e7ae..0b6191c02fb 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/DefaultStompSession.java @@ -79,7 +79,7 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { private final StompHeaders connectHeaders; - private final SettableListenableFuture sessionFuture = new SettableListenableFuture(); + private final SettableListenableFuture sessionFuture = new SettableListenableFuture<>(); private MessageConverter converter = new SimpleMessageConverter(); @@ -96,11 +96,11 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { private final AtomicInteger subscriptionIndex = new AtomicInteger(); - private final Map subscriptions = new ConcurrentHashMap(4); + private final Map subscriptions = new ConcurrentHashMap<>(4); private final AtomicInteger receiptIndex = new AtomicInteger(); - private final Map receiptHandlers = new ConcurrentHashMap(4); + private final Map receiptHandlers = new ConcurrentHashMap<>(4); /* Whether the client is willfully closing the connection */ private volatile boolean closing = false; @@ -503,9 +503,9 @@ public class DefaultStompSession implements ConnectionHandlingStompSession { private final String receiptId; - private final List receiptCallbacks = new ArrayList(2); + private final List receiptCallbacks = new ArrayList<>(2); - private final List receiptLostCallbacks = new ArrayList(2); + private final List receiptLostCallbacks = new ArrayList<>(2); private ScheduledFuture future; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClient.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClient.java index 9fac4c6b658..cf34ae0e3e5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClient.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/Reactor2TcpStompClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class Reactor2TcpStompClient extends StompClientSupport { ConfigurationReader reader = new StompClientDispatcherConfigReader(); Environment environment = new Environment(reader).assignErrorJournal(); StompTcpClientSpecFactory factory = new StompTcpClientSpecFactory(environment, host, port); - this.tcpClient = new Reactor2TcpClient(factory); + this.tcpClient = new Reactor2TcpClient<>(factory); } /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java index f0383acc16b..3462ec5c782 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler private static final byte[] EMPTY_PAYLOAD = new byte[0]; - private static final ListenableFutureTask EMPTY_TASK = new ListenableFutureTask(new VoidCallable()); + private static final ListenableFutureTask EMPTY_TASK = new ListenableFutureTask<>(new VoidCallable()); // STOMP recommends error of margin for receiving heartbeats private static final long HEARTBEAT_MULTIPLIER = 3; @@ -122,14 +122,14 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler private String virtualHost; - private final Map systemSubscriptions = new HashMap(4); + private final Map systemSubscriptions = new HashMap<>(4); private TcpOperations tcpClient; private MessageHeaderInitializer headerInitializer; private final Map connectionHandlers = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); private final Stats stats = new Stats(); @@ -974,7 +974,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler private static class StompTcpClientFactory { public TcpOperations create(String relayHost, int relayPort, Reactor2StompCodec codec) { - return new Reactor2TcpClient(relayHost, relayPort, codec); + return new Reactor2TcpClient<>(relayHost, relayPort, codec); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompCommand.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompCommand.java index 5e5b2930907..94eb1383eab 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompCommand.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ public enum StompCommand { ERROR; - private static Map messageTypes = new HashMap(); + private static Map messageTypes = new HashMap<>(); static { messageTypes.put(StompCommand.CONNECT, SimpMessageType.CONNECT); messageTypes.put(StompCommand.STOMP, SimpMessageType.CONNECT); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java index 28a636a984a..142176c3f5a 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public class StompDecoder { * @throws StompConversionException raised in case of decoding issues */ public List> decode(ByteBuffer buffer, MultiValueMap partialMessageHeaders) { - List> messages = new ArrayList>(); + List> messages = new ArrayList<>(); while (buffer.hasRemaining()) { Message message = decodeMessage(buffer, partialMessageHeaders); if (message != null) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java index c6abad4581c..e917a922b2a 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,13 +105,13 @@ public class StompHeaders implements MultiValueMap, Serializable * Create a new instance to be populated with new header values. */ public StompHeaders() { - this(new LinkedMultiValueMap(4), false); + this(new LinkedMultiValueMap<>(4), false); } private StompHeaders(Map> headers, boolean readOnly) { Assert.notNull(headers, "'headers' must not be null"); if (readOnly) { - Map> map = new LinkedMultiValueMap(headers.size()); + Map> map = new LinkedMultiValueMap<>(headers.size()); for (Entry> entry : headers.entrySet()) { List values = Collections.unmodifiableList(entry.getValue()); map.put(entry.getKey(), values); @@ -394,7 +394,7 @@ public class StompHeaders implements MultiValueMap, Serializable public void add(String headerName, String headerValue) { List headerValues = headers.get(headerName); if (headerValues == null) { - headerValues = new LinkedList(); + headerValues = new LinkedList<>(); this.headers.put(headerName, headerValues); } headerValues.add(headerValue); @@ -410,7 +410,7 @@ public class StompHeaders implements MultiValueMap, Serializable */ @Override public void set(String headerName, String headerValue) { - List headerValues = new LinkedList(); + List headerValues = new LinkedList<>(); headerValues.add(headerValue); headers.put(headerName, headerValues); } @@ -424,7 +424,7 @@ public class StompHeaders implements MultiValueMap, Serializable @Override public Map toSingleValueMap() { - LinkedHashMap singleValueMap = new LinkedHashMap(this.headers.size()); + LinkedHashMap singleValueMap = new LinkedHashMap<>(this.headers.size()); for (Entry> entry : headers.entrySet()) { singleValueMap.put(entry.getKey(), entry.getValue().get(0)); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java index 67a77f0ab81..6c91b57b5a6 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java @@ -126,7 +126,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver { return null; } String user = parseResult.getUser(); - Set targetSet = new HashSet(); + Set targetSet = new HashSet<>(); for (String sessionId : parseResult.getSessionIds()) { String actualDestination = parseResult.getActualDestination(); String targetDestination = getTargetDestination(sourceDestination, actualDestination, sessionId, user); @@ -181,7 +181,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver { } else { Set sessions = user.getSessions(); - sessionIds = new HashSet(sessions.size()); + sessionIds = new HashSet<>(sessions.size()); for (SimpSession session : sessions) { sessionIds.add(session.getId()); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java index 144d7f6ca65..fd7caf72c05 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/MultiServerUserRegistry.java @@ -51,7 +51,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati private final SimpUserRegistry localRegistry; - private final Map remoteRegistries = new ConcurrentHashMap(); + private final Map remoteRegistries = new ConcurrentHashMap<>(); private final boolean delegateApplicationEvents; @@ -125,7 +125,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati @Override public Set getUsers() { // Prefer remote registries due to cross-server SessionLookup - Set result = new HashSet(); + Set result = new HashSet<>(); for (UserRegistrySnapshot registry : this.remoteRegistries.values()) { result.addAll(registry.getUserMap().values()); } @@ -135,7 +135,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati @Override public Set findSubscriptions(SimpSubscriptionMatcher matcher) { - Set result = new HashSet(); + Set result = new HashSet<>(); for (UserRegistrySnapshot registry : this.remoteRegistries.values()) { result.addAll(registry.findSubscriptions(matcher)); } @@ -201,7 +201,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati public UserRegistrySnapshot(String id, SimpUserRegistry registry) { this.id = id; Set users = registry.getUsers(); - this.users = new HashMap(users.size()); + this.users = new HashMap<>(users.size()); for (SimpUser user : users) { this.users.put(user.getName(), new TransferSimpUser(user)); } @@ -238,7 +238,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati public Set findSubscriptions(SimpSubscriptionMatcher matcher) { - Set result = new HashSet(); + Set result = new HashSet<>(); for (TransferSimpUser user : this.users.values()) { for (TransferSimpSession session : user.sessions) { for (SimpSubscription subscription : session.subscriptions) { @@ -279,7 +279,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati * Default constructor for JSON deserialization. */ public TransferSimpUser() { - this.sessions = new HashSet(1); + this.sessions = new HashSet<>(1); } /** @@ -288,7 +288,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati public TransferSimpUser(SimpUser user) { this.name = user.getName(); Set sessions = user.getSessions(); - this.sessions = new HashSet(sessions.size()); + this.sessions = new HashSet<>(sessions.size()); for (SimpSession session : sessions) { this.sessions.add(new TransferSimpSession(session)); } @@ -333,9 +333,9 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati public Set getSessions() { if (this.sessionLookup != null) { Map sessions = this.sessionLookup.findSessions(getName()); - return new HashSet(sessions.values()); + return new HashSet<>(sessions.values()); } - return new HashSet(this.sessions); + return new HashSet<>(this.sessions); } private void afterDeserialization(SessionLookup sessionLookup) { @@ -386,7 +386,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati * Default constructor for JSON deserialization. */ public TransferSimpSession() { - this.subscriptions = new HashSet(4); + this.subscriptions = new HashSet<>(4); } /** @@ -395,7 +395,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati public TransferSimpSession(SimpSession session) { this.id = session.getId(); Set subscriptions = session.getSubscriptions(); - this.subscriptions = new HashSet(subscriptions.size()); + this.subscriptions = new HashSet<>(subscriptions.size()); for (SimpSubscription subscription : subscriptions) { this.subscriptions.add(new TransferSimpSubscription(subscription)); } @@ -425,7 +425,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati @Override public Set getSubscriptions() { - return new HashSet(this.subscriptions); + return new HashSet<>(this.subscriptions); } private void afterDeserialization() { @@ -536,7 +536,7 @@ public class MultiServerUserRegistry implements SimpUserRegistry, SmartApplicati private class SessionLookup { public Map findSessions(String userName) { - Map map = new HashMap(1); + Map map = new HashMap<>(1); SimpUser user = localRegistry.getUser(userName); if (user != null) { for (SimpSession session : user.getSessions()) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java index 37825c7674b..0f48b50fe48 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractMessageChannel.java @@ -41,7 +41,7 @@ public abstract class AbstractMessageChannel implements MessageChannel, Intercep protected final Log logger = LogFactory.getLog(getClass()); - private final List interceptors = new ArrayList(5); + private final List interceptors = new ArrayList<>(5); private String beanName; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractSubscribableChannel.java b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractSubscribableChannel.java index 9145f224c82..cc76c56d30b 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractSubscribableChannel.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/AbstractSubscribableChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.messaging.SubscribableChannel; */ public abstract class AbstractSubscribableChannel extends AbstractMessageChannel implements SubscribableChannel { - private final Set handlers = new CopyOnWriteArraySet(); + private final Set handlers = new CopyOnWriteArraySet<>(); public Set getSubscribers() { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/ExecutorSubscribableChannel.java b/spring-messaging/src/main/java/org/springframework/messaging/support/ExecutorSubscribableChannel.java index 45acbbf03fc..75db9919896 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/ExecutorSubscribableChannel.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/ExecutorSubscribableChannel.java @@ -37,7 +37,7 @@ public class ExecutorSubscribableChannel extends AbstractSubscribableChannel { private final Executor executor; - private final List executorInterceptors = new ArrayList(4); + private final List executorInterceptors = new ArrayList<>(4); /** diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java index 22cc4bec713..c198748eef8 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,7 +153,7 @@ public final class MessageBuilder { return (Message) new ErrorMessage((Throwable) this.payload, headersToUse); } else { - return new GenericMessage(this.payload, headersToUse); + return new GenericMessage<>(this.payload, headersToUse); } } @@ -165,7 +165,7 @@ public final class MessageBuilder { * @param message the Message from which the payload and all headers will be copied */ public static MessageBuilder fromMessage(Message message) { - return new MessageBuilder(message); + return new MessageBuilder<>(message); } /** @@ -173,7 +173,7 @@ public final class MessageBuilder { * @param payload the payload */ public static MessageBuilder withPayload(T payload) { - return new MessageBuilder(payload, new MessageHeaderAccessor()); + return new MessageBuilder<>(payload, new MessageHeaderAccessor()); } /** @@ -194,7 +194,7 @@ public final class MessageBuilder { return (Message) new ErrorMessage((Throwable) payload, messageHeaders); } else { - return new GenericMessage(payload, messageHeaders); + return new GenericMessage<>(payload, messageHeaders); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java index 4c3141c42b2..484ab28f967 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -282,7 +282,7 @@ public class MessageHeaderAccessor { * where each new call returns a fresh copy of the current header values. */ public Map toMap() { - return new HashMap(this.headers); + return new HashMap<>(this.headers); } @@ -354,7 +354,7 @@ public class MessageHeaderAccessor { * names. Supported pattern styles are: "xxx*", "*xxx", "*xxx*" and "xxx*yyy". */ public void removeHeaders(String... headerPatterns) { - List headersToRemove = new ArrayList(); + List headersToRemove = new ArrayList<>(); for (String pattern : headerPatterns) { if (StringUtils.hasLength(pattern)){ if (pattern.contains("*")){ @@ -371,7 +371,7 @@ public class MessageHeaderAccessor { } private List getMatchingHeaderNames(String pattern, Map headers) { - List matchingHeaderNames = new ArrayList(); + List matchingHeaderNames = new ArrayList<>(); if (headers != null) { for (String key : headers.keySet()) { if (PatternMatchUtils.simpleMatch(pattern, key)) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java index b6ea5aa77c9..ca0c164eed4 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/NativeMessageHeaderAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { */ protected NativeMessageHeaderAccessor(Map> nativeHeaders) { if (!CollectionUtils.isEmpty(nativeHeaders)) { - setHeader(NATIVE_HEADERS, new LinkedMultiValueMap(nativeHeaders)); + setHeader(NATIVE_HEADERS, new LinkedMultiValueMap<>(nativeHeaders)); } } @@ -79,7 +79,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { if (map != null) { // Force removal since setHeader checks for equality removeHeader(NATIVE_HEADERS); - setHeader(NATIVE_HEADERS, new LinkedMultiValueMap(map)); + setHeader(NATIVE_HEADERS, new LinkedMultiValueMap<>(map)); } } } @@ -94,7 +94,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { */ public Map> toNativeHeaderMap() { Map> map = getNativeHeaders(); - return (map != null ? new LinkedMultiValueMap(map) : Collections.>emptyMap()); + return (map != null ? new LinkedMultiValueMap<>(map) : Collections.>emptyMap()); } @Override @@ -154,10 +154,10 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { return; } if (map == null) { - map = new LinkedMultiValueMap(4); + map = new LinkedMultiValueMap<>(4); setHeader(NATIVE_HEADERS, map); } - List values = new LinkedList(); + List values = new LinkedList<>(); values.add(value); if (!ObjectUtils.nullSafeEquals(values, getHeader(name))) { setModified(true); @@ -175,12 +175,12 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor { } Map> nativeHeaders = getNativeHeaders(); if (nativeHeaders == null) { - nativeHeaders = new LinkedMultiValueMap(4); + nativeHeaders = new LinkedMultiValueMap<>(4); setHeader(NATIVE_HEADERS, nativeHeaders); } List values = nativeHeaders.get(name); if (values == null) { - values = new LinkedList(); + values = new LinkedList<>(); nativeHeaders.put(name, values); } values.add(value); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/AbstractPromiseToListenableFutureAdapter.java b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/AbstractPromiseToListenableFutureAdapter.java index 633bd801799..7e4a77ad343 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/AbstractPromiseToListenableFutureAdapter.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/AbstractPromiseToListenableFutureAdapter.java @@ -43,7 +43,7 @@ abstract class AbstractPromiseToListenableFutureAdapter implements Listena private final Promise promise; - private final ListenableFutureCallbackRegistry registry = new ListenableFutureCallbackRegistry(); + private final ListenableFutureCallbackRegistry registry = new ListenableFutureCallbackRegistry<>(); protected AbstractPromiseToListenableFutureAdapter(Promise promise) { diff --git a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java index 71541dcd79b..3dda2c8c187 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ public class Reactor2TcpClient

implements TcpOperations

{ private final TcpClientFactory, Message

> tcpClientSpecFactory; private final List, Message

>> tcpClients = - new ArrayList, Message

>>(); + new ArrayList<>(); private boolean stopping; @@ -173,7 +173,7 @@ public class Reactor2TcpClient

implements TcpOperations

{ if (this.stopping) { IllegalStateException ex = new IllegalStateException("Shutting down."); connectionHandler.afterConnectFailure(ex); - return new PassThroughPromiseToListenableFutureAdapter(Promises.error(ex)); + return new PassThroughPromiseToListenableFutureAdapter<>(Promises.error(ex)); } tcpClient = NetStreams.tcpClient(REACTOR_TCP_CLIENT_TYPE, this.tcpClientSpecFactory); this.tcpClients.add(tcpClient); @@ -188,9 +188,9 @@ public class Reactor2TcpClient

implements TcpOperations

{ } Promise promise = tcpClient.start( - new MessageChannelStreamHandler

(connectionHandler, cleanupTask)); + new MessageChannelStreamHandler<>(connectionHandler, cleanupTask)); - return new PassThroughPromiseToListenableFutureAdapter( + return new PassThroughPromiseToListenableFutureAdapter<>( promise.onError(new Consumer() { @Override public void accept(Throwable ex) { @@ -212,7 +212,7 @@ public class Reactor2TcpClient

implements TcpOperations

{ if (this.stopping) { IllegalStateException ex = new IllegalStateException("Shutting down."); connectionHandler.afterConnectFailure(ex); - return new PassThroughPromiseToListenableFutureAdapter(Promises.error(ex)); + return new PassThroughPromiseToListenableFutureAdapter<>(Promises.error(ex)); } tcpClient = NetStreams.tcpClient(REACTOR_TCP_CLIENT_TYPE, this.tcpClientSpecFactory); this.tcpClients.add(tcpClient); @@ -227,10 +227,10 @@ public class Reactor2TcpClient

implements TcpOperations

{ } Stream> stream = tcpClient.start( - new MessageChannelStreamHandler

(connectionHandler, cleanupTask), + new MessageChannelStreamHandler<>(connectionHandler, cleanupTask), new ReactorReconnectAdapter(strategy)); - return new PassThroughPromiseToListenableFutureAdapter(stream.next().after()); + return new PassThroughPromiseToListenableFutureAdapter<>(stream.next().after()); } @Override @@ -283,7 +283,7 @@ public class Reactor2TcpClient

implements TcpOperations

{ }); } - return new PassThroughPromiseToListenableFutureAdapter(promise); + return new PassThroughPromiseToListenableFutureAdapter<>(promise); } @@ -322,7 +322,7 @@ public class Reactor2TcpClient

implements TcpOperations

{ @Override public Publisher apply(ChannelStream, Message

> channelStream) { Promise closePromise = Promises.prepare(); - this.connectionHandler.afterConnected(new Reactor2TcpConnection

(channelStream, closePromise)); + this.connectionHandler.afterConnected(new Reactor2TcpConnection<>(channelStream, closePromise)); channelStream .finallyDo(new Consumer>>() { @Override diff --git a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpConnection.java b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpConnection.java index 6770aabf97f..582a0c37e97 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpConnection.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/tcp/reactor/Reactor2TcpConnection.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class Reactor2TcpConnection

implements TcpConnection

{ public ListenableFuture send(Message

message) { Promise afterWrite = Promises.prepare(); this.channelStream.writeWith(Streams.just(message)).subscribe(afterWrite); - return new PassThroughPromiseToListenableFutureAdapter(afterWrite); + return new PassThroughPromiseToListenableFutureAdapter<>(afterWrite); } @Override diff --git a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java index cd25691b43e..05d399fecac 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -107,7 +107,7 @@ public class MessageHeadersTests { @Test public void testNonTypedAccessOfHeaderValue() { Integer value = new Integer(123); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("test", value); MessageHeaders headers = new MessageHeaders(map); assertEquals(value, headers.get("test")); @@ -116,7 +116,7 @@ public class MessageHeadersTests { @Test public void testTypedAccessOfHeaderValue() { Integer value = new Integer(123); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("test", value); MessageHeaders headers = new MessageHeaders(map); assertEquals(value, headers.get("test", Integer.class)); @@ -125,7 +125,7 @@ public class MessageHeadersTests { @Test(expected = IllegalArgumentException.class) public void testHeaderValueAccessWithIncorrectType() { Integer value = new Integer(123); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("test", value); MessageHeaders headers = new MessageHeaders(map); assertEquals(value, headers.get("test", String.class)); @@ -133,21 +133,21 @@ public class MessageHeadersTests { @Test public void testNullHeaderValue() { - Map map = new HashMap(); + Map map = new HashMap<>(); MessageHeaders headers = new MessageHeaders(map); assertNull(headers.get("nosuchattribute")); } @Test public void testNullHeaderValueWithTypedAccess() { - Map map = new HashMap(); + Map map = new HashMap<>(); MessageHeaders headers = new MessageHeaders(map); assertNull(headers.get("nosuchattribute", String.class)); } @Test public void testHeaderKeys() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key1", "val1"); map.put("key2", new Integer(123)); MessageHeaders headers = new MessageHeaders(map); @@ -158,7 +158,7 @@ public class MessageHeadersTests { @Test public void serializeWithAllSerializableHeaders() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("name", "joe"); map.put("age", 42); MessageHeaders input = new MessageHeaders(map); @@ -172,7 +172,7 @@ public class MessageHeadersTests { @Test public void serializeWithNonSerializableHeader() throws Exception { Object address = new Object(); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("name", "joe"); map.put("address", address); MessageHeaders input = new MessageHeaders(map); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java index 0d683921481..3e9b38e1f28 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class DefaultContentTypeResolverTests { @Test public void resolve() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON); MessageHeaders headers = new MessageHeaders(map); @@ -55,7 +55,7 @@ public class DefaultContentTypeResolverTests { @Test public void resolveStringContentType() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON_VALUE); MessageHeaders headers = new MessageHeaders(map); @@ -64,7 +64,7 @@ public class DefaultContentTypeResolverTests { @Test(expected = InvalidMimeTypeException.class) public void resolveInvalidStringContentType() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put(MessageHeaders.CONTENT_TYPE, "invalidContentType"); MessageHeaders headers = new MessageHeaders(map); this.resolver.resolve(headers); @@ -72,7 +72,7 @@ public class DefaultContentTypeResolverTests { @Test(expected = IllegalArgumentException.class) public void resolveUnknownHeaderType() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put(MessageHeaders.CONTENT_TYPE, new Integer(1)); MessageHeaders headers = new MessageHeaders(map); this.resolver.resolve(headers); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java index 3bc508b875a..df866cd7f39 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java @@ -106,7 +106,7 @@ public class MessageConverterTests { @Test public void toMessageWithHeaders() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo", "bar"); MessageHeaders headers = new MessageHeaders(map); Message message = this.converter.toMessage("ABC", headers); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java index 618303912e0..2dde6b78172 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ public class StringMessageConverterTests { @Test public void toMessage() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN); MessageHeaders headers = new MessageHeaders(map); Message message = this.converter.toMessage("ABC", headers); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java index 49648082708..7749f2e6754 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class CachingDestinationResolverTests { public void cachedDestination() { @SuppressWarnings("unchecked") DestinationResolver destinationResolver = mock(DestinationResolver.class); - CachingDestinationResolverProxy cachingDestinationResolver = new CachingDestinationResolverProxy(destinationResolver); + CachingDestinationResolverProxy cachingDestinationResolver = new CachingDestinationResolverProxy<>(destinationResolver); given(destinationResolver.resolveDestination("abcd")).willReturn("dcba"); given(destinationResolver.resolveDestination("1234")).willReturn("4321"); @@ -49,7 +49,7 @@ public class CachingDestinationResolverTests { @Test(expected = IllegalArgumentException.class) public void noTargetSet() { - CachingDestinationResolverProxy cachingDestinationResolver = new CachingDestinationResolverProxy(); + CachingDestinationResolverProxy cachingDestinationResolver = new CachingDestinationResolverProxy<>(); cachingDestinationResolver.afterPropertiesSet(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java index 44baf9dc55b..b3128a3b885 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public class GenericMessagingTemplateTests { @Override public void handleMessage(Message message) throws MessagingException { MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel(); - replyChannel.send(new GenericMessage("response")); + replyChannel.send(new GenericMessage<>("response")); } }); @@ -83,7 +83,7 @@ public class GenericMessagingTemplateTests { @Test public void sendAndReceiveTimeout() throws InterruptedException { - final AtomicReference failure = new AtomicReference(); + final AtomicReference failure = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); this.template.setReceiveTimeout(1); @@ -96,7 +96,7 @@ public class GenericMessagingTemplateTests { try { Thread.sleep(500); MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel(); - replyChannel.send(new GenericMessage("response")); + replyChannel.send(new GenericMessage<>("response")); failure.set(new IllegalStateException("Expected exception")); } catch (InterruptedException e) { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java index 37b759abb94..18dd1859861 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,7 +114,7 @@ public class DefaultMessageHandlerMethodFactoryTests { @Test public void customArgumentResolver() throws Exception { DefaultMessageHandlerMethodFactory instance = createInstance(); - List customResolvers = new ArrayList(); + List customResolvers = new ArrayList<>(); customResolvers.add(new CustomHandlerMethodArgumentResolver()); instance.setCustomArgumentResolvers(customResolvers); instance.afterPropertiesSet(); @@ -129,7 +129,7 @@ public class DefaultMessageHandlerMethodFactoryTests { @Test public void overrideArgumentResolvers() throws Exception { DefaultMessageHandlerMethodFactory instance = createInstance(); - List customResolvers = new ArrayList(); + List customResolvers = new ArrayList<>(); customResolvers.add(new CustomHandlerMethodArgumentResolver()); instance.setArgumentResolvers(customResolvers); instance.afterPropertiesSet(); @@ -211,7 +211,7 @@ public class DefaultMessageHandlerMethodFactoryTests { static class SampleBean { - private final Map invocations = new HashMap(); + private final Map invocations = new HashMap<>(); public void simpleString(String value) { invocations.put("simpleString", true); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java index 012a1ee3fe6..a351e62656b 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ public class DestinationVariableMethodArgumentResolverTests { @Test public void resolveArgument() throws Exception { - Map vars = new HashMap(); + Map vars = new HashMap<>(); vars.put("foo", "bar"); vars.put("name", "value"); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java index 9fd9b6fe8e9..c312e2a26ac 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ public class HeadersMethodArgumentResolverTests { this.paramMessageHeaderAccessor = new MethodParameter(method, 3); this.paramMessageHeaderAccessorSubclass = new MethodParameter(method, 4); - Map headers = new HashMap(); + Map headers = new HashMap<>(); headers.put("foo", "bar"); this.message = MessageBuilder.withPayload(new byte[0]).copyHeaders(headers).build(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java index be385a7cc96..eb43dec917c 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,7 +142,7 @@ public class MethodMessageHandlerTests { public String method; - private Map arguments = new LinkedHashMap(); + private Map arguments = new LinkedHashMap<>(); public void handlerPathMatchWildcard() { this.method = "pathMatchWildcard"; @@ -196,7 +196,7 @@ public class MethodMessageHandlerTests { @Override protected List initArgumentResolvers() { - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); resolvers.add(new MessageMethodArgumentResolver(new SimpleMessageConverter())); resolvers.addAll(getCustomArgumentResolvers()); return resolvers; @@ -204,7 +204,7 @@ public class MethodMessageHandlerTests { @Override protected List initReturnValueHandlers() { - List handlers = new ArrayList(); + List handlers = new ArrayList<>(); handlers.addAll(getCustomReturnValueHandlers()); return handlers; } @@ -225,7 +225,7 @@ public class MethodMessageHandlerTests { @Override protected Set getDirectLookupDestinations(String mapping) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); if (!this.pathMatcher.isPattern(mapping)) { result.add(mapping); } @@ -273,7 +273,7 @@ public class MethodMessageHandlerTests { } private static Map, Method> initExceptionMappings(Class handlerType) { - Map, Method> result = new HashMap, Method>(); + Map, Method> result = new HashMap<>(); for (Method method : MethodIntrospector.selectMethods(handlerType, EXCEPTION_HANDLER_METHOD_FILTER)) { for (Class exception : getExceptionsFromMethodSignature(method)) { result.put(exception, method); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java index ac5bca021ae..8e03ac49c06 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -367,7 +367,7 @@ public class SimpAnnotationMethodMessageHandlerTests { private String method; - private Map arguments = new LinkedHashMap(); + private Map arguments = new LinkedHashMap<>(); @MessageMapping("/headers") public void headers(@Header String foo, @Headers Map headers) { @@ -462,13 +462,13 @@ public class SimpAnnotationMethodMessageHandlerTests { @MessageMapping("success") public ListenableFutureTask handleListenableFuture() { - this.future = new ListenableFutureTask(() -> "foo"); + this.future = new ListenableFutureTask<>(() -> "foo"); return this.future; } @MessageMapping("failure") public ListenableFutureTask handleListenableFutureException() { - this.future = new ListenableFutureTask(() -> { + this.future = new ListenableFutureTask<>(() -> { throw new IllegalStateException(); }); return this.future; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java index 9f5cdfd7b3d..8910474def4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -285,7 +285,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests { public void expectMessages(MessageExchange... messageExchanges) throws InterruptedException { List expectedMessages = - new ArrayList(Arrays.asList(messageExchanges)); + new ArrayList<>(Arrays.asList(messageExchanges)); while (expectedMessages.size() > 0) { Message message = this.queue.poll(10000, TimeUnit.MILLISECONDS); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java index b6afa9a7aac..6c6948490ae 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCodecTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import static org.junit.Assert.*; */ public class StompCodecTests { - private final ArgumentCapturingConsumer> consumer = new ArgumentCapturingConsumer>(); + private final ArgumentCapturingConsumer> consumer = new ArgumentCapturingConsumer<>(); private final Function> decoder = new Reactor2StompCodec().decoder(consumer); @@ -175,7 +175,7 @@ public class StompCodecTests { Buffer buffer = Buffer.wrap(frame1 + frame2); - final List> messages = new ArrayList>(); + final List> messages = new ArrayList<>(); new Reactor2StompCodec().decoder(messages::add).apply(buffer); assertEquals(2, messages.size()); @@ -247,7 +247,7 @@ public class StompCodecTests { Buffer buffer = Buffer.wrap(frame); - final List> messages = new ArrayList>(); + final List> messages = new ArrayList<>(); new Reactor2StompCodec().decoder(messages::add).apply(buffer); assertEquals(1, messages.size()); @@ -335,7 +335,7 @@ public class StompCodecTests { private static final class ArgumentCapturingConsumer implements Consumer { - private final List arguments = new ArrayList(); + private final List arguments = new ArrayList<>(); @Override public void accept(T t) { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java index 2d26c77fb52..0c0b1133b2d 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class StompHeaderAccessorTests { StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.CONNECTED); assertEquals(StompCommand.CONNECTED, accessor.getCommand()); - accessor = StompHeaderAccessor.create(StompCommand.CONNECTED, new LinkedMultiValueMap()); + accessor = StompHeaderAccessor.create(StompCommand.CONNECTED, new LinkedMultiValueMap<>()); assertEquals(StompCommand.CONNECTED, accessor.getCommand()); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java index cc5f9d03007..671a532350b 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -186,7 +186,7 @@ public class ChannelInterceptorTests { private static class TestMessageHandler implements MessageHandler { - private final List> messages = new ArrayList>(); + private final List> messages = new ArrayList<>(); public List> getMessages() { return this.messages; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java index 3d1e324f681..6c9d259e4c8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ public class NativeMessageHeaderAccessorTests { inputNativeHeaders.add("foo", "bar"); inputNativeHeaders.add("bar", "baz"); - Map inputHeaders = new HashMap(); + Map inputHeaders = new HashMap<>(); inputHeaders.put("a", "b"); inputHeaders.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, inputNativeHeaders); @@ -97,7 +97,7 @@ public class NativeMessageHeaderAccessorTests { inputNativeHeaders.add("foo", "bar"); inputNativeHeaders.add("bar", "baz"); - Map nativeHeaders = new HashMap(); + Map nativeHeaders = new HashMap<>(); nativeHeaders.put("a", "b"); nativeHeaders.put(NativeMessageHeaderAccessor.NATIVE_HEADERS, inputNativeHeaders); diff --git a/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java b/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java index d345263046f..f7a73a3e404 100644 --- a/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java +++ b/spring-orm/src/main/java/org/springframework/orm/hibernate5/LocalSessionFactoryBuilder.java @@ -250,9 +250,9 @@ public class LocalSessionFactoryBuilder extends Configuration { */ @SuppressWarnings("unchecked") public LocalSessionFactoryBuilder scanPackages(String... packagesToScan) throws HibernateException { - Set entityClassNames = new TreeSet(); - Set converterClassNames = new TreeSet(); - Set packageNames = new TreeSet(); + Set entityClassNames = new TreeSet<>(); + Set converterClassNames = new TreeSet<>(); + Set packageNames = new TreeSet<>(); try { for (String pkg : packagesToScan) { String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java b/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java index f4401ae2983..64648b559f2 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java @@ -97,7 +97,7 @@ public abstract class AbstractEntityManagerFactoryBean implements private String persistenceUnitName; - private final Map jpaPropertyMap = new HashMap(); + private final Map jpaPropertyMap = new HashMap<>(); private Class entityManagerFactoryInterface; @@ -392,7 +392,7 @@ public abstract class AbstractEntityManagerFactoryBean implements * @return proxy entity manager */ protected EntityManagerFactory createEntityManagerFactoryProxy(EntityManagerFactory emf) { - Set> ifcs = new LinkedHashSet>(); + Set> ifcs = new LinkedHashSet<>(); if (this.entityManagerFactoryInterface != null) { ifcs.add(this.entityManagerFactoryInterface); } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryAccessor.java b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryAccessor.java index 7e0eb82a05b..5fd48d9563d 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryAccessor.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public abstract class EntityManagerFactoryAccessor implements BeanFactoryAware { private String persistenceUnitName; - private final Map jpaPropertyMap = new HashMap(); + private final Map jpaPropertyMap = new HashMap<>(); /** diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java index 1575a7d2f01..cc7bde2aee4 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java @@ -221,7 +221,7 @@ public abstract class ExtendedEntityManagerCreator { boolean containerManaged, boolean synchronizedWithTransaction) { Assert.notNull(rawEm, "EntityManager must not be null"); - Set> ifcs = new LinkedHashSet>(); + Set> ifcs = new LinkedHashSet<>(); if (emIfc != null) { ifcs.add(emIfc); } diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java index 27ff649a77e..83b2631a3b5 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/JpaTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,7 +115,7 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager private String persistenceUnitName; - private final Map jpaPropertyMap = new HashMap(); + private final Map jpaPropertyMap = new HashMap<>(); private DataSource dataSource; diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java index 46f6ae689de..8c51e2acb72 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/SharedEntityManagerCreator.java @@ -65,9 +65,9 @@ public abstract class SharedEntityManagerCreator { private static final Class[] NO_ENTITY_MANAGER_INTERFACES = new Class[0]; - private static final Set transactionRequiringMethods = new HashSet(6); + private static final Set transactionRequiringMethods = new HashSet<>(6); - private static final Set queryTerminationMethods = new HashSet(3); + private static final Set queryTerminationMethods = new HashSet<>(3); static { transactionRequiringMethods.add("joinTransaction"); diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java index af74040358c..911392c908a 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java @@ -111,7 +111,7 @@ public class DefaultPersistenceUnitManager private static final Set entityTypeFilters; static { - entityTypeFilters = new LinkedHashSet(4); + entityTypeFilters = new LinkedHashSet<>(4); entityTypeFilters.add(new AnnotationTypeFilter(Entity.class, false)); entityTypeFilters.add(new AnnotationTypeFilter(Embeddable.class, false)); entityTypeFilters.add(new AnnotationTypeFilter(MappedSuperclass.class, false)); @@ -147,9 +147,9 @@ public class DefaultPersistenceUnitManager private ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); - private final Set persistenceUnitInfoNames = new HashSet(); + private final Set persistenceUnitInfoNames = new HashSet<>(); - private final Map persistenceUnitInfos = new HashMap(); + private final Map persistenceUnitInfos = new HashMap<>(); /** @@ -469,7 +469,7 @@ public class DefaultPersistenceUnitManager * as defined in the JPA specification. */ private List readPersistenceUnitInfos() { - List infos = new LinkedList(); + List infos = new LinkedList<>(); String defaultName = this.defaultPersistenceUnitName; boolean buildDefaultUnit = (this.packagesToScan != null || this.mappingResources != null); boolean foundDefaultUnit = false; diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java index 36a530523a0..35f4c0d1016 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,15 +53,15 @@ public class MutablePersistenceUnitInfo implements SmartPersistenceUnitInfo { private DataSource jtaDataSource; - private final List mappingFileNames = new LinkedList(); + private final List mappingFileNames = new LinkedList<>(); - private List jarFileUrls = new LinkedList(); + private List jarFileUrls = new LinkedList<>(); private URL persistenceUnitRootUrl; - private final List managedClassNames = new LinkedList(); + private final List managedClassNames = new LinkedList<>(); - private final List managedPackages = new LinkedList(); + private final List managedPackages = new LinkedList<>(); private boolean excludeUnlistedClasses = false; diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java index bb4c44f0463..30b038fef6f 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java @@ -121,7 +121,7 @@ final class PersistenceUnitReader { */ public SpringPersistenceUnitInfo[] readPersistenceUnitInfos(String[] persistenceXmlLocations) { ErrorHandler handler = new SimpleSaxErrorHandler(logger); - List infos = new LinkedList(); + List infos = new LinkedList<>(); String resourceLocation = null; try { for (String location : persistenceXmlLocations) { diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java b/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java index f8236240ea7..c00cd50d70d 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java @@ -186,10 +186,10 @@ public class PersistenceAnnotationBeanPostProcessor private transient ListableBeanFactory beanFactory; private transient final Map injectionMetadataCache = - new ConcurrentHashMap(256); + new ConcurrentHashMap<>(256); private final Map extendedEntityManagersToClose = - new ConcurrentHashMap(16); + new ConcurrentHashMap<>(16); /** @@ -404,12 +404,12 @@ public class PersistenceAnnotationBeanPostProcessor } private InjectionMetadata buildPersistenceMetadata(final Class clazz) { - LinkedList elements = new LinkedList(); + LinkedList elements = new LinkedList<>(); Class targetClass = clazz; do { final LinkedList currElements = - new LinkedList(); + new LinkedList<>(); ReflectionUtils.doWithLocalFields(targetClass, new ReflectionUtils.FieldCallback() { @Override diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java index d27e8f2efa9..d845df0ccc6 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class EclipseLinkJpaVendorAdapter extends AbstractJpaVendorAdapter { @Override public Map getJpaPropertyMap() { - Map jpaProperties = new HashMap(); + Map jpaProperties = new HashMap<>(); if (getDatabasePlatform() != null) { jpaProperties.put(PersistenceUnitProperties.TARGET_DATABASE, getDatabasePlatform()); diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java index 54bd8b9dade..6a88f8873cd 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java @@ -101,7 +101,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter { @Override public Map getJpaPropertyMap() { - Map jpaProperties = new HashMap(); + Map jpaProperties = new HashMap<>(); if (getDatabasePlatform() != null) { jpaProperties.put(Environment.DIALECT, getDatabasePlatform()); diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider.java b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider.java index 90e29408e7c..8f6e1e3c462 100644 --- a/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider.java +++ b/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider.java @@ -44,7 +44,7 @@ class SpringHibernateJpaPersistenceProvider extends HibernatePersistenceProvider @Override @SuppressWarnings("rawtypes") public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map properties) { - final List mergedClassesAndPackages = new ArrayList(info.getManagedClassNames()); + final List mergedClassesAndPackages = new ArrayList<>(info.getManagedClassNames()); if (info instanceof SmartPersistenceUnitInfo) { mergedClassesAndPackages.addAll(((SmartPersistenceUnitInfo) info).getManagedPackages()); } diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java index 9314ed39a54..9269a73b05b 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ public class JpaTransactionManagerTests { public void testTransactionCommit() { given(manager.getTransaction()).willReturn(tx); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -118,7 +118,7 @@ public class JpaTransactionManagerTests { given(tx.getRollbackOnly()).willReturn(true); willThrow(new RollbackException()).given(tx).commit(); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -152,7 +152,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); given(tx.isActive()).willReturn(true); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -185,7 +185,7 @@ public class JpaTransactionManagerTests { public void testTransactionRollbackWithAlreadyRolledBack() { given(manager.getTransaction()).willReturn(tx); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -217,7 +217,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); given(tx.isActive()).willReturn(true); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -247,7 +247,7 @@ public class JpaTransactionManagerTests { public void testParticipatingTransactionWithCommit() { given(manager.getTransaction()).willReturn(tx); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -281,7 +281,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); given(tx.isActive()).willReturn(true); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -322,7 +322,7 @@ public class JpaTransactionManagerTests { given(tx.getRollbackOnly()).willReturn(true); willThrow(new RollbackException()).given(tx).commit(); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -367,7 +367,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); given(manager.isOpen()).willReturn(true); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -402,7 +402,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -447,7 +447,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -486,7 +486,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); given(manager.isOpen()).willReturn(true); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -570,7 +570,7 @@ public class JpaTransactionManagerTests { public void testTransactionCommitWithPropagationSupports() { given(manager.isOpen()).willReturn(true); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS); @@ -629,7 +629,7 @@ public class JpaTransactionManagerTests { public void testTransactionCommitWithPrebound() { given(manager.getTransaction()).willReturn(tx); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); @@ -694,7 +694,7 @@ public class JpaTransactionManagerTests { @Test public void testTransactionCommitWithPreboundAndPropagationSupports() { - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS); @@ -765,7 +765,7 @@ public class JpaTransactionManagerTests { given(manager.getTransaction()).willReturn(tx); - final List l = new ArrayList(); + final List l = new ArrayList<>(); l.add("test"); assertTrue(!TransactionSynchronizationManager.hasResource(factory)); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java index 12b6ddd9b5b..3f6907f9ed8 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java @@ -182,7 +182,7 @@ public class PersistenceXmlParsingTests { String resource = "/org/springframework/orm/jpa/persistence-complex.xml"; MapDataSourceLookup dataSourceLookup = new MapDataSourceLookup(); - Map dataSources = new HashMap(); + Map dataSources = new HashMap<>(); dataSources.put("jdbc/MyPartDB", ds); dataSources.put("jdbc/MyDB", ds); dataSourceLookup.setDataSources(dataSources); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java index 4d183cdad9d..d15dc615fd4 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -340,7 +340,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT EntityManagerFactoryWithInfo mockEmf2 = mock(EntityManagerFactoryWithInfo.class); - Map persistenceUnits = new HashMap(); + Map persistenceUnits = new HashMap<>(); persistenceUnits.put("", "pu1"); persistenceUnits.put("Person", "pu2"); ExpectedLookupTemplate jt = new ExpectedLookupTemplate(); @@ -379,7 +379,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT public void testPersistenceUnitsFromJndiWithDefaultUnit() { EntityManagerFactoryWithInfo mockEmf2 = mock(EntityManagerFactoryWithInfo.class); - Map persistenceUnits = new HashMap(); + Map persistenceUnits = new HashMap<>(); persistenceUnits.put("System", "pu1"); persistenceUnits.put("Person", "pu2"); ExpectedLookupTemplate jt = new ExpectedLookupTemplate(); @@ -407,7 +407,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT @Test public void testSinglePersistenceUnitFromJndi() { - Map persistenceUnits = new HashMap(); + Map persistenceUnits = new HashMap<>(); persistenceUnits.put("Person", "pu1"); ExpectedLookupTemplate jt = new ExpectedLookupTemplate(); jt.addObject("java:comp/env/pu1", mockEmf); @@ -436,10 +436,10 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT EntityManager mockEm2 = mock(EntityManager.class); EntityManager mockEm3 = mock(EntityManager.class); - Map persistenceContexts = new HashMap(); + Map persistenceContexts = new HashMap<>(); persistenceContexts.put("", "pc1"); persistenceContexts.put("Person", "pc2"); - Map extendedPersistenceContexts = new HashMap(); + Map extendedPersistenceContexts = new HashMap<>(); extendedPersistenceContexts .put("", "pc3"); ExpectedLookupTemplate jt = new ExpectedLookupTemplate(); jt.addObject("java:comp/env/pc1", mockEm); @@ -476,10 +476,10 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT EntityManager mockEm2 = mock(EntityManager.class); EntityManager mockEm3 = mock(EntityManager.class); - Map persistenceContexts = new HashMap(); + Map persistenceContexts = new HashMap<>(); persistenceContexts.put("System", "pc1"); persistenceContexts.put("Person", "pc2"); - Map extendedPersistenceContexts = new HashMap(); + Map extendedPersistenceContexts = new HashMap<>(); extendedPersistenceContexts .put("System", "pc3"); ExpectedLookupTemplate jt = new ExpectedLookupTemplate(); jt.addObject("java:comp/env/pc1", mockEm); @@ -516,9 +516,9 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT EntityManager mockEm = mock(EntityManager.class); EntityManager mockEm2 = mock(EntityManager.class); - Map persistenceContexts = new HashMap(); + Map persistenceContexts = new HashMap<>(); persistenceContexts.put("System", "pc1"); - Map extendedPersistenceContexts = new HashMap(); + Map extendedPersistenceContexts = new HashMap<>(); extendedPersistenceContexts .put("System", "pc2"); ExpectedLookupTemplate jt = new ExpectedLookupTemplate(); jt.addObject("java:comp/env/pc1", mockEm); diff --git a/spring-orm/src/test/java/org/springframework/test/AbstractSpringContextTests.java b/spring-orm/src/test/java/org/springframework/test/AbstractSpringContextTests.java index 2af77331dbd..d6eefe161d9 100644 --- a/spring-orm/src/test/java/org/springframework/test/AbstractSpringContextTests.java +++ b/spring-orm/src/test/java/org/springframework/test/AbstractSpringContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ abstract class AbstractSpringContextTests extends TestCase { protected final Log logger = LogFactory.getLog(getClass()); private static Map contextKeyToContextMap = - new HashMap(); + new HashMap<>(); /** diff --git a/spring-orm/src/test/java/org/springframework/test/jpa/AbstractJpaTests.java b/spring-orm/src/test/java/org/springframework/test/jpa/AbstractJpaTests.java index 626591ec553..a688b70a1f6 100644 --- a/spring-orm/src/test/java/org/springframework/test/jpa/AbstractJpaTests.java +++ b/spring-orm/src/test/java/org/springframework/test/jpa/AbstractJpaTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,9 +92,9 @@ public abstract class AbstractJpaTests extends AbstractTransactionalSpringContex * Values are intentionally not strongly typed, to avoid potential class cast exceptions * through use between different class loaders. */ - private static Map contextCache = new HashMap(); + private static Map contextCache = new HashMap<>(); - private static Map classLoaderCache = new HashMap(); + private static Map classLoaderCache = new HashMap<>(); protected EntityManagerFactory entityManagerFactory; diff --git a/spring-oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java b/spring-oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java index 0dc8092ee1b..9fdc18f800b 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/config/Jaxb2MarshallerBeanDefinitionParser.java @@ -1,6 +1,6 @@ /* -* Copyright 2002-2013 the original author or authors. - * + * Copyright 2002-2016 the original author or authors. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -53,7 +53,7 @@ class Jaxb2MarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionPa List classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound"); if (!classes.isEmpty()) { - ManagedList classesToBeBound = new ManagedList(classes.size()); + ManagedList classesToBeBound = new ManagedList<>(classes.size()); for (Element classToBeBound : classes) { String className = classToBeBound.getAttribute("name"); classesToBeBound.add(className); diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/ClassPathJaxb2TypeScanner.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/ClassPathJaxb2TypeScanner.java index 6c6af3e919f..0a1ba88c9a8 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/ClassPathJaxb2TypeScanner.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/ClassPathJaxb2TypeScanner.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ class ClassPathJaxb2TypeScanner { */ public Class[] scanPackages() throws UncategorizedMappingException { try { - List> jaxb2Classes = new ArrayList>(); + List> jaxb2Classes = new ArrayList<>(); for (String packageToScan : this.packagesToScan) { String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + ClassUtils.convertClassNameToResourcePath(packageToScan) + RESOURCE_PATTERN; diff --git a/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java index 7ce47f58c44..740dfe535e5 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/xstream/XStreamMarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -568,7 +568,7 @@ public class XStreamMarshaller extends AbstractMarshaller implements Initializin } private Map> toClassMap(Map map) throws ClassNotFoundException { - Map> result = new LinkedHashMap>(map.size()); + Map> result = new LinkedHashMap<>(map.size()); for (Map.Entry entry : map.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java index 423fec4de64..be32fde8486 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorMarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -278,7 +278,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests namespaces = new HashMap(); + Map namespaces = new HashMap<>(); namespaces.put("tns", "http://samples.springframework.org/flight"); namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorUnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorUnmarshallerTests.java index f3b2a0f5d6f..5313a02df69 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorUnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/castor/CastorUnmarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -198,7 +198,7 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests result = new AtomicReference(); + final AtomicReference result = new AtomicReference<>(); CastorMarshaller marshaller = new CastorMarshaller() { @Override protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource) { @@ -225,7 +225,7 @@ public class CastorUnmarshallerTests extends AbstractUnmarshallerTests result = new AtomicReference(); + final AtomicReference result = new AtomicReference<>(); CastorMarshaller marshaller = new CastorMarshaller() { @Override protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource) { diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index 68f29789568..1d5cc651537 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -191,7 +191,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests flightTypeJAXBElement = new JAXBElement(new QName("http://springframework.org", "flight"), FlightType.class, + JAXBElement flightTypeJAXBElement = new JAXBElement<>(new QName("http://springframework.org", "flight"), FlightType.class, new FlightType()); assertTrue("Jaxb2Marshaller does not support JAXBElement", marshaller.supports(flightTypeJAXBElement.getClass())); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Primitives.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Primitives.java index 5e982d76133..44efed66d78 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Primitives.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Primitives.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,31 +30,31 @@ public class Primitives { // following methods are used to test support for primitives public JAXBElement primitiveBoolean() { - return new JAXBElement(NAME, Boolean.class, true); + return new JAXBElement<>(NAME, Boolean.class, true); } public JAXBElement primitiveByte() { - return new JAXBElement(NAME, Byte.class, (byte)42); + return new JAXBElement<>(NAME, Byte.class, (byte) 42); } public JAXBElement primitiveShort() { - return new JAXBElement(NAME, Short.class, (short)42); + return new JAXBElement<>(NAME, Short.class, (short) 42); } public JAXBElement primitiveInteger() { - return new JAXBElement(NAME, Integer.class, 42); + return new JAXBElement<>(NAME, Integer.class, 42); } public JAXBElement primitiveLong() { - return new JAXBElement(NAME, Long.class, 42L); + return new JAXBElement<>(NAME, Long.class, 42L); } public JAXBElement primitiveDouble() { - return new JAXBElement(NAME, Double.class, 42D); + return new JAXBElement<>(NAME, Double.class, 42D); } public JAXBElement primitiveByteArray() { - return new JAXBElement(NAME, byte[].class, new byte[]{42}); + return new JAXBElement<>(NAME, byte[].class, new byte[] {42}); } diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/StandardClasses.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/StandardClasses.java index 00daa798f45..ac98f5bc19e 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/StandardClasses.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/StandardClasses.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,57 +62,57 @@ public class StandardClasses { java.util.UUID */ public JAXBElement standardClassString() { - return new JAXBElement(NAME, String.class, "42"); + return new JAXBElement<>(NAME, String.class, "42"); } public JAXBElement standardClassBigInteger() { - return new JAXBElement(NAME, BigInteger.class, new BigInteger("42")); + return new JAXBElement<>(NAME, BigInteger.class, new BigInteger("42")); } public JAXBElement standardClassBigDecimal() { - return new JAXBElement(NAME, BigDecimal.class, new BigDecimal("42.0")); + return new JAXBElement<>(NAME, BigDecimal.class, new BigDecimal("42.0")); } public JAXBElement standardClassCalendar() { - return new JAXBElement(NAME, Calendar.class, Calendar.getInstance()); + return new JAXBElement<>(NAME, Calendar.class, Calendar.getInstance()); } public JAXBElement standardClassGregorianCalendar() { - return new JAXBElement(NAME, GregorianCalendar.class, (GregorianCalendar)Calendar.getInstance()); + return new JAXBElement<>(NAME, GregorianCalendar.class, (GregorianCalendar) Calendar.getInstance()); } public JAXBElement standardClassDate() { - return new JAXBElement(NAME, Date.class, new Date()); + return new JAXBElement<>(NAME, Date.class, new Date()); } public JAXBElement standardClassQName() { - return new JAXBElement(NAME, QName.class, NAME); + return new JAXBElement<>(NAME, QName.class, NAME); } public JAXBElement standardClassURI() { - return new JAXBElement(NAME, URI.class, URI.create("http://springframework.org")); + return new JAXBElement<>(NAME, URI.class, URI.create("http://springframework.org")); } public JAXBElement standardClassXMLGregorianCalendar() throws DatatypeConfigurationException { XMLGregorianCalendar calendar = factory.newXMLGregorianCalendar((GregorianCalendar) Calendar.getInstance()); - return new JAXBElement(NAME, XMLGregorianCalendar.class, calendar); + return new JAXBElement<>(NAME, XMLGregorianCalendar.class, calendar); } public JAXBElement standardClassDuration() { Duration duration = factory.newDuration(42000); - return new JAXBElement(NAME, Duration.class, duration); + return new JAXBElement<>(NAME, Duration.class, duration); } public JAXBElement standardClassImage() throws IOException { Image image = ImageIO.read(getClass().getResourceAsStream("spring-ws.png")); - return new JAXBElement(NAME, Image.class, image); + return new JAXBElement<>(NAME, Image.class, image); } public JAXBElement standardClassDataHandler() { DataSource dataSource = new URLDataSource(getClass().getResource("spring-ws.png")); DataHandler dataHandler = new DataHandler(dataSource); - return new JAXBElement(NAME, DataHandler.class, dataHandler); + return new JAXBElement<>(NAME, DataHandler.class, dataHandler); } /* The following should work according to the spec, but doesn't on the JAXB2 implementation including in JDK 1.6.0_17 @@ -123,7 +123,7 @@ public class StandardClasses { */ public JAXBElement standardClassUUID() { - return new JAXBElement(NAME, UUID.class, UUID.randomUUID()); + return new JAXBElement<>(NAME, UUID.class, UUID.randomUUID()); } } diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java index a3f6c702af5..56f3970e398 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java @@ -1,4 +1,20 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.oxm.jaxb; import javax.xml.bind.JAXBElement; @@ -11,6 +27,6 @@ public class XmlRegObjectFactory { @XmlElementDecl(name = "brand-airplane") public JAXBElement createAirplane(Airplane airplane) { - return new JAXBElement(new QName("brand-airplane"), Airplane.class, null, airplane); + return new JAXBElement<>(new QName("brand-airplane"), Airplane.class, null, airplane); } } \ No newline at end of file diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java b/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java index f44e14c8310..9a2ad6f3f7b 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jibx/Flights.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import java.util.List; public class Flights { - protected List flightList = new ArrayList(); + protected List flightList = new ArrayList<>(); public void addFlight(FlightType flight) { flightList.add(flight); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/Flights.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/Flights.java index a8d28c2c609..b32bba36f4f 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/Flights.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/Flights.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.oxm.xstream; import java.util.ArrayList; @@ -5,9 +21,9 @@ import java.util.List; public class Flights { - private List flights = new ArrayList(); + private List flights = new ArrayList<>(); - private List strings = new ArrayList(); + private List strings = new ArrayList<>(); public List getFlights() { return flights; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java index 0a97391cca6..ee6a7279775 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public class XStreamMarshallerTests { @Before public void createMarshaller() throws Exception { marshaller = new XStreamMarshaller(); - Map aliases = new HashMap(); + Map aliases = new HashMap<>(); aliases.put("flight", Flight.class.getName()); marshaller.setAliases(aliases); flight = new Flight(); @@ -231,7 +231,7 @@ public class XStreamMarshallerTests { @Test @Ignore("Fails on JDK 8 build 108") public void aliasesByTypeStringClassMap() throws Exception { - Map> aliases = new HashMap>(); + Map> aliases = new HashMap<>(); aliases.put("flight", Flight.class); FlightSubclass flight = new FlightSubclass(); flight.setFlightNumber(42); @@ -245,7 +245,7 @@ public class XStreamMarshallerTests { @Test @Ignore("Fails on JDK 8 build 108") public void aliasesByTypeStringStringMap() throws Exception { - Map aliases = new HashMap(); + Map aliases = new HashMap<>(); aliases.put("flight", Flight.class.getName()); FlightSubclass flight = new FlightSubclass(); flight.setFlightNumber(42); @@ -282,7 +282,7 @@ public class XStreamMarshallerTests { flights.getFlights().add(flight); flights.getStrings().add("42"); - Map> aliases = new HashMap>(); + Map> aliases = new HashMap<>(); aliases.put("flight", Flight.class); aliases.put("flights", Flights.class); marshaller.setAliases(aliases); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java index 56e99af2d3d..4d54cc7e58f 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class XStreamUnmarshallerTests { @Before public void createUnmarshaller() throws Exception { unmarshaller = new XStreamMarshaller(); - Map> aliases = new HashMap>(); + Map> aliases = new HashMap<>(); aliases.put("flight", Flight.class); unmarshaller.setAliases(aliases); } diff --git a/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java b/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java index bfe609dec7d..975f5a228ab 100644 --- a/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/http/client/MockAsyncClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class MockAsyncClientHttpRequest extends MockClientHttpRequest implements @Override public ListenableFuture executeAsync() throws IOException { - SettableListenableFuture future = new SettableListenableFuture(); + SettableListenableFuture future = new SettableListenableFuture<>(); future.set(execute()); return future; } diff --git a/spring-test/src/main/java/org/springframework/mock/jndi/ExpectedLookupTemplate.java b/spring-test/src/main/java/org/springframework/mock/jndi/ExpectedLookupTemplate.java index 7bffe4de135..3eeeb760a57 100644 --- a/spring-test/src/main/java/org/springframework/mock/jndi/ExpectedLookupTemplate.java +++ b/spring-test/src/main/java/org/springframework/mock/jndi/ExpectedLookupTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import org.springframework.jndi.JndiTemplate; */ public class ExpectedLookupTemplate extends JndiTemplate { - private final Map jndiObjects = new ConcurrentHashMap(16); + private final Map jndiObjects = new ConcurrentHashMap<>(16); /** diff --git a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java index 4e1641b2cd8..a4522c3a847 100644 --- a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java +++ b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class SimpleNamingContext implements Context { private final Hashtable boundObjects; - private final Hashtable environment = new Hashtable(); + private final Hashtable environment = new Hashtable<>(); /** @@ -73,7 +73,7 @@ public class SimpleNamingContext implements Context { */ public SimpleNamingContext(String root) { this.root = root; - this.boundObjects = new Hashtable(); + this.boundObjects = new Hashtable<>(); } /** @@ -302,7 +302,7 @@ public class SimpleNamingContext implements Context { proot = proot + "/"; } String root = context.root + proot; - Map contents = new HashMap(); + Map contents = new HashMap<>(); for (String boundName : context.boundObjects.keySet()) { if (boundName.startsWith(root)) { int startIndex = root.length(); diff --git a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java index d12a968fbd4..caa45a855ef 100644 --- a/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java +++ b/spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContextBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ public class SimpleNamingContextBuilder implements InitialContextFactoryBuilder private final Log logger = LogFactory.getLog(getClass()); - private final Hashtable boundObjects = new Hashtable(); + private final Hashtable boundObjects = new Hashtable<>(); /** diff --git a/spring-test/src/main/java/org/springframework/mock/web/HeaderValueHolder.java b/spring-test/src/main/java/org/springframework/mock/web/HeaderValueHolder.java index e8f5e91dfb6..d26f7a1364a 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/HeaderValueHolder.java +++ b/spring-test/src/main/java/org/springframework/mock/web/HeaderValueHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import org.springframework.util.CollectionUtils; */ class HeaderValueHolder { - private final List values = new LinkedList(); + private final List values = new LinkedList<>(); public void setValue(Object value) { @@ -60,7 +60,7 @@ class HeaderValueHolder { } public List getStringValues() { - List stringList = new ArrayList(this.values.size()); + List stringList = new ArrayList<>(this.values.size()); for (Object value : this.values) { stringList.add(value.toString()); } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java b/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java index 0d9f917818b..69e3e286e66 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockAsyncContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,13 +45,13 @@ public class MockAsyncContext implements AsyncContext { private final HttpServletResponse response; - private final List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); private String dispatchedPath; private long timeout = 10 * 1000L; // 10 seconds is Tomcat's default - private final List dispatchHandlers = new ArrayList(); + private final List dispatchHandlers = new ArrayList<>(); public MockAsyncContext(ServletRequest request, ServletResponse response) { diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockFilterConfig.java b/spring-test/src/main/java/org/springframework/mock/web/MockFilterConfig.java index 99e7722f335..123214b66f5 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockFilterConfig.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockFilterConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class MockFilterConfig implements FilterConfig { private final String filterName; - private final Map initParameters = new LinkedHashMap(); + private final Map initParameters = new LinkedHashMap<>(); /** diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java index d1a8c37c7f3..6eeb849298b 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,7 +144,7 @@ public class MockHttpServletRequest implements HttpServletRequest { // ServletRequest properties // --------------------------------------------------------------------- - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private String characterEncoding; @@ -152,7 +152,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private String contentType; - private final Map parameters = new LinkedHashMap(16); + private final Map parameters = new LinkedHashMap<>(16); private String protocol = DEFAULT_PROTOCOL; @@ -167,7 +167,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private String remoteHost = DEFAULT_REMOTE_HOST; /** List of locales in descending order */ - private final List locales = new LinkedList(); + private final List locales = new LinkedList<>(); private boolean secure = false; @@ -198,7 +198,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private Cookie[] cookies; - private final Map headers = new LinkedCaseInsensitiveMap(); + private final Map headers = new LinkedCaseInsensitiveMap<>(); private String method; @@ -210,7 +210,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private String remoteUser; - private final Set userRoles = new HashSet(); + private final Set userRoles = new HashSet<>(); private Principal userPrincipal; @@ -228,7 +228,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private boolean requestedSessionIdFromURL = false; - private final MultiValueMap parts = new LinkedMultiValueMap(); + private final MultiValueMap parts = new LinkedMultiValueMap<>(); // --------------------------------------------------------------------- @@ -347,7 +347,7 @@ public class MockHttpServletRequest implements HttpServletRequest { @Override public Enumeration getAttributeNames() { checkActive(); - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override @@ -973,7 +973,7 @@ public class MockHttpServletRequest implements HttpServletRequest { @Override public Enumeration getHeaders(String name) { HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name); - return Collections.enumeration(header != null ? header.getStringValues() : new LinkedList()); + return Collections.enumeration(header != null ? header.getStringValues() : new LinkedList<>()); } @Override @@ -1213,7 +1213,7 @@ public class MockHttpServletRequest implements HttpServletRequest { @Override public Collection getParts() throws IOException, IllegalStateException, ServletException { - List result = new LinkedList(); + List result = new LinkedList<>(); for (List list : this.parts.values()) { result.addAll(list); } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java index 1d5b838dfe2..86c7d6eeecf 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,9 +102,9 @@ public class MockHttpServletResponse implements HttpServletResponse { // HttpServletResponse properties //--------------------------------------------------------------------- - private final List cookies = new ArrayList(); + private final List cookies = new ArrayList<>(); - private final Map headers = new LinkedCaseInsensitiveMap(); + private final Map headers = new LinkedCaseInsensitiveMap<>(); private int status = HttpServletResponse.SC_OK; @@ -112,7 +112,7 @@ public class MockHttpServletResponse implements HttpServletResponse { private String forwardedUrl; - private final List includedUrls = new ArrayList(); + private final List includedUrls = new ArrayList<>(); //--------------------------------------------------------------------- diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockHttpSession.java b/spring-test/src/main/java/org/springframework/mock/web/MockHttpSession.java index cae49f69fb3..4089c0f48d9 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockHttpSession.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockHttpSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ public class MockHttpSession implements HttpSession { private final ServletContext servletContext; - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private boolean invalid = false; @@ -166,7 +166,7 @@ public class MockHttpSession implements HttpSession { @Override public Enumeration getAttributeNames() { assertIsValid(); - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override @@ -270,7 +270,7 @@ public class MockHttpSession implements HttpSession { * @return a representation of this session's serialized state */ public Serializable serializeState() { - HashMap state = new HashMap(); + HashMap state = new HashMap<>(); for (Iterator> it = this.attributes.entrySet().iterator(); it.hasNext();) { Map.Entry entry = it.next(); String name = entry.getKey(); diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java index 7988b17b326..f1a0307836e 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockMultipartHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest; public class MockMultipartHttpServletRequest extends MockHttpServletRequest implements MultipartHttpServletRequest { private final MultiValueMap multipartFiles = - new LinkedMultiValueMap(); + new LinkedMultiValueMap<>(); /** @@ -112,7 +112,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl @Override public MultiValueMap getMultiFileMap() { - return new LinkedMultiValueMap(this.multipartFiles); + return new LinkedMultiValueMap<>(this.multipartFiles); } @Override diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java b/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java index 0e95d460b53..02dc7465e46 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockPageContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class MockPageContext extends PageContext { private final ServletConfig servletConfig; - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private JspWriter out; @@ -257,7 +257,7 @@ public class MockPageContext extends PageContext { } public Enumeration getAttributeNames() { - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockServletConfig.java b/spring-test/src/main/java/org/springframework/mock/web/MockServletConfig.java index be7ebf808e5..d5bb9f33aa3 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockServletConfig.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockServletConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public class MockServletConfig implements ServletConfig { private final String servletName; - private final Map initParameters = new LinkedHashMap(); + private final Map initParameters = new LinkedHashMap<>(); /** diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java b/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java index 7bca348a743..df3c6690502 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockServletContext.java @@ -106,7 +106,7 @@ public class MockServletContext implements ServletContext { private static final String TEMP_DIR_SYSTEM_PROPERTY = "java.io.tmpdir"; private static final Set DEFAULT_SESSION_TRACKING_MODES = - new LinkedHashSet(3); + new LinkedHashSet<>(3); static { DEFAULT_SESSION_TRACKING_MODES.add(SessionTrackingMode.COOKIE); @@ -123,7 +123,7 @@ public class MockServletContext implements ServletContext { private String contextPath = ""; - private final Map contexts = new HashMap(); + private final Map contexts = new HashMap<>(); private int majorVersion = 3; @@ -133,17 +133,17 @@ public class MockServletContext implements ServletContext { private int effectiveMinorVersion = 0; - private final Map namedRequestDispatchers = new HashMap(); + private final Map namedRequestDispatchers = new HashMap<>(); private String defaultServletName = COMMON_DEFAULT_SERVLET_NAME; - private final Map initParameters = new LinkedHashMap(); + private final Map initParameters = new LinkedHashMap<>(); - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private String servletContextName = "MockServletContext"; - private final Set declaredRoles = new LinkedHashSet(); + private final Set declaredRoles = new LinkedHashSet<>(); private Set sessionTrackingModes; @@ -304,7 +304,7 @@ public class MockServletContext implements ServletContext { if (ObjectUtils.isEmpty(fileList)) { return null; } - Set resourcePaths = new LinkedHashSet(fileList.length); + Set resourcePaths = new LinkedHashSet<>(fileList.length); for (String fileEntry : fileList) { String resultPath = actualPath + fileEntry; if (resource.createRelative(fileEntry).getFile().isDirectory()) { @@ -502,7 +502,7 @@ public class MockServletContext implements ServletContext { @Override public Enumeration getAttributeNames() { - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override diff --git a/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java index 45f31a182e3..c49bbd4579a 100644 --- a/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/MergedContextConfiguration.java @@ -127,7 +127,7 @@ public class MergedContextConfiguration implements Serializable { } // Active profiles must be unique - Set profilesSet = new LinkedHashSet(Arrays.asList(activeProfiles)); + Set profilesSet = new LinkedHashSet<>(Arrays.asList(activeProfiles)); return StringUtils.toStringArray(profilesSet); } diff --git a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java index 33598520741..5c0e709daef 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java @@ -86,7 +86,7 @@ public class TestContextManager { private final TestContext testContext; - private final List testExecutionListeners = new ArrayList(); + private final List testExecutionListeners = new ArrayList<>(); /** @@ -165,7 +165,7 @@ public class TestContextManager { * registered for this {@code TestContextManager} in reverse order. */ private List getReversedTestExecutionListeners() { - List listenersReversed = new ArrayList(getTestExecutionListeners()); + List listenersReversed = new ArrayList<>(getTestExecutionListeners()); Collections.reverse(listenersReversed); return listenersReversed; } diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java index d4aaa44184c..ca6f471179c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java @@ -69,7 +69,7 @@ public class DefaultContextCache implements ContextCache { * of other contexts. */ private final Map> hierarchyMap = - new ConcurrentHashMap>(32); + new ConcurrentHashMap<>(32); private final int maxSize; @@ -143,7 +143,7 @@ public class DefaultContextCache implements ContextCache { while (parent != null) { Set list = this.hierarchyMap.get(parent); if (list == null) { - list = new HashSet(); + list = new HashSet<>(); this.hierarchyMap.put(parent, list); } list.add(child); @@ -168,7 +168,7 @@ public class DefaultContextCache implements ContextCache { } } - List removedContexts = new ArrayList(); + List removedContexts = new ArrayList<>(); remove(removedContexts, startKey); // Remove all remaining references to any removed contexts from the diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/rules/SpringClassRule.java b/spring-test/src/main/java/org/springframework/test/context/junit4/rules/SpringClassRule.java index cbbe7437bc2..53058ccc32e 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/rules/SpringClassRule.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/rules/SpringClassRule.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,7 +95,7 @@ public class SpringClassRule implements TestRule { * Cache of {@code TestContextManagers} keyed by test class. */ private static final Map, TestContextManager> testContextManagerCache = - new ConcurrentHashMap, TestContextManager>(64); + new ConcurrentHashMap<>(64); static { if (!ClassUtils.isPresent("org.junit.internal.Throwables", SpringClassRule.class.getClassLoader())) { diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java index bf05536a476..588e91cfbfc 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestClassCallbacks.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ public class RunAfterTestClassCallbacks extends Statement { */ @Override public void evaluate() throws Throwable { - List errors = new ArrayList(); + List errors = new ArrayList<>(); try { this.next.evaluate(); } diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java index e07712641e8..b8de040f4d6 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/statements/RunAfterTestMethodCallbacks.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public class RunAfterTestMethodCallbacks extends Statement { @Override public void evaluate() throws Throwable { Throwable testException = null; - List errors = new ArrayList(); + List errors = new ArrayList<>(); try { this.next.evaluate(); } diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java b/spring-test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java index f17782f8a6f..31533a8ec32 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AbstractContextLoader.java @@ -149,7 +149,7 @@ public abstract class AbstractContextLoader implements SmartContextLoader { return; } - List> initializerInstances = new ArrayList>(); + List> initializerInstances = new ArrayList<>(); Class contextClass = context.getClass(); for (Class> initializerClass : initializerClasses) { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java b/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java index fb9e28c036a..19fd57bca57 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AbstractTestContextBootstrapper.java @@ -120,7 +120,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot public final List getTestExecutionListeners() { Class clazz = getBootstrapContext().getTestClass(); Class annotationType = TestExecutionListeners.class; - List> classesList = new ArrayList>(); + List> classesList = new ArrayList<>(); boolean usingDefaults = false; AnnotationDescriptor descriptor = @@ -170,7 +170,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot // Remove possible duplicates if we loaded default listeners. if (usingDefaults) { - Set> classesSet = new HashSet>(); + Set> classesSet = new HashSet<>(); classesSet.addAll(classesList); classesList.clear(); classesList.addAll(classesSet); @@ -190,7 +190,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot } private List instantiateListeners(List> classesList) { - List listeners = new ArrayList(classesList.size()); + List listeners = new ArrayList<>(classesList.size()); for (Class listenerClass : classesList) { NoClassDefFoundError ncdfe = null; try { @@ -226,7 +226,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot */ @SuppressWarnings("unchecked") protected Set> getDefaultTestExecutionListenerClasses() { - Set> defaultListenerClasses = new LinkedHashSet>(); + Set> defaultListenerClasses = new LinkedHashSet<>(); ClassLoader cl = getClass().getClassLoader(); for (String className : getDefaultTestExecutionListenerClassNames()) { try { @@ -284,7 +284,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot MergedContextConfiguration mergedConfig = null; for (List list : hierarchyMap.values()) { - List reversedList = new ArrayList(list); + List reversedList = new ArrayList<>(list); Collections.reverse(reversedList); // Don't use the supplied testClass; instead ensure that we are @@ -357,9 +357,9 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be null or empty"); ContextLoader contextLoader = resolveContextLoader(testClass, configAttributesList); - List locations = new ArrayList(); - List> classes = new ArrayList>(); - List> initializers = new ArrayList>(); + List locations = new ArrayList<>(); + List> classes = new ArrayList<>(); + List> initializers = new ArrayList<>(); for (ContextConfigurationAttributes configAttributes : configAttributesList) { if (logger.isTraceEnabled()) { @@ -413,7 +413,7 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot List configAttributes) { List factories = getContextCustomizerFactories(); - Set customizers = new LinkedHashSet(factories.size()); + Set customizers = new LinkedHashSet<>(factories.size()); for (ContextCustomizerFactory factory : factories) { ContextCustomizer customizer = factory.createContextCustomizer(testClass, configAttributes); if (customizer != null) { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/ActiveProfilesUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/ActiveProfilesUtils.java index c2025424c50..fcad0767965 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/ActiveProfilesUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/ActiveProfilesUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ abstract class ActiveProfilesUtils { static String[] resolveActiveProfiles(Class testClass) { Assert.notNull(testClass, "Class must not be null"); - final List profileArrays = new ArrayList(); + final List profileArrays = new ArrayList<>(); Class annotationType = ActiveProfiles.class; AnnotationDescriptor descriptor = MetaAnnotationUtils.findAnnotationDescriptor(testClass, @@ -130,7 +130,7 @@ abstract class ActiveProfilesUtils { // Reverse the list so that we can traverse "down" the hierarchy. Collections.reverse(profileArrays); - final Set activeProfiles = new LinkedHashSet(); + final Set activeProfiles = new LinkedHashSet<>(); for (String[] profiles : profileArrays) { for (String profile : profiles) { if (StringUtils.hasText(profile)) { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java index 968d2300e82..b5b0eb686b8 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java @@ -60,7 +60,7 @@ public abstract class AnnotationConfigContextLoaderUtils { public static Class[] detectDefaultConfigurationClasses(Class declaringClass) { Assert.notNull(declaringClass, "Declaring class must not be null"); - List> configClasses = new ArrayList>(); + List> configClasses = new ArrayList<>(); for (Class candidate : declaringClass.getDeclaredClasses()) { if (isDefaultConfigurationClassCandidate(candidate)) { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java index aa6420d4b72..013d3f7e6d0 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ abstract class ApplicationContextInitializerUtils { Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be empty"); final Set>> initializerClasses = // - new HashSet>>(); + new HashSet<>(); for (ContextConfigurationAttributes configAttributes : configAttributesList) { if (logger.isTraceEnabled()) { diff --git a/spring-test/src/main/java/org/springframework/test/context/support/ContextLoaderUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/ContextLoaderUtils.java index 49819fd546f..71dc4330ee7 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/ContextLoaderUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/ContextLoaderUtils.java @@ -97,7 +97,7 @@ abstract class ContextLoaderUtils { Class contextConfigType = ContextConfiguration.class; Class contextHierarchyType = ContextHierarchy.class; - List> hierarchyAttributes = new ArrayList>(); + List> hierarchyAttributes = new ArrayList<>(); UntypedAnnotationDescriptor desc = findAnnotationDescriptorForTypes(testClass, contextConfigType, contextHierarchyType); @@ -122,7 +122,7 @@ abstract class ContextLoaderUtils { throw new IllegalStateException(msg); } - List configAttributesList = new ArrayList(); + List configAttributesList = new ArrayList<>(); if (contextConfigDeclaredLocally) { ContextConfiguration contextConfiguration = AnnotationUtils.synthesizeAnnotation( @@ -178,7 +178,7 @@ abstract class ContextLoaderUtils { * @see #resolveContextHierarchyAttributes(Class) */ static Map> buildContextHierarchyMap(Class testClass) { - final Map> map = new LinkedHashMap>(); + final Map> map = new LinkedHashMap<>(); int hierarchyLevel = 1; for (List configAttributesList : resolveContextHierarchyAttributes(testClass)) { @@ -193,7 +193,7 @@ abstract class ContextLoaderUtils { // Encountered a new context hierarchy level? if (!map.containsKey(name)) { hierarchyLevel++; - map.put(name, new ArrayList()); + map.put(name, new ArrayList<>()); } map.get(name).add(configAttributes); @@ -201,7 +201,7 @@ abstract class ContextLoaderUtils { } // Check for uniqueness - Set> set = new HashSet>(map.values()); + Set> set = new HashSet<>(map.values()); if (set.size() != map.size()) { String msg = String.format("The @ContextConfiguration elements configured via @ContextHierarchy in " + "test class [%s] and its superclasses must define unique contexts per hierarchy level.", @@ -233,7 +233,7 @@ abstract class ContextLoaderUtils { static List resolveContextConfigurationAttributes(Class testClass) { Assert.notNull(testClass, "Class must not be null"); - List attributesList = new ArrayList(); + List attributesList = new ArrayList<>(); Class annotationType = ContextConfiguration.class; AnnotationDescriptor descriptor = findAnnotationDescriptor(testClass, annotationType); diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DefaultActiveProfilesResolver.java b/spring-test/src/main/java/org/springframework/test/context/support/DefaultActiveProfilesResolver.java index e1de32a8ccc..9f770f2bf2e 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DefaultActiveProfilesResolver.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DefaultActiveProfilesResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class DefaultActiveProfilesResolver implements ActiveProfilesResolver { public String[] resolve(Class testClass) { Assert.notNull(testClass, "Class must not be null"); - final Set activeProfiles = new LinkedHashSet(); + final Set activeProfiles = new LinkedHashSet<>(); Class annotationType = ActiveProfiles.class; AnnotationDescriptor descriptor = findAnnotationDescriptor(testClass, annotationType); diff --git a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java index 47e488cf29d..6cc0c8b7f69 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/TestPropertySourceUtils.java @@ -85,7 +85,7 @@ public abstract class TestPropertySourceUtils { private static List resolveTestPropertySourceAttributes(Class testClass) { Assert.notNull(testClass, "Class must not be null"); - final List attributesList = new ArrayList(); + final List attributesList = new ArrayList<>(); final Class annotationType = TestPropertySource.class; AnnotationDescriptor descriptor = findAnnotationDescriptor(testClass, annotationType); Assert.notNull(descriptor, String.format( @@ -115,7 +115,7 @@ public abstract class TestPropertySourceUtils { } private static String[] mergeLocations(List attributesList) { - final List locations = new ArrayList(); + final List locations = new ArrayList<>(); for (TestPropertySourceAttributes attrs : attributesList) { if (logger.isTraceEnabled()) { @@ -135,7 +135,7 @@ public abstract class TestPropertySourceUtils { } private static String[] mergeProperties(List attributesList) { - final List properties = new ArrayList(); + final List properties = new ArrayList<>(); for (TestPropertySourceAttributes attrs : attributesList) { if (logger.isTraceEnabled()) { @@ -255,7 +255,7 @@ public abstract class TestPropertySourceUtils { } MapPropertySource ps = (MapPropertySource) environment.getPropertySources().get(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME); if (ps == null) { - ps = new MapPropertySource(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME, new LinkedHashMap()); + ps = new MapPropertySource(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME, new LinkedHashMap<>()); environment.getPropertySources().addFirst(ps); } ps.getSource().putAll(convertInlinedPropertiesToMap(inlinedProperties)); @@ -281,7 +281,7 @@ public abstract class TestPropertySourceUtils { */ public static Map convertInlinedPropertiesToMap(String... inlinedProperties) { Assert.notNull(inlinedProperties, "inlinedProperties must not be null"); - Map map = new LinkedHashMap(); + Map map = new LinkedHashMap<>(); Properties props = new Properties(); for (String pair : inlinedProperties) { diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java index 9f1a102d44c..2cb89c67209 100644 --- a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java +++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +26,8 @@ import org.springframework.core.NamedInheritableThreadLocal; */ class TransactionContextHolder { - private static final ThreadLocal currentTransactionContext = new NamedInheritableThreadLocal( - "Test Transaction Context"); + private static final ThreadLocal currentTransactionContext = new NamedInheritableThreadLocal<>( + "Test Transaction Context"); static TransactionContext getCurrentTransactionContext() { diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java index 356eb3d053e..b5323369914 100644 --- a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java @@ -442,7 +442,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis * as well as annotated interface default methods */ private List getAnnotatedMethods(Class clazz, Class annotationType) { - List methods = new ArrayList(4); + List methods = new ArrayList<>(4); for (Method method : ReflectionUtils.getUniqueDeclaredMethods(clazz)) { if (AnnotationUtils.getAnnotation(method, annotationType) != null) { methods.add(method); diff --git a/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java b/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java index dd3e74d4e44..dcb866c7f86 100644 --- a/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/util/TestContextResourceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,7 +114,7 @@ public abstract class TestContextResourceUtils { * @see #convertToClasspathResourcePaths */ public static List convertToResourceList(ResourceLoader resourceLoader, String... paths) { - List list = new ArrayList(); + List list = new ArrayList<>(); for (String path : paths) { list.add(resourceLoader.getResource(path)); } diff --git a/spring-test/src/main/java/org/springframework/test/util/MetaAnnotationUtils.java b/spring-test/src/main/java/org/springframework/test/util/MetaAnnotationUtils.java index 9c203d743e2..df203284ef0 100644 --- a/spring-test/src/main/java/org/springframework/test/util/MetaAnnotationUtils.java +++ b/spring-test/src/main/java/org/springframework/test/util/MetaAnnotationUtils.java @@ -83,7 +83,7 @@ public abstract class MetaAnnotationUtils { public static AnnotationDescriptor findAnnotationDescriptor( Class clazz, Class annotationType) { - return findAnnotationDescriptor(clazz, new HashSet(), annotationType); + return findAnnotationDescriptor(clazz, new HashSet<>(), annotationType); } /** @@ -106,7 +106,7 @@ public abstract class MetaAnnotationUtils { // Declared locally? if (AnnotationUtils.isAnnotationDeclaredLocally(annotationType, clazz)) { - return new AnnotationDescriptor(clazz, clazz.getAnnotation(annotationType)); + return new AnnotationDescriptor<>(clazz, clazz.getAnnotation(annotationType)); } // Declared on a composed annotation (i.e., as a meta-annotation)? @@ -115,7 +115,7 @@ public abstract class MetaAnnotationUtils { AnnotationDescriptor descriptor = findAnnotationDescriptor( composedAnnotation.annotationType(), visited, annotationType); if (descriptor != null) { - return new AnnotationDescriptor( + return new AnnotationDescriptor<>( clazz, descriptor.getDeclaringClass(), composedAnnotation, descriptor.getAnnotation()); } } @@ -125,8 +125,8 @@ public abstract class MetaAnnotationUtils { for (Class ifc : clazz.getInterfaces()) { AnnotationDescriptor descriptor = findAnnotationDescriptor(ifc, visited, annotationType); if (descriptor != null) { - return new AnnotationDescriptor(clazz, descriptor.getDeclaringClass(), - descriptor.getComposedAnnotation(), descriptor.getAnnotation()); + return new AnnotationDescriptor<>(clazz, descriptor.getDeclaringClass(), + descriptor.getComposedAnnotation(), descriptor.getAnnotation()); } } @@ -168,7 +168,7 @@ public abstract class MetaAnnotationUtils { public static UntypedAnnotationDescriptor findAnnotationDescriptorForTypes( Class clazz, Class... annotationTypes) { - return findAnnotationDescriptorForTypes(clazz, new HashSet(), annotationTypes); + return findAnnotationDescriptorForTypes(clazz, new HashSet<>(), annotationTypes); } /** diff --git a/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java b/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java index 6cbbfcd9775..e8f7165fd13 100644 --- a/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java +++ b/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -200,7 +200,7 @@ public abstract class ModelAndViewAssert { private static void appendNonMatchingSetsErrorMessage(Set assertionSet, Set incorrectSet, StringBuilder sb) { - Set tempSet = new HashSet(); + Set tempSet = new HashSet<>(); tempSet.addAll(incorrectSet); tempSet.removeAll(assertionSet); @@ -213,7 +213,7 @@ public abstract class ModelAndViewAssert { } } - tempSet = new HashSet(); + tempSet = new HashSet<>(); tempSet.addAll(assertionSet); tempSet.removeAll(incorrectSet); diff --git a/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java b/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java index 37139cb7334..41b1f2448ca 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/AbstractRequestExpectationManager.java @@ -42,9 +42,9 @@ import org.springframework.util.Assert; */ public abstract class AbstractRequestExpectationManager implements RequestExpectationManager { - private final List expectations = new LinkedList(); + private final List expectations = new LinkedList<>(); - private final List requests = new LinkedList(); + private final List requests = new LinkedList<>(); protected List getExpectations() { @@ -147,7 +147,7 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect */ protected static class RequestExpectationGroup { - private final Set expectations = new LinkedHashSet(); + private final Set expectations = new LinkedHashSet<>(); public Set getExpectations() { return this.expectations; diff --git a/spring-test/src/main/java/org/springframework/test/web/client/DefaultRequestExpectation.java b/spring-test/src/main/java/org/springframework/test/web/client/DefaultRequestExpectation.java index 93a4752aaab..1755842ada4 100644 --- a/spring-test/src/main/java/org/springframework/test/web/client/DefaultRequestExpectation.java +++ b/spring-test/src/main/java/org/springframework/test/web/client/DefaultRequestExpectation.java @@ -35,7 +35,7 @@ public class DefaultRequestExpectation implements RequestExpectation { private final RequestCount requestCount; - private final List requestMatchers = new LinkedList(); + private final List requestMatchers = new LinkedList<>(); private ResponseCreator responseCreator; diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/DefaultMvcResult.java b/spring-test/src/main/java/org/springframework/test/web/servlet/DefaultMvcResult.java index 4bf5f8dd10f..87a79278212 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/DefaultMvcResult.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/DefaultMvcResult.java @@ -49,7 +49,7 @@ class DefaultMvcResult implements MvcResult { private Exception resolvedException; - private final AtomicReference asyncResult = new AtomicReference(RESULT_NONE); + private final AtomicReference asyncResult = new AtomicReference<>(RESULT_NONE); /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java b/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java index 360bf33c255..97c4e84d2ad 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,9 +70,9 @@ public final class MockMvc { private RequestBuilder defaultRequestBuilder; - private List defaultResultMatchers = new ArrayList(); + private List defaultResultMatchers = new ArrayList<>(); - private List defaultResultHandlers = new ArrayList(); + private List defaultResultHandlers = new ArrayList<>(); /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java index 28f9f0b4fa7..3a06cd8a269 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java @@ -56,7 +56,7 @@ import com.gargoylesoftware.htmlunit.WebRequest; */ public final class HostRequestMatcher implements WebRequestMatcher { - private final Set hosts = new HashSet(); + private final Set hosts = new HashSet<>(); /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java index 4fdaa22a043..d92695268c1 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilder.java @@ -253,7 +253,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable { } private void cookies(MockHttpServletRequest request) { - List cookies = new ArrayList(); + List cookies = new ArrayList<>(); String cookieHeaderValue = header("Cookie"); if (cookieHeaderValue != null) { diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java index ada749840c5..d6ea3707598 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java @@ -57,7 +57,7 @@ import org.springframework.util.Assert; */ public final class MockMvcWebConnection implements WebConnection { - private final Map sessions = new HashMap(); + private final Map sessions = new HashMap<>(); private final MockMvc mockMvc; diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java index 7e88a064d8a..3edf482474d 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnectionBuilderSupport.java @@ -45,7 +45,7 @@ public abstract class MockMvcWebConnectionBuilderSupport requestMatchers = new ArrayList(); + private final List requestMatchers = new ArrayList<>(); private String contextPath = ""; @@ -159,7 +159,7 @@ public abstract class MockMvcWebConnectionBuilderSupport delegates = new ArrayList(this.requestMatchers.size()); + List delegates = new ArrayList<>(this.requestMatchers.size()); for (WebRequestMatcher matcher : this.requestMatchers) { delegates.add(new DelegateWebConnection(matcher, connection)); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilder.java index fd716f476cb..0db002b1b94 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilder.java @@ -94,7 +94,7 @@ final class MockWebResponseBuilder { private List responseHeaders() { Collection headerNames = this.response.getHeaderNames(); - List responseHeaders = new ArrayList(headerNames.size()); + List responseHeaders = new ArrayList<>(headerNames.size()); for (String headerName : headerNames) { List headerValues = this.response.getHeaderValues(headerName); for (Object value : headerValues) { diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 65be88c5ce5..b7fcd6be4d4 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -82,15 +82,15 @@ public class MockHttpServletRequestBuilder private final URI url; - private final MultiValueMap headers = new LinkedMultiValueMap(); + private final MultiValueMap headers = new LinkedMultiValueMap<>(); private String contentType; private byte[] content; - private final MultiValueMap parameters = new LinkedMultiValueMap(); + private final MultiValueMap parameters = new LinkedMultiValueMap<>(); - private final List cookies = new ArrayList(); + private final List cookies = new ArrayList<>(); private Locale locale; @@ -100,13 +100,13 @@ public class MockHttpServletRequestBuilder private Principal principal; - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private MockHttpSession session; - private final Map sessionAttributes = new LinkedHashMap(); + private final Map sessionAttributes = new LinkedHashMap<>(); - private final Map flashAttributes = new LinkedHashMap(); + private final Map flashAttributes = new LinkedHashMap<>(); private String contextPath = ""; @@ -114,7 +114,7 @@ public class MockHttpServletRequestBuilder private String pathInfo = ValueConstants.DEFAULT_NONE; - private final List postProcessors = new ArrayList(); + private final List postProcessors = new ArrayList<>(); /** @@ -250,7 +250,7 @@ public class MockHttpServletRequestBuilder */ public MockHttpServletRequestBuilder accept(String... mediaTypes) { Assert.notEmpty(mediaTypes, "No 'Accept' media types"); - List result = new ArrayList(mediaTypes.length); + List result = new ArrayList<>(mediaTypes.length); for (String mediaType : mediaTypes) { result.add(MediaType.parseMediaType(mediaType)); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java index b56e8a9f152..cb437797ad7 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockMultipartHttpServletRequestBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.mock.web.MockMultipartHttpServletRequest; */ public class MockMultipartHttpServletRequestBuilder extends MockHttpServletRequestBuilder { - private final List files = new ArrayList(); + private final List files = new ArrayList<>(); /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/PrintingResultHandler.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/PrintingResultHandler.java index c559ff11026..8f0f32953af 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/PrintingResultHandler.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/PrintingResultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,7 +124,7 @@ public class PrintingResultHandler implements ResultHandler { protected final MultiValueMap getParamsMultiValueMap(MockHttpServletRequest request) { Map params = request.getParameterMap(); - MultiValueMap multiValueMap = new LinkedMultiValueMap(); + MultiValueMap multiValueMap = new LinkedMultiValueMap<>(); for (String name : params.keySet()) { if (params.get(name) != null) { for (String value : params.get(name)) { diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java index 50c4db84c27..98227c80f65 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/AbstractMockMvcBuilder.java @@ -47,17 +47,17 @@ import org.springframework.web.context.WebApplicationContext; public abstract class AbstractMockMvcBuilder> extends MockMvcBuilderSupport implements ConfigurableMockMvcBuilder { - private List filters = new ArrayList(); + private List filters = new ArrayList<>(); private RequestBuilder defaultRequestBuilder; - private final List globalResultMatchers = new ArrayList(); + private final List globalResultMatchers = new ArrayList<>(); - private final List globalResultHandlers = new ArrayList(); + private final List globalResultHandlers = new ArrayList<>(); private Boolean dispatchOptions = Boolean.TRUE; - private final List configurers = new ArrayList(4); + private final List configurers = new ArrayList<>(4); @SuppressWarnings("unchecked") diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java index 7ae98a634bc..868c0a7b92b 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/PatternMappingFilterProxy.java @@ -49,13 +49,13 @@ final class PatternMappingFilterProxy implements Filter { private final Filter delegate; /** Patterns that require an exact match, e.g. "/test" */ - private final List exactMatches = new ArrayList(); + private final List exactMatches = new ArrayList<>(); /** Patterns that require the URL to have a specific prefix, e.g. "/test/*" */ - private final List startsWithMatches = new ArrayList(); + private final List startsWithMatches = new ArrayList<>(); /** Patterns that require the request URL to have a specific suffix, e.g. "*.html" */ - private final List endsWithMatches = new ArrayList(); + private final List endsWithMatches = new ArrayList<>(); /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java index bf965cca422..568b93840ca 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,13 +89,13 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder controllerAdvice; - private List> messageConverters = new ArrayList>(); + private List> messageConverters = new ArrayList<>(); - private List customArgumentResolvers = new ArrayList(); + private List customArgumentResolvers = new ArrayList<>(); - private List customReturnValueHandlers = new ArrayList(); + private List customReturnValueHandlers = new ArrayList<>(); - private final List mappedInterceptors = new ArrayList(); + private final List mappedInterceptors = new ArrayList<>(); private Validator validator = null; @@ -119,7 +119,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder placeHolderValues = new HashMap(); + private Map placeHolderValues = new HashMap<>(); /** diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java index 5b5643183e7..afa37457bec 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,7 +157,7 @@ public class MockHttpServletRequestTests { public void setMultipleParameters() { request.setParameter("key1", "value1"); request.setParameter("key2", "value2"); - Map params = new HashMap(2); + Map params = new HashMap<>(2); params.put("key1", "newValue1"); params.put("key3", new String[] { "value3A", "value3B" }); request.setParameters(params); @@ -175,7 +175,7 @@ public class MockHttpServletRequestTests { public void addMultipleParameters() { request.setParameter("key1", "value1"); request.setParameter("key2", "value2"); - Map params = new HashMap(2); + Map params = new HashMap<>(2); params.put("key1", "newValue1"); params.put("key3", new String[] { "value3A", "value3B" }); request.addParameters(params); @@ -193,7 +193,7 @@ public class MockHttpServletRequestTests { @Test public void removeAllParameters() { request.setParameter("key1", "value1"); - Map params = new HashMap(2); + Map params = new HashMap<>(2); params.put("key2", "value2"); params.put("key3", new String[] { "value3A", "value3B" }); request.addParameters(params); @@ -245,7 +245,7 @@ public class MockHttpServletRequestTests { @Test(expected = IllegalArgumentException.class) public void setPreferredLocalesWithEmptyList() { - request.setPreferredLocales(new ArrayList()); + request.setPreferredLocales(new ArrayList<>()); } @Test diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java index f74ea338196..47c6cb208f4 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class MockMultipartHttpServletRequestTests { } private void doTestMultipartHttpServletRequest(MultipartHttpServletRequest request) throws IOException { - Set fileNames = new HashSet(); + Set fileNames = new HashSet<>(); Iterator fileIter = request.getFileNames(); while (fileIter.hasNext()) { fileNames.add(fileIter.next()); @@ -73,7 +73,7 @@ public class MockMultipartHttpServletRequestTests { MultipartFile file1 = request.getFile("file1"); MultipartFile file2 = request.getFile("file2"); Map fileMap = request.getFileMap(); - List fileMapKeys = new LinkedList(fileMap.keySet()); + List fileMapKeys = new LinkedList<>(fileMap.keySet()); assertEquals(2, fileMapKeys.size()); assertEquals(file1, fileMap.get("file1")); assertEquals(file2, fileMap.get("file2")); diff --git a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java index 0409e11f69f..a74b9c55caf 100644 --- a/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/MergedContextConfigurationTests.java @@ -172,12 +172,12 @@ public class MergedContextConfigurationTests { @Test public void hashCodeWithSameInitializers() { Set>> initializerClasses1 = - new HashSet>>(); + new HashSet<>(); initializerClasses1.add(FooInitializer.class); initializerClasses1.add(BarInitializer.class); Set>> initializerClasses2 = - new HashSet>>(); + new HashSet<>(); initializerClasses2.add(BarInitializer.class); initializerClasses2.add(FooInitializer.class); @@ -191,11 +191,11 @@ public class MergedContextConfigurationTests { @Test public void hashCodeWithDifferentInitializers() { Set>> initializerClasses1 = - new HashSet>>(); + new HashSet<>(); initializerClasses1.add(FooInitializer.class); Set>> initializerClasses2 = - new HashSet>>(); + new HashSet<>(); initializerClasses2.add(BarInitializer.class); MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), @@ -369,12 +369,12 @@ public class MergedContextConfigurationTests { @Test public void equalsWithSameInitializers() { Set>> initializerClasses1 = - new HashSet>>(); + new HashSet<>(); initializerClasses1.add(FooInitializer.class); initializerClasses1.add(BarInitializer.class); Set>> initializerClasses2 = - new HashSet>>(); + new HashSet<>(); initializerClasses2.add(BarInitializer.class); initializerClasses2.add(FooInitializer.class); @@ -388,11 +388,11 @@ public class MergedContextConfigurationTests { @Test public void equalsWithDifferentInitializers() { Set>> initializerClasses1 = - new HashSet>>(); + new HashSet<>(); initializerClasses1.add(FooInitializer.class); Set>> initializerClasses2 = - new HashSet>>(); + new HashSet<>(); initializerClasses2.add(BarInitializer.class); MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), diff --git a/spring-test/src/test/java/org/springframework/test/context/TestContextManagerTests.java b/spring-test/src/test/java/org/springframework/test/context/TestContextManagerTests.java index 560a8542bd3..3070ba4900d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/TestContextManagerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/TestContextManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,8 +48,8 @@ public class TestContextManagerTests { private static final String SECOND = "vidi"; private static final String THIRD = "vici"; - private static final List afterTestMethodCalls = new ArrayList(); - private static final List beforeTestMethodCalls = new ArrayList(); + private static final List afterTestMethodCalls = new ArrayList<>(); + private static final List beforeTestMethodCalls = new ArrayList<>(); protected static final Log logger = LogFactory.getLog(TestContextManagerTests.class); @@ -72,10 +72,10 @@ public class TestContextManagerTests { List expectedAfterTestMethodCalls, final String usageContext) { if (expectedBeforeTestMethodCalls == null) { - expectedBeforeTestMethodCalls = new ArrayList(); + expectedBeforeTestMethodCalls = new ArrayList<>(); } if (expectedAfterTestMethodCalls == null) { - expectedAfterTestMethodCalls = new ArrayList(); + expectedAfterTestMethodCalls = new ArrayList<>(); } if (logger.isDebugEnabled()) { diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/ExpectedExceptionSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/ExpectedExceptionSpringRunnerTests.java index 4cfb46994ae..2ea416817c3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/ExpectedExceptionSpringRunnerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/ExpectedExceptionSpringRunnerTests.java @@ -50,7 +50,7 @@ public class ExpectedExceptionSpringRunnerTests { // Should Pass. @Test(expected = IndexOutOfBoundsException.class) public void verifyJUnitExpectedException() { - new ArrayList().get(1); + new ArrayList<>().get(1); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/StandardJUnit4FeaturesTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/StandardJUnit4FeaturesTests.java index 0a7699708e2..817a5cfbb8c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/StandardJUnit4FeaturesTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/StandardJUnit4FeaturesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public class StandardJUnit4FeaturesTests { @Test(expected = IndexOutOfBoundsException.class) public void expectingAnIndexOutOfBoundsException() { - new ArrayList().get(1); + new ArrayList<>().get(1); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java index cf876a87a33..a5cb8acfad6 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr9051/AnnotatedConfigClassesWithoutAtConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,9 +93,9 @@ public class AnnotatedConfigClassesWithoutAtConfigurationTests { assertNotNull(enigma); assertNotNull(lifecycleBean); assertTrue(lifecycleBean.isInitialized()); - Set names = new HashSet(); + Set names = new HashSet<>(); names.add(enigma.toString()); names.add(lifecycleBean.getName()); - assertEquals(names, new HashSet(Arrays.asList("enigma #1", "enigma #2"))); + assertEquals(names, new HashSet<>(Arrays.asList("enigma #1", "enigma #2"))); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/support/ActiveProfilesUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/ActiveProfilesUtilsTests.java index f9f4013c39c..6be602776f3 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/ActiveProfilesUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/ActiveProfilesUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -378,7 +378,7 @@ public class ActiveProfilesUtilsTests extends AbstractContextConfigurationUtilsT @Override public String[] resolve(Class testClass) { - List profiles = new ArrayList(Arrays.asList(super.resolve(testClass))); + List profiles = new ArrayList<>(Arrays.asList(super.resolve(testClass))); profiles.add("foo"); return StringUtils.toStringArray(profiles); } diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatchersIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatchersIntegrationTests.java index d6c1d876b32..4837d5bce9e 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatchersIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/ContentRequestMatchersIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class ContentRequestMatchersIntegrationTests { @Before public void setup() { - List> converters = new ArrayList>(); + List> converters = new ArrayList<>(); converters.add(new StringHttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter()); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatchersIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatchersIntegrationTests.java index 1b56ffa28b2..0d7df2f11dc 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatchersIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/HeaderRequestMatchersIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class HeaderRequestMatchersIntegrationTests { @Before public void setup() { - List> converters = new ArrayList>(); + List> converters = new ArrayList<>(); converters.add(new StringHttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter()); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java index 91d670b347c..c5183618480 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/JsonPathRequestMatchersIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat */ public class JsonPathRequestMatchersIntegrationTests { - private static final MultiValueMap people = new LinkedMultiValueMap(); + private static final MultiValueMap people = new LinkedMultiValueMap<>(); static { people.add("composers", new Person("Johann Sebastian Bach")); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XmlContentRequestMatchersIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XmlContentRequestMatchersIntegrationTests.java index 0d4fba55c74..3a5ab147a59 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XmlContentRequestMatchersIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XmlContentRequestMatchersIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ public class XmlContentRequestMatchersIntegrationTests { this.people = new PeopleWrapper(composers); - List> converters = new ArrayList>(); + List> converters = new ArrayList<>(); converters.add(new Jaxb2RootElementHttpMessageConverter()); this.restTemplate = new RestTemplate(); diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java index 49a30591845..820d704f5e7 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/matchers/XpathRequestMatchersIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public class XpathRequestMatchersIntegrationTests { this.people = new PeopleWrapper(composers, performers); - List> converters = new ArrayList>(); + List> converters = new ArrayList<>(); converters.add(new Jaxb2RootElementHttpMessageConverter()); this.restTemplate = new RestTemplate(); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java index feffb296536..6dbc1e9e61d 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/PrintingResultHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ public class PrintingResultHandlerTests { HttpHeaders headers = new HttpHeaders(); headers.set("header", "headerValue"); - MultiValueMap params = new LinkedMultiValueMap(); + MultiValueMap params = new LinkedMultiValueMap<>(); params.add("param", "paramValue"); assertValue("MockHttpServletRequest", "HTTP Method", this.request.getMethod()); @@ -243,12 +243,12 @@ public class PrintingResultHandlerTests { private String printedHeading; - private Map> printedValues = new HashMap>(); + private Map> printedValues = new HashMap<>(); @Override public void printHeading(String heading) { this.printedHeading = heading; - this.printedValues.put(heading, new HashMap()); + this.printedValues.put(heading, new HashMap<>()); } @Override diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java index ead30b9ecb1..5039b895ee5 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/StatusResultMatchersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class StatusResultMatchersTests { @Test public void testHttpStatusCodeResultMatchers() throws Exception { - List failures = new ArrayList(); + List failures = new ArrayList<>(); for (HttpStatus status : HttpStatus.values()) { MockHttpServletResponse response = new MockHttpServletResponse(); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java index ee8f505e516..1d85e92e265 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java @@ -173,10 +173,10 @@ public class AsyncTests { private static class AsyncController { private final Collection> deferredResults = - new CopyOnWriteArrayList>(); + new CopyOnWriteArrayList<>(); private final Collection> futureTasks = - new CopyOnWriteArrayList>(); + new CopyOnWriteArrayList<>(); @RequestMapping(params = "callable") @@ -186,21 +186,21 @@ public class AsyncTests { @RequestMapping(params = "deferredResult") public DeferredResult getDeferredResult() { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); this.deferredResults.add(deferredResult); return deferredResult; } @RequestMapping(params = "deferredResultWithImmediateValue") public DeferredResult getDeferredResultWithImmediateValue() { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); deferredResult.setResult(new Person("Joe")); return deferredResult; } @RequestMapping(params = "deferredResultWithDelayedError") public DeferredResult getDeferredResultWithDelayedError() { - final DeferredResult deferredResult = new DeferredResult(); + final DeferredResult deferredResult = new DeferredResult<>(); new Thread() { public void run() { try { @@ -217,14 +217,14 @@ public class AsyncTests { @RequestMapping(params = "listenableFuture") public ListenableFuture getListenableFuture() { - ListenableFutureTask futureTask = new ListenableFutureTask(() -> new Person("Joe")); + ListenableFutureTask futureTask = new ListenableFutureTask<>(() -> new Person("Joe")); this.futureTasks.add(futureTask); return futureTask; } @RequestMapping(params = "completableFutureWithImmediateValue") public CompletableFuture getCompletableFutureWithImmediateValue() { - CompletableFuture future = new CompletableFuture(); + CompletableFuture future = new CompletableFuture<>(); future.complete(new Person("Joe")); return future; } diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java index b286f626c1d..001a2c69ce0 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ViewResolutionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,7 +89,7 @@ public class ViewResolutionTests { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(Person.class); - List viewList = new ArrayList(); + List viewList = new ArrayList<>(); viewList.add(new MappingJackson2JsonView()); viewList.add(new MarshallingView(marshaller)); diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java index f7f5a025a23..91ee86a6dd4 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/JsonPathAssertionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +121,7 @@ public class JsonPathAssertionTests { @RequestMapping("/music/people") public MultiValueMap get() { - MultiValueMap map = new LinkedMultiValueMap(); + MultiValueMap map = new LinkedMultiValueMap<>(); map.add("composers", new Person("Johann Sebastian Bach")); map.add("composers", new Person("Johannes Brahms")); diff --git a/spring-tx/src/main/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslator.java b/spring-tx/src/main/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslator.java index d86c5aeb118..9c09bd00d99 100644 --- a/spring-tx/src/main/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslator.java +++ b/spring-tx/src/main/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.util.Assert; public class ChainedPersistenceExceptionTranslator implements PersistenceExceptionTranslator { /** List of PersistenceExceptionTranslators */ - private final List delegates = new ArrayList(4); + private final List delegates = new ArrayList<>(4); /** diff --git a/spring-tx/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java b/spring-tx/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java index 78f3b29a716..8bdb6c03ba9 100644 --- a/spring-tx/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java +++ b/spring-tx/src/main/java/org/springframework/jca/cci/connection/ConnectionSpecConnectionFactoryAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class ConnectionSpecConnectionFactoryAdapter extends DelegatingConnection private ConnectionSpec connectionSpec; private final ThreadLocal threadBoundSpec = - new NamedThreadLocal("Current CCI ConnectionSpec"); + new NamedThreadLocal<>("Current CCI ConnectionSpec"); /** diff --git a/spring-tx/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java b/spring-tx/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java index 532ea23e7c3..fd24159daf7 100644 --- a/spring-tx/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java +++ b/spring-tx/src/main/java/org/springframework/jca/work/WorkManagerTaskExecutor.java @@ -258,28 +258,28 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport @Override public Future submit(Runnable task) { - FutureTask future = new FutureTask(task, null); + FutureTask future = new FutureTask<>(task, null); execute(future, TIMEOUT_INDEFINITE); return future; } @Override public Future submit(Callable task) { - FutureTask future = new FutureTask(task); + FutureTask future = new FutureTask<>(task); execute(future, TIMEOUT_INDEFINITE); return future; } @Override public ListenableFuture submitListenable(Runnable task) { - ListenableFutureTask future = new ListenableFutureTask(task, null); + ListenableFutureTask future = new ListenableFutureTask<>(task, null); execute(future, TIMEOUT_INDEFINITE); return future; } @Override public ListenableFuture submitListenable(Callable task) { - ListenableFutureTask future = new ListenableFutureTask(task); + ListenableFutureTask future = new ListenableFutureTask<>(task); execute(future, TIMEOUT_INDEFINITE); return future; } diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java index 476d6b14f5c..7d04a4c02e2 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa */ public AnnotationTransactionAttributeSource(boolean publicMethodsOnly) { this.publicMethodsOnly = publicMethodsOnly; - this.annotationParsers = new LinkedHashSet(2); + this.annotationParsers = new LinkedHashSet<>(2); this.annotationParsers.add(new SpringTransactionAnnotationParser()); if (jta12Present) { this.annotationParsers.add(new JtaTransactionAnnotationParser()); @@ -112,7 +112,7 @@ public class AnnotationTransactionAttributeSource extends AbstractFallbackTransa public AnnotationTransactionAttributeSource(TransactionAnnotationParser... annotationParsers) { this.publicMethodsOnly = true; Assert.notEmpty(annotationParsers, "At least one TransactionAnnotationParser needs to be specified"); - Set parsers = new LinkedHashSet(annotationParsers.length); + Set parsers = new LinkedHashSet<>(annotationParsers.length); Collections.addAll(parsers, annotationParsers); this.annotationParsers = parsers; } diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/JtaTransactionAnnotationParser.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/JtaTransactionAnnotationParser.java index dcecefb54c3..5c667b967bc 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/JtaTransactionAnnotationParser.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/JtaTransactionAnnotationParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ public class JtaTransactionAnnotationParser implements TransactionAnnotationPars RuleBasedTransactionAttribute rbta = new RuleBasedTransactionAttribute(); rbta.setPropagationBehaviorName( RuleBasedTransactionAttribute.PREFIX_PROPAGATION + attributes.getEnum("value").toString()); - ArrayList rollBackRules = new ArrayList(); + ArrayList rollBackRules = new ArrayList<>(); Class[] rbf = attributes.getClassArray("rollbackOn"); for (Class rbRule : rbf) { RollbackRuleAttribute rule = new RollbackRuleAttribute(rbRule); diff --git a/spring-tx/src/main/java/org/springframework/transaction/annotation/SpringTransactionAnnotationParser.java b/spring-tx/src/main/java/org/springframework/transaction/annotation/SpringTransactionAnnotationParser.java index df9a3109465..2dc9f23a62c 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/annotation/SpringTransactionAnnotationParser.java +++ b/spring-tx/src/main/java/org/springframework/transaction/annotation/SpringTransactionAnnotationParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class SpringTransactionAnnotationParser implements TransactionAnnotationP rbta.setTimeout(attributes.getNumber("timeout").intValue()); rbta.setReadOnly(attributes.getBoolean("readOnly")); rbta.setQualifier(attributes.getString("value")); - ArrayList rollBackRules = new ArrayList(); + ArrayList rollBackRules = new ArrayList<>(); Class[] rbf = attributes.getClassArray("rollbackFor"); for (Class rbRule : rbf) { RollbackRuleAttribute rule = new RollbackRuleAttribute(rbRule); diff --git a/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java b/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java index c727c770ab7..db9fffb07c2 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java +++ b/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { private RootBeanDefinition parseAttributeSource(Element attrEle, ParserContext parserContext) { List methods = DomUtils.getChildElementsByTagName(attrEle, METHOD_ELEMENT); ManagedMap transactionAttributeMap = - new ManagedMap(methods.size()); + new ManagedMap<>(methods.size()); transactionAttributeMap.setSource(parserContext.extractSource(attrEle)); for (Element methodEle : methods) { @@ -127,7 +127,7 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { attribute.setReadOnly(Boolean.valueOf(methodEle.getAttribute(READ_ONLY_ATTRIBUTE))); } - List rollbackRules = new LinkedList(); + List rollbackRules = new LinkedList<>(); if (methodEle.hasAttribute(ROLLBACK_FOR_ATTRIBUTE)) { String rollbackForValue = methodEle.getAttribute(ROLLBACK_FOR_ATTRIBUTE); addRollbackRuleAttributesTo(rollbackRules,rollbackForValue); diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java index 206f3c82403..070613d5691 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java @@ -69,7 +69,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran *

As this base class is not marked Serializable, the cache will be recreated * after serialization - provided that the concrete subclass is Serializable. */ - final Map attributeCache = new ConcurrentHashMap(1024); + final Map attributeCache = new ConcurrentHashMap<>(1024); /** diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java index 81d5297240e..16692ca0bf6 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/MethodMapTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,10 +59,10 @@ public class MethodMapTransactionAttributeSource /** Map from Method to TransactionAttribute */ private final Map transactionAttributeMap = - new HashMap(); + new HashMap<>(); /** Map from Method to name pattern used for registration */ - private final Map methodNameMap = new HashMap(); + private final Map methodNameMap = new HashMap<>(); /** @@ -145,7 +145,7 @@ public class MethodMapTransactionAttributeSource String name = clazz.getName() + '.' + mappedName; Method[] methods = clazz.getDeclaredMethods(); - List matchingMethods = new ArrayList(); + List matchingMethods = new ArrayList<>(); for (Method method : methods) { if (isMatch(method.getName(), mappedName)) { matchingMethods.add(method); diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java index 571a5cdd9ae..edd9376ed4f 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/NameMatchTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class NameMatchTransactionAttributeSource implements TransactionAttribute protected static final Log logger = LogFactory.getLog(NameMatchTransactionAttributeSource.class); /** Keys are method names; values are TransactionAttributes */ - private Map nameMap = new HashMap(); + private Map nameMap = new HashMap<>(); /** diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttribute.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttribute.java index a4444aa1032..e0784b9979d 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttribute.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ public class RuleBasedTransactionAttribute extends DefaultTransactionAttribute i */ public RuleBasedTransactionAttribute(RuleBasedTransactionAttribute other) { super(other); - this.rollbackRules = new ArrayList(other.rollbackRules); + this.rollbackRules = new ArrayList<>(other.rollbackRules); } /** @@ -113,7 +113,7 @@ public class RuleBasedTransactionAttribute extends DefaultTransactionAttribute i */ public List getRollbackRules() { if (this.rollbackRules == null) { - this.rollbackRules = new LinkedList(); + this.rollbackRules = new LinkedList<>(); } return this.rollbackRules; } diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index 6888d46f035..9eef0e03b23 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,11 +82,11 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init * single method (as will be the case for around advice). */ private static final ThreadLocal transactionInfoHolder = - new NamedThreadLocal("Current aspect-driven transaction"); + new NamedThreadLocal<>("Current aspect-driven transaction"); private final ConcurrentHashMap transactionManagerCache = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); /** * Subclasses can use this to return the current TransactionInfo. diff --git a/spring-tx/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java b/spring-tx/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java index 9b7a07a0f58..3788905a329 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java +++ b/spring-tx/src/main/java/org/springframework/transaction/jta/WebSphereUowTransactionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -285,7 +285,7 @@ public class WebSphereUowTransactionManager extends JtaTransactionManager if (debug) { logger.debug("Invoking WebSphere UOW action: type=" + uowType + ", join=" + joinTx); } - UOWActionAdapter action = new UOWActionAdapter( + UOWActionAdapter action = new UOWActionAdapter<>( definition, callback, (uowType == UOWManager.UOW_TYPE_GLOBAL_TRANSACTION), !joinTx, newSynch, debug); this.uowManager.runUnderUOW(uowType, joinTx, action); if (debug) { diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java b/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java index 84a6668c75c..b4cf3a0a4b3 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java +++ b/spring-tx/src/main/java/org/springframework/transaction/support/SimpleTransactionScope.java @@ -90,9 +90,9 @@ public class SimpleTransactionScope implements Scope { static class ScopedObjectsHolder { - final Map scopedInstances = new HashMap(); + final Map scopedInstances = new HashMap<>(); - final Map destructionCallbacks = new LinkedHashMap(); + final Map destructionCallbacks = new LinkedHashMap<>(); } diff --git a/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java b/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java index 2f3cc69bfaa..8507d4296e7 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java +++ b/spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,22 +78,22 @@ public abstract class TransactionSynchronizationManager { private static final Log logger = LogFactory.getLog(TransactionSynchronizationManager.class); private static final ThreadLocal> resources = - new NamedThreadLocal>("Transactional resources"); + new NamedThreadLocal<>("Transactional resources"); private static final ThreadLocal> synchronizations = - new NamedThreadLocal>("Transaction synchronizations"); + new NamedThreadLocal<>("Transaction synchronizations"); private static final ThreadLocal currentTransactionName = - new NamedThreadLocal("Current transaction name"); + new NamedThreadLocal<>("Current transaction name"); private static final ThreadLocal currentTransactionReadOnly = - new NamedThreadLocal("Current transaction read-only status"); + new NamedThreadLocal<>("Current transaction read-only status"); private static final ThreadLocal currentTransactionIsolationLevel = - new NamedThreadLocal("Current transaction isolation level"); + new NamedThreadLocal<>("Current transaction isolation level"); private static final ThreadLocal actualTransactionActive = - new NamedThreadLocal("Actual transaction active"); + new NamedThreadLocal<>("Actual transaction active"); //------------------------------------------------------------------------- @@ -177,7 +177,7 @@ public abstract class TransactionSynchronizationManager { Map map = resources.get(); // set ThreadLocal Map if none found if (map == null) { - map = new HashMap(); + map = new HashMap<>(); resources.set(map); } Object oldValue = map.put(actualKey, value); @@ -270,7 +270,7 @@ public abstract class TransactionSynchronizationManager { throw new IllegalStateException("Cannot activate transaction synchronization - already active"); } logger.trace("Initializing transaction synchronization"); - synchronizations.set(new LinkedHashSet()); + synchronizations.set(new LinkedHashSet<>()); } /** @@ -313,7 +313,7 @@ public abstract class TransactionSynchronizationManager { } else { // Sort lazily here, not in registerSynchronization. - List sortedSynchs = new ArrayList(synchs); + List sortedSynchs = new ArrayList<>(synchs); AnnotationAwareOrderComparator.sort(sortedSynchs); return Collections.unmodifiableList(sortedSynchs); } diff --git a/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java b/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java index 2b8ad81d691..5be4b3470fe 100644 --- a/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class DataAccessUtilsTests { @Test public void withEmptyCollection() { - Collection col = new HashSet(); + Collection col = new HashSet<>(); assertNull(DataAccessUtils.uniqueResult(col)); @@ -87,7 +87,7 @@ public class DataAccessUtilsTests { @Test public void withTooLargeCollection() { - Collection col = new HashSet(2); + Collection col = new HashSet<>(2); col.add("test1"); col.add("test2"); @@ -144,7 +144,7 @@ public class DataAccessUtilsTests { @Test public void withInteger() { - Collection col = new HashSet(1); + Collection col = new HashSet<>(1); col.add(5); assertEquals(Integer.valueOf(5), DataAccessUtils.uniqueResult(col)); @@ -158,7 +158,7 @@ public class DataAccessUtilsTests { @Test public void withSameIntegerInstanceTwice() { Integer i = 5; - Collection col = new ArrayList(1); + Collection col = new ArrayList<>(1); col.add(i); col.add(i); @@ -172,7 +172,7 @@ public class DataAccessUtilsTests { @Test public void withEquivalentIntegerInstanceTwice() { - Collection col = new ArrayList(2); + Collection col = new ArrayList<>(2); col.add(new Integer(5)); col.add(new Integer(5)); @@ -189,7 +189,7 @@ public class DataAccessUtilsTests { @Test public void withLong() { - Collection col = new HashSet(1); + Collection col = new HashSet<>(1); col.add(5L); assertEquals(Long.valueOf(5L), DataAccessUtils.uniqueResult(col)); @@ -202,7 +202,7 @@ public class DataAccessUtilsTests { @Test public void withString() { - Collection col = new HashSet(1); + Collection col = new HashSet<>(1); col.add("test1"); assertEquals("test1", DataAccessUtils.uniqueResult(col)); @@ -229,7 +229,7 @@ public class DataAccessUtilsTests { @Test public void withDate() { Date date = new Date(); - Collection col = new HashSet(1); + Collection col = new HashSet<>(1); col.add(date); assertEquals(date, DataAccessUtils.uniqueResult(col)); @@ -276,7 +276,7 @@ public class DataAccessUtilsTests { /** * in to out */ - private Map translations = new HashMap(); + private Map translations = new HashMap<>(); public void addTranslation(RuntimeException in, RuntimeException out) { this.translations.put(in, out); diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java index 269da2cd04a..e1ab7217ec3 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/MapTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import java.util.Map; */ public class MapTransactionAttributeSource extends AbstractFallbackTransactionAttributeSource { - private final Map attributeMap = new HashMap(); + private final Map attributeMap = new HashMap<>(); public void register(Method method, TransactionAttribute txAtt) { diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java index e6a3c78e072..720582b767d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ public class RuleBasedTransactionAttributeTests { */ @Test public void testRuleForRollbackOnChecked() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new RollbackRuleAttribute(IOException.class.getName())); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); @@ -64,7 +64,7 @@ public class RuleBasedTransactionAttributeTests { @Test public void testRuleForCommitOnUnchecked() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new NoRollbackRuleAttribute(MyRuntimeException.class.getName())); list.add(new RollbackRuleAttribute(IOException.class.getName())); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); @@ -79,7 +79,7 @@ public class RuleBasedTransactionAttributeTests { @Test public void testRuleForSelectiveRollbackOnCheckedWithString() { - List l = new LinkedList(); + List l = new LinkedList<>(); l.add(new RollbackRuleAttribute(java.rmi.RemoteException.class.getName())); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, l); doTestRuleForSelectiveRollbackOnChecked(rta); @@ -106,7 +106,7 @@ public class RuleBasedTransactionAttributeTests { */ @Test public void testRuleForCommitOnSubclassOfChecked() { - List list = new LinkedList(); + List list = new LinkedList<>(); // Note that it's important to ensure that we have this as // a FQN: otherwise it will match everything! list.add(new RollbackRuleAttribute("java.lang.Exception")); @@ -121,7 +121,7 @@ public class RuleBasedTransactionAttributeTests { @Test public void testRollbackNever() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new NoRollbackRuleAttribute("Throwable")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); @@ -134,7 +134,7 @@ public class RuleBasedTransactionAttributeTests { @Test public void testToStringMatchesEditor() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new NoRollbackRuleAttribute("Throwable")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); @@ -154,7 +154,7 @@ public class RuleBasedTransactionAttributeTests { */ @Test public void testConflictingRulesToDetermineExactContract() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new NoRollbackRuleAttribute(MyBusinessWarningException.class)); list.add(new RollbackRuleAttribute(MyBusinessException.class)); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED, list); diff --git a/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java b/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java index 6542569118a..617748cf36e 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java +++ b/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,9 +42,9 @@ public class MockUOWManager implements UOWManager { private int status = UOW_STATUS_NONE; - private final Map resources = new HashMap(); + private final Map resources = new HashMap<>(); - private final List synchronizations = new LinkedList(); + private final List synchronizations = new LinkedList<>(); @Override diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index 8d7f3f37f2d..a9e4728b19a 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -148,7 +148,7 @@ public class SimpleTransactionScopeTests { CallCountingTransactionManager tm = new CallCountingTransactionManager(); TransactionTemplate tt = new TransactionTemplate(tm); - Set finallyDestroy = new HashSet(); + Set finallyDestroy = new HashSet<>(); tt.execute(status -> { TestBean bean1 = context.getBean(TestBean.class); @@ -173,7 +173,7 @@ public class SimpleTransactionScopeTests { assertNotSame(bean2, bean2b); assertNotSame(bean2a, bean2b); - Set immediatelyDestroy = new HashSet(); + Set immediatelyDestroy = new HashSet<>(); TransactionTemplate tt2 = new TransactionTemplate(tm); tt2.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED); tt2.execute(status2 -> { diff --git a/spring-web/src/main/java/org/springframework/http/HttpEntity.java b/spring-web/src/main/java/org/springframework/http/HttpEntity.java index b866c0bf4ca..6931ab77797 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpEntity.java +++ b/spring-web/src/main/java/org/springframework/http/HttpEntity.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class HttpEntity { /** * The empty {@code HttpEntity}, with no body or headers. */ - public static final HttpEntity EMPTY = new HttpEntity(); + public static final HttpEntity EMPTY = new HttpEntity<>(); private final HttpHeaders headers; diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index 697d4582148..d3f3a97c07e 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -392,7 +392,7 @@ public class HttpHeaders implements MultiValueMap, Serializable * Constructs a new, empty instance of the {@code HttpHeaders} object. */ public HttpHeaders() { - this(new LinkedCaseInsensitiveMap>(8, Locale.ENGLISH), false); + this(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH), false); } /** @@ -402,7 +402,7 @@ public class HttpHeaders implements MultiValueMap, Serializable Assert.notNull(headers, "'headers' must not be null"); if (readOnly) { Map> map = - new LinkedCaseInsensitiveMap>(headers.size(), Locale.ENGLISH); + new LinkedCaseInsensitiveMap<>(headers.size(), Locale.ENGLISH); for (Entry> entry : headers.entrySet()) { List values = Collections.unmodifiableList(entry.getValue()); map.put(entry.getKey(), values); @@ -483,7 +483,7 @@ public class HttpHeaders implements MultiValueMap, Serializable * Return the value of the {@code Access-Control-Allow-Methods} response header. */ public List getAccessControlAllowMethods() { - List result = new ArrayList(); + List result = new ArrayList<>(); String value = getFirst(ACCESS_CONTROL_ALLOW_METHODS); if (value != null) { String[] tokens = StringUtils.tokenizeToStringArray(value, ",", true, true); @@ -590,7 +590,7 @@ public class HttpHeaders implements MultiValueMap, Serializable * as specified by the {@code Accept-Charset} header. */ public List getAcceptCharset() { - List result = new ArrayList(); + List result = new ArrayList<>(); String value = getFirst(ACCEPT_CHARSET); if (value != null) { String[] tokens = value.split(",\\s*"); @@ -627,7 +627,7 @@ public class HttpHeaders implements MultiValueMap, Serializable public Set getAllow() { String value = getFirst(ALLOW); if (!StringUtils.isEmpty(value)) { - List result = new LinkedList(); + List result = new LinkedList<>(); String[] tokens = value.split(",\\s*"); for (String token : tokens) { HttpMethod resolved = HttpMethod.resolve(token); @@ -1063,7 +1063,7 @@ public class HttpHeaders implements MultiValueMap, Serializable public List getValuesAsList(String headerName) { List values = get(headerName); if (values != null) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (String value : values) { if (value != null) { String[] tokens = StringUtils.tokenizeToStringArray(value, ","); @@ -1086,7 +1086,7 @@ public class HttpHeaders implements MultiValueMap, Serializable protected List getETagValuesAsList(String headerName) { List values = get(headerName); if (values != null) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (String value : values) { if (value != null) { Matcher matcher = ETAG_HEADER_VALUE_PATTERN.matcher(value); @@ -1163,7 +1163,7 @@ public class HttpHeaders implements MultiValueMap, Serializable public void add(String headerName, String headerValue) { List headerValues = this.headers.get(headerName); if (headerValues == null) { - headerValues = new LinkedList(); + headerValues = new LinkedList<>(); this.headers.put(headerName, headerValues); } headerValues.add(headerValue); @@ -1179,7 +1179,7 @@ public class HttpHeaders implements MultiValueMap, Serializable */ @Override public void set(String headerName, String headerValue) { - List headerValues = new LinkedList(); + List headerValues = new LinkedList<>(); headerValues.add(headerValue); this.headers.put(headerName, headerValues); } @@ -1193,7 +1193,7 @@ public class HttpHeaders implements MultiValueMap, Serializable @Override public Map toSingleValueMap() { - LinkedHashMap singleValueMap = new LinkedHashMap(this.headers.size()); + LinkedHashMap singleValueMap = new LinkedHashMap<>(this.headers.size()); for (Entry> entry : this.headers.entrySet()) { singleValueMap.put(entry.getKey(), entry.getValue().get(0)); } diff --git a/spring-web/src/main/java/org/springframework/http/HttpMethod.java b/spring-web/src/main/java/org/springframework/http/HttpMethod.java index c38c46fc7ba..3a21183632d 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpMethod.java +++ b/spring-web/src/main/java/org/springframework/http/HttpMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public enum HttpMethod { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE; - private static final Map mappings = new HashMap(8); + private static final Map mappings = new HashMap<>(8); static { for (HttpMethod httpMethod : values()) { diff --git a/spring-web/src/main/java/org/springframework/http/HttpRange.java b/spring-web/src/main/java/org/springframework/http/HttpRange.java index 63d40e690a1..22f65a06963 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpRange.java +++ b/spring-web/src/main/java/org/springframework/http/HttpRange.java @@ -132,7 +132,7 @@ public abstract class HttpRange { ranges = ranges.substring(BYTE_RANGE_PREFIX.length()); String[] tokens = ranges.split(",\\s*"); - List result = new ArrayList(tokens.length); + List result = new ArrayList<>(tokens.length); for (String token : tokens) { result.add(parseRange(token)); } @@ -173,7 +173,7 @@ public abstract class HttpRange { if(ranges == null || ranges.size() == 0) { return Collections.emptyList(); } - List regions = new ArrayList(ranges.size()); + List regions = new ArrayList<>(ranges.size()); for(HttpRange range : ranges) { regions.add(range.toResourceRegion(resource)); } diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index 224ea717f13..7763febe033 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -374,7 +374,7 @@ public class MediaType extends MimeType implements Serializable { if (!mediaType.getParameters().containsKey(PARAM_QUALITY_FACTOR)) { return this; } - Map params = new LinkedHashMap(getParameters()); + Map params = new LinkedHashMap<>(getParameters()); params.put(PARAM_QUALITY_FACTOR, mediaType.getParameters().get(PARAM_QUALITY_FACTOR)); return new MediaType(this, params); } @@ -387,7 +387,7 @@ public class MediaType extends MimeType implements Serializable { if (!getParameters().containsKey(PARAM_QUALITY_FACTOR)) { return this; } - Map params = new LinkedHashMap(getParameters()); + Map params = new LinkedHashMap<>(getParameters()); params.remove(PARAM_QUALITY_FACTOR); return new MediaType(this, params); } @@ -438,7 +438,7 @@ public class MediaType extends MimeType implements Serializable { return Collections.emptyList(); } String[] tokens = mediaTypes.split(",\\s*"); - List result = new ArrayList(tokens.length); + List result = new ArrayList<>(tokens.length); for (String token : tokens) { result.add(parseMediaType(token)); } @@ -525,7 +525,7 @@ public class MediaType extends MimeType implements Serializable { public static void sortBySpecificityAndQuality(List mediaTypes) { Assert.notNull(mediaTypes, "'mediaTypes' must not be null"); if (mediaTypes.size() > 1) { - Collections.sort(mediaTypes, new CompoundComparator( + Collections.sort(mediaTypes, new CompoundComparator<>( MediaType.SPECIFICITY_COMPARATOR, MediaType.QUALITY_VALUE_COMPARATOR)); } } diff --git a/spring-web/src/main/java/org/springframework/http/RequestEntity.java b/spring-web/src/main/java/org/springframework/http/RequestEntity.java index 46dbba93ddd..cf7a0b95b56 100644 --- a/spring-web/src/main/java/org/springframework/http/RequestEntity.java +++ b/spring-web/src/main/java/org/springframework/http/RequestEntity.java @@ -444,17 +444,17 @@ public class RequestEntity extends HttpEntity { @Override public RequestEntity build() { - return new RequestEntity(this.headers, this.method, this.url); + return new RequestEntity<>(this.headers, this.method, this.url); } @Override public RequestEntity body(T body) { - return new RequestEntity(body, this.headers, this.method, this.url); + return new RequestEntity<>(body, this.headers, this.method, this.url); } @Override public RequestEntity body(T body, Type type) { - return new RequestEntity(body, this.headers, this.method, this.url, type); + return new RequestEntity<>(body, this.headers, this.method, this.url, type); } } diff --git a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java index 7edb9ea2925..53b5cd5ddd6 100644 --- a/spring-web/src/main/java/org/springframework/http/ResponseEntity.java +++ b/spring-web/src/main/java/org/springframework/http/ResponseEntity.java @@ -447,7 +447,7 @@ public class ResponseEntity extends HttpEntity { @Override public BodyBuilder allow(HttpMethod... allowedMethods) { - this.headers.setAllow(new LinkedHashSet(Arrays.asList(allowedMethods))); + this.headers.setAllow(new LinkedHashSet<>(Arrays.asList(allowedMethods))); return this; } @@ -511,7 +511,7 @@ public class ResponseEntity extends HttpEntity { @Override public ResponseEntity body(T body) { - return new ResponseEntity(body, this.headers, this.statusCode); + return new ResponseEntity<>(body, this.headers, this.statusCode); } } diff --git a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java index e062ba8db46..de022125f7b 100644 --- a/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,7 +102,7 @@ final class HttpComponentsAsyncClientHttpRequest extends AbstractBufferingAsyncC private static class HttpResponseFutureCallback implements FutureCallback { private final ListenableFutureCallbackRegistry callbacks = - new ListenableFutureCallbackRegistry(); + new ListenableFutureCallbackRegistry<>(); public void addCallback(ListenableFutureCallback callback) { this.callbacks.addCallback(callback); diff --git a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java index 929cfb62b8d..d7b825db0ba 100644 --- a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java @@ -88,7 +88,7 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements @Override protected ListenableFuture executeInternal(final HttpHeaders headers) throws IOException { final SettableListenableFuture responseFuture = - new SettableListenableFuture(); + new SettableListenableFuture<>(); ChannelFutureListener connectionListener = new ChannelFutureListener() { @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/support/InterceptingAsyncHttpAccessor.java b/spring-web/src/main/java/org/springframework/http/client/support/InterceptingAsyncHttpAccessor.java index fd59f604a81..c3c2236bcf1 100644 --- a/spring-web/src/main/java/org/springframework/http/client/support/InterceptingAsyncHttpAccessor.java +++ b/spring-web/src/main/java/org/springframework/http/client/support/InterceptingAsyncHttpAccessor.java @@ -35,7 +35,7 @@ import org.springframework.util.CollectionUtils; public abstract class InterceptingAsyncHttpAccessor extends AsyncHttpAccessor { private List interceptors = - new ArrayList(); + new ArrayList<>(); /** diff --git a/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java b/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java index 29f9161f0bd..704b421bd2e 100644 --- a/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java +++ b/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.util.CollectionUtils; */ public abstract class InterceptingHttpAccessor extends HttpAccessor { - private List interceptors = new ArrayList(); + private List interceptors = new ArrayList<>(); /** * Sets the request interceptors that this accessor should use. diff --git a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java index e990fcd774b..fd7d1f0b0f2 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/AbstractHttpMessageConverter.java @@ -97,7 +97,7 @@ public abstract class AbstractHttpMessageConverter implements HttpMessageConv */ public void setSupportedMediaTypes(List supportedMediaTypes) { Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' must not be empty"); - this.supportedMediaTypes = new ArrayList(supportedMediaTypes); + this.supportedMediaTypes = new ArrayList<>(supportedMediaTypes); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java index 359cac63022..fc1b59ce62c 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ import org.springframework.util.StringUtils; */ public class BufferedImageHttpMessageConverter implements HttpMessageConverter { - private final List readableMediaTypes = new ArrayList(); + private final List readableMediaTypes = new ArrayList<>(); private MediaType defaultContentType; diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 643a8713f0e..fbf5d585ed2 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -91,9 +91,9 @@ public class FormHttpMessageConverter implements HttpMessageConverter supportedMediaTypes = new ArrayList(); + private List supportedMediaTypes = new ArrayList<>(); - private List> partConverters = new ArrayList>(); + private List> partConverters = new ArrayList<>(); private Charset charset = DEFAULT_CHARSET; @@ -230,7 +230,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter result = new LinkedMultiValueMap(pairs.length); + MultiValueMap result = new LinkedMultiValueMap<>(pairs.length); for (String pair : pairs) { int idx = pair.indexOf('='); if (idx == -1) { @@ -399,7 +399,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter) part; } else { - return new HttpEntity(part); + return new HttpEntity<>(part); } } diff --git a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java index dc15005483c..83b93bd8b87 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java @@ -62,7 +62,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter(Charset.availableCharsets().values()); + this.availableCharsets = new ArrayList<>(Charset.availableCharsets().values()); } diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java index 546aca46989..a6ceb197613 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java @@ -145,7 +145,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener if (!logger.isWarnEnabled()) { return this.objectMapper.canDeserialize(javaType); } - AtomicReference causeRef = new AtomicReference(); + AtomicReference causeRef = new AtomicReference<>(); if (this.objectMapper.canDeserialize(javaType, causeRef)) { return true; } @@ -161,7 +161,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener if (!logger.isWarnEnabled()) { return this.objectMapper.canSerialize(clazz); } - AtomicReference causeRef = new AtomicReference(); + AtomicReference causeRef = new AtomicReference<>(); if (this.objectMapper.canSerialize(clazz, causeRef)) { return true; } diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java index 462bc56894c..d7ea7cf0571 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java @@ -108,13 +108,13 @@ public class Jackson2ObjectMapperBuilder { private FilterProvider filters; - private final Map, Class> mixIns = new HashMap, Class>(); + private final Map, Class> mixIns = new HashMap<>(); - private final Map, JsonSerializer> serializers = new LinkedHashMap, JsonSerializer>(); + private final Map, JsonSerializer> serializers = new LinkedHashMap<>(); - private final Map, JsonDeserializer> deserializers = new LinkedHashMap, JsonDeserializer>(); + private final Map, JsonDeserializer> deserializers = new LinkedHashMap<>(); - private final Map features = new HashMap(); + private final Map features = new HashMap<>(); private List modules; @@ -485,7 +485,7 @@ public class Jackson2ObjectMapperBuilder { * @see com.fasterxml.jackson.databind.Module */ public Jackson2ObjectMapperBuilder modules(List modules) { - this.modules = new LinkedList(modules); + this.modules = new LinkedList<>(modules); this.findModulesViaServiceLoader = false; this.findWellKnownModules = false; return this; diff --git a/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java index c73e6129139..c7ea72e7f10 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverter.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -74,7 +74,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter, Method> methodCache = new ConcurrentHashMap, Method>(); + private static final ConcurrentHashMap, Method> methodCache = new ConcurrentHashMap<>(); private final ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance(); diff --git a/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java index 2edcbb8f992..d8c8c13dbcc 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/support/AllEncompassingFormHttpMessageConverter.java @@ -51,7 +51,7 @@ public class AllEncompassingFormHttpMessageConverter extends FormHttpMessageConv public AllEncompassingFormHttpMessageConverter() { - addPartConverter(new SourceHttpMessageConverter()); + addPartConverter(new SourceHttpMessageConverter<>()); if (jaxb2Present && !jackson2XmlPresent) { addPartConverter(new Jaxb2RootElementHttpMessageConverter()); diff --git a/spring-web/src/main/java/org/springframework/http/converter/xml/AbstractJaxb2HttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/xml/AbstractJaxb2HttpMessageConverter.java index 71af0810fd4..0ee9f2db32c 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/xml/AbstractJaxb2HttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/xml/AbstractJaxb2HttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.springframework.util.Assert; */ public abstract class AbstractJaxb2HttpMessageConverter extends AbstractXmlHttpMessageConverter { - private final ConcurrentMap, JAXBContext> jaxbContexts = new ConcurrentHashMap, JAXBContext>(64); + private final ConcurrentMap, JAXBContext> jaxbContexts = new ConcurrentHashMap<>(64); /** diff --git a/spring-web/src/main/java/org/springframework/http/converter/xml/SourceHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/xml/SourceHttpMessageConverter.java index e9875107b60..a4a2f29572f 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/xml/SourceHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/xml/SourceHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ import org.springframework.util.StreamUtils; */ public class SourceHttpMessageConverter extends AbstractHttpMessageConverter { - private static final Set> SUPPORTED_CLASSES = new HashSet>(5); + private static final Set> SUPPORTED_CLASSES = new HashSet<>(5); static { SUPPORTED_CLASSES.add(DOMSource.class); diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java index 660044b8e82..676e4c735b1 100644 --- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpRequest.java @@ -129,7 +129,7 @@ public class ServletServerHttpRequest implements ServerHttpRequest { String requestEncoding = this.servletRequest.getCharacterEncoding(); if (StringUtils.hasLength(requestEncoding)) { Charset charSet = Charset.forName(requestEncoding); - Map params = new LinkedCaseInsensitiveMap(); + Map params = new LinkedCaseInsensitiveMap<>(); params.putAll(contentType.getParameters()); params.put("charset", charSet.toString()); MediaType newContentType = new MediaType(contentType.getType(), contentType.getSubtype(), params); diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java index a6d1189c3dd..867ed8e9441 100644 --- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java +++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java @@ -163,7 +163,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse { return null; } - List values = new ArrayList(); + List values = new ArrayList<>(); if (!isEmpty1) { values.addAll(values1); } diff --git a/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java b/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java index 12791ac43a6..e5cb25316b8 100644 --- a/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java +++ b/spring-web/src/main/java/org/springframework/remoting/jaxws/AbstractJaxWsServiceExporter.java @@ -60,7 +60,7 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware, private ListableBeanFactory beanFactory; - private final Set publishedEndpoints = new LinkedHashSet(); + private final Set publishedEndpoints = new LinkedHashSet<>(); /** @@ -127,7 +127,7 @@ public abstract class AbstractJaxWsServiceExporter implements BeanFactoryAware, * @see #publishEndpoint */ public void publishEndpoints() { - Set beanNames = new LinkedHashSet(this.beanFactory.getBeanDefinitionCount()); + Set beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount()); beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames())); if (this.beanFactory instanceof ConfigurableBeanFactory) { beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames())); diff --git a/spring-web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortClientInterceptor.java b/spring-web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortClientInterceptor.java index b905d9818d0..a1d6d32e42b 100644 --- a/spring-web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortClientInterceptor.java +++ b/spring-web/src/main/java/org/springframework/remoting/jaxws/JaxWsPortClientInterceptor.java @@ -240,7 +240,7 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory */ public Map getCustomProperties() { if (this.customProperties == null) { - this.customProperties = new HashMap(); + this.customProperties = new HashMap<>(); } return this.customProperties; } @@ -427,7 +427,7 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory * @see #setCustomProperties */ protected void preparePortStub(Object stub) { - Map stubProperties = new HashMap(); + Map stubProperties = new HashMap<>(); String username = getUsername(); if (username != null) { stubProperties.put(BindingProvider.USERNAME_PROPERTY, username); diff --git a/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java b/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java index 13caeda9bb3..0a2644660b5 100644 --- a/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java +++ b/spring-web/src/main/java/org/springframework/web/HttpRequestMethodNotSupportedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public class HttpRequestMethodNotSupportedException extends ServletException { * Return the actually supported HTTP methods, if known, as {@link HttpMethod} instances. */ public Set getSupportedHttpMethods() { - List supportedMethods = new LinkedList(); + List supportedMethods = new LinkedList<>(); for (String value : this.supportedMethods) { HttpMethod resolved = HttpMethod.resolve(value); if (resolved != null) { diff --git a/spring-web/src/main/java/org/springframework/web/SpringServletContainerInitializer.java b/spring-web/src/main/java/org/springframework/web/SpringServletContainerInitializer.java index b5a43b7ba5c..acd7a3d679a 100644 --- a/spring-web/src/main/java/org/springframework/web/SpringServletContainerInitializer.java +++ b/spring-web/src/main/java/org/springframework/web/SpringServletContainerInitializer.java @@ -140,7 +140,7 @@ public class SpringServletContainerInitializer implements ServletContainerInitia public void onStartup(Set> webAppInitializerClasses, ServletContext servletContext) throws ServletException { - List initializers = new LinkedList(); + List initializers = new LinkedList<>(); if (webAppInitializerClasses != null) { for (Class waiClass : webAppInitializerClasses) { diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java index 81553b81d0a..a37475e823e 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManager.java @@ -46,9 +46,9 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me private static final List MEDIA_TYPE_ALL = Collections.singletonList(MediaType.ALL); - private final List strategies = new ArrayList(); + private final List strategies = new ArrayList<>(); - private final Set resolvers = new LinkedHashSet(); + private final Set resolvers = new LinkedHashSet<>(); /** @@ -133,11 +133,11 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me @Override public List resolveFileExtensions(MediaType mediaType) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (MediaTypeFileExtensionResolver resolver : this.resolvers) { result.addAll(resolver.resolveFileExtensions(mediaType)); } - return new ArrayList(result); + return new ArrayList<>(result); } /** @@ -152,11 +152,11 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me */ @Override public List getAllFileExtensions() { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (MediaTypeFileExtensionResolver resolver : this.resolvers) { result.addAll(resolver.getAllFileExtensions()); } - return new ArrayList(result); + return new ArrayList<>(result); } } diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index dfcd84990e8..45858803c52 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -96,7 +96,7 @@ public class ContentNegotiationManagerFactoryBean private boolean ignoreAcceptHeader = false; - private Map mediaTypes = new HashMap(); + private Map mediaTypes = new HashMap<>(); private boolean ignoreUnknownPathExtensions = true; @@ -250,7 +250,7 @@ public class ContentNegotiationManagerFactoryBean @Override public void afterPropertiesSet() { - List strategies = new ArrayList(); + List strategies = new ArrayList<>(); if (this.favorPathExtension) { PathExtensionContentNegotiationStrategy strategy; diff --git a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java index 49c38d6dd34..fac818e41f5 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java +++ b/spring-web/src/main/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolver.java @@ -43,12 +43,12 @@ import org.springframework.util.MultiValueMap; public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExtensionResolver { private final ConcurrentMap mediaTypes = - new ConcurrentHashMap(64); + new ConcurrentHashMap<>(64); private final MultiValueMap fileExtensions = - new LinkedMultiValueMap(); + new LinkedMultiValueMap<>(); - private final List allFileExtensions = new LinkedList(); + private final List allFileExtensions = new LinkedList<>(); /** @@ -68,7 +68,7 @@ public class MappingMediaTypeFileExtensionResolver implements MediaTypeFileExten protected List getAllMediaTypes() { - return new ArrayList(this.mediaTypes.values()); + return new ArrayList<>(this.mediaTypes.values()); } /** diff --git a/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java b/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java index 02885b55ea1..3609afa73e9 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java +++ b/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -230,7 +230,7 @@ public class EscapedErrors implements Errors { } private List escapeObjectErrors(List source) { - List escaped = new ArrayList(source.size()); + List escaped = new ArrayList<>(source.size()); for (T objectError : source) { escaped.add(escapeObjectError(objectError)); } diff --git a/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java b/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java index c079c8152d5..7841d5b951b 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java +++ b/spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -134,7 +134,7 @@ public class WebRequestDataBinder extends WebDataBinder { private void bindParts(HttpServletRequest request, MutablePropertyValues mpvs) { try { - MultiValueMap map = new LinkedMultiValueMap(); + MultiValueMap map = new LinkedMultiValueMap<>(); for (Part part : request.getParts()) { map.add(part.getName(), part); } diff --git a/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java index acbe795361b..ae4d3021acc 100644 --- a/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/AsyncRestTemplate.java @@ -503,7 +503,7 @@ public class AsyncRestTemplate extends InterceptingAsyncHttpAccessor implements requestCallback.doWithRequest(request); } ListenableFuture responseFuture = request.executeAsync(); - return new ResponseExtractorFuture(method, url, responseFuture, responseExtractor); + return new ResponseExtractorFuture<>(method, url, responseFuture, responseExtractor); } catch (IOException ex) { throw new ResourceAccessException("I/O error on " + method.name() + diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java index 8a7f79a2ae0..09828856872 100644 --- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java @@ -138,7 +138,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat ClassUtils.isPresent("com.google.gson.Gson", RestTemplate.class.getClassLoader()); - private final List> messageConverters = new ArrayList>(); + private final List> messageConverters = new ArrayList<>(); private ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler(); @@ -155,7 +155,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(new StringHttpMessageConverter()); this.messageConverters.add(new ResourceHttpMessageConverter()); - this.messageConverters.add(new SourceHttpMessageConverter()); + this.messageConverters.add(new SourceHttpMessageConverter<>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); if (romePresent) { @@ -283,7 +283,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat public T getForObject(String url, Class responseType, Object... urlVariables) throws RestClientException { RequestCallback requestCallback = acceptHeaderRequestCallback(responseType); HttpMessageConverterExtractor responseExtractor = - new HttpMessageConverterExtractor(responseType, getMessageConverters(), logger); + new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger); return execute(url, HttpMethod.GET, requestCallback, responseExtractor, urlVariables); } @@ -291,7 +291,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat public T getForObject(String url, Class responseType, Map urlVariables) throws RestClientException { RequestCallback requestCallback = acceptHeaderRequestCallback(responseType); HttpMessageConverterExtractor responseExtractor = - new HttpMessageConverterExtractor(responseType, getMessageConverters(), logger); + new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger); return execute(url, HttpMethod.GET, requestCallback, responseExtractor, urlVariables); } @@ -299,7 +299,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat public T getForObject(URI url, Class responseType) throws RestClientException { RequestCallback requestCallback = acceptHeaderRequestCallback(responseType); HttpMessageConverterExtractor responseExtractor = - new HttpMessageConverterExtractor(responseType, getMessageConverters(), logger); + new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger); return execute(url, HttpMethod.GET, requestCallback, responseExtractor); } @@ -376,7 +376,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat RequestCallback requestCallback = httpEntityCallback(request, responseType); HttpMessageConverterExtractor responseExtractor = - new HttpMessageConverterExtractor(responseType, getMessageConverters(), logger); + new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger); return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables); } @@ -386,7 +386,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat RequestCallback requestCallback = httpEntityCallback(request, responseType); HttpMessageConverterExtractor responseExtractor = - new HttpMessageConverterExtractor(responseType, getMessageConverters(), logger); + new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger); return execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables); } @@ -394,7 +394,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat public T postForObject(URI url, Object request, Class responseType) throws RestClientException { RequestCallback requestCallback = httpEntityCallback(request, responseType); HttpMessageConverterExtractor responseExtractor = - new HttpMessageConverterExtractor(responseType, getMessageConverters()); + new HttpMessageConverterExtractor<>(responseType, getMessageConverters()); return execute(url, HttpMethod.POST, requestCallback, responseExtractor); } @@ -697,7 +697,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat * Returns a response extractor for {@link ResponseEntity}. */ protected ResponseExtractor> responseEntityExtractor(Type responseType) { - return new ResponseEntityResponseExtractor(responseType); + return new ResponseEntityResponseExtractor<>(responseType); } /** @@ -726,7 +726,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat if (this.responseType instanceof Class) { responseClass = (Class) this.responseType; } - List allSupportedMediaTypes = new ArrayList(); + List allSupportedMediaTypes = new ArrayList<>(); for (HttpMessageConverter converter : getMessageConverters()) { if (responseClass != null) { if (converter.canRead(responseClass, null)) { @@ -752,7 +752,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat private List getSupportedMediaTypes(HttpMessageConverter messageConverter) { List supportedMediaTypes = messageConverter.getSupportedMediaTypes(); - List result = new ArrayList(supportedMediaTypes.size()); + List result = new ArrayList<>(supportedMediaTypes.size()); for (MediaType supportedMediaType : supportedMediaTypes) { if (supportedMediaType.getCharset() != null) { supportedMediaType = @@ -782,7 +782,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat this.requestEntity = (HttpEntity) requestBody; } else if (requestBody != null) { - this.requestEntity = new HttpEntity(requestBody); + this.requestEntity = new HttpEntity<>(requestBody); } else { this.requestEntity = HttpEntity.EMPTY; @@ -871,7 +871,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat public ResponseEntityResponseExtractor(Type responseType) { if (responseType != null && Void.class != responseType) { - this.delegate = new HttpMessageConverterExtractor(responseType, getMessageConverters(), logger); + this.delegate = new HttpMessageConverterExtractor<>(responseType, getMessageConverters(), logger); } else { this.delegate = null; @@ -882,10 +882,10 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat public ResponseEntity extractData(ClientHttpResponse response) throws IOException { if (this.delegate != null) { T body = this.delegate.extractData(response); - return new ResponseEntity(body, response.getHeaders(), response.getStatusCode()); + return new ResponseEntity<>(body, response.getHeaders(), response.getStatusCode()); } else { - return new ResponseEntity(response.getHeaders(), response.getStatusCode()); + return new ResponseEntity<>(response.getHeaders(), response.getStatusCode()); } } } diff --git a/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java b/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java index 595d2908c0a..a00df24b058 100644 --- a/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java +++ b/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java @@ -183,7 +183,7 @@ public class ContextLoader { * Map from (thread context) ClassLoader to corresponding 'current' WebApplicationContext. */ private static final Map currentContextPerThread = - new ConcurrentHashMap(1); + new ConcurrentHashMap<>(1); /** * The 'current' WebApplicationContext, if the ContextLoader class is @@ -205,7 +205,7 @@ public class ContextLoader { /** Actual ApplicationContextInitializer instances to apply to the context */ private final List> contextInitializers = - new ArrayList>(); + new ArrayList<>(); /** @@ -494,7 +494,7 @@ public class ContextLoader { determineContextInitializerClasses(ServletContext servletContext) { List>> classes = - new ArrayList>>(); + new ArrayList<>(); String globalClassNames = servletContext.getInitParameter(GLOBAL_INITIALIZER_CLASSES_PARAM); if (globalClassNames != null) { diff --git a/spring-web/src/main/java/org/springframework/web/context/request/AbstractRequestAttributes.java b/spring-web/src/main/java/org/springframework/web/context/request/AbstractRequestAttributes.java index 164c5c6314b..57e43aa6000 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/AbstractRequestAttributes.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/AbstractRequestAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.util.Assert; public abstract class AbstractRequestAttributes implements RequestAttributes { /** Map from attribute name String to destruction callback Runnable */ - protected final Map requestDestructionCallbacks = new LinkedHashMap(8); + protected final Map requestDestructionCallbacks = new LinkedHashMap<>(8); private volatile boolean requestActive = true; diff --git a/spring-web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java b/spring-web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java index 793e7c48930..365f66f6c4f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/RequestContextHolder.java @@ -47,10 +47,10 @@ public abstract class RequestContextHolder { ClassUtils.isPresent("javax.faces.context.FacesContext", RequestContextHolder.class.getClassLoader()); private static final ThreadLocal requestAttributesHolder = - new NamedThreadLocal("Request attributes"); + new NamedThreadLocal<>("Request attributes"); private static final ThreadLocal inheritableRequestAttributesHolder = - new NamedInheritableThreadLocal("Request context"); + new NamedInheritableThreadLocal<>("Request context"); /** diff --git a/spring-web/src/main/java/org/springframework/web/context/request/ServletRequestAttributes.java b/spring-web/src/main/java/org/springframework/web/context/request/ServletRequestAttributes.java index 6eb5de182d6..970c77b7551 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/ServletRequestAttributes.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/ServletRequestAttributes.java @@ -49,7 +49,7 @@ public class ServletRequestAttributes extends AbstractRequestAttributes { public static final String DESTRUCTION_CALLBACK_NAME_PREFIX = ServletRequestAttributes.class.getName() + ".DESTRUCTION_CALLBACK."; - protected static final Set> immutableValueTypes = new HashSet>(16); + protected static final Set> immutableValueTypes = new HashSet<>(16); static { immutableValueTypes.addAll(NumberUtils.STANDARD_NUMBER_TYPES); @@ -65,7 +65,7 @@ public class ServletRequestAttributes extends AbstractRequestAttributes { private volatile HttpSession session; - private final Map sessionAttributesToUpdate = new ConcurrentHashMap(1); + private final Map sessionAttributesToUpdate = new ConcurrentHashMap<>(1); /** diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java index fc0bb983235..c00b6ad280f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +48,9 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements private AtomicBoolean asyncCompleted = new AtomicBoolean(false); - private final List timeoutHandlers = new ArrayList(); + private final List timeoutHandlers = new ArrayList<>(); - private final List completionHandlers = new ArrayList(); + private final List completionHandlers = new ArrayList<>(); /** diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java index ea188badfa4..c8b41e098fe 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java @@ -79,10 +79,10 @@ public final class WebAsyncManager { private Object[] concurrentResultContext; private final Map callableInterceptors = - new LinkedHashMap(); + new LinkedHashMap<>(); private final Map deferredResultInterceptors = - new LinkedHashMap(); + new LinkedHashMap<>(); /** @@ -279,7 +279,7 @@ public final class WebAsyncManager { this.taskExecutor = executor; } - List interceptors = new ArrayList(); + List interceptors = new ArrayList<>(); interceptors.add(webAsyncTask.getInterceptor()); interceptors.addAll(this.callableInterceptors.values()); interceptors.add(timeoutCallableInterceptor); @@ -379,7 +379,7 @@ public final class WebAsyncManager { this.asyncWebRequest.setTimeout(timeout); } - List interceptors = new ArrayList(); + List interceptors = new ArrayList<>(); interceptors.add(deferredResult.getInterceptor()); interceptors.addAll(this.deferredResultInterceptors.values()); interceptors.add(timeoutDeferredResultInterceptor); diff --git a/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java index dd116cdf18f..ceb2c2ede62 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,9 +86,9 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe private ScopeMetadataResolver scopeMetadataResolver; - private final Set> annotatedClasses = new LinkedHashSet>(); + private final Set> annotatedClasses = new LinkedHashSet<>(); - private final Set basePackages = new LinkedHashSet(); + private final Set basePackages = new LinkedHashSet<>(); /** diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ContextExposingHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/context/support/ContextExposingHttpServletRequest.java index 759d347c5f1..9eca5235f5e 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ContextExposingHttpServletRequest.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ContextExposingHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,7 +92,7 @@ public class ContextExposingHttpServletRequest extends HttpServletRequestWrapper public void setAttribute(String name, Object value) { super.setAttribute(name, value); if (this.explicitAttributes == null) { - this.explicitAttributes = new HashSet(8); + this.explicitAttributes = new HashSet<>(8); } this.explicitAttributes.add(name); } diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java index df7a4537b0e..982091ac93b 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextLiveBeansView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class ServletContextLiveBeansView extends LiveBeansView { @Override protected Set findApplicationContexts() { - Set contexts = new LinkedHashSet(); + Set contexts = new LinkedHashSet<>(); Enumeration attrNames = this.servletContext.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = attrNames.nextElement(); diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java index e33a0928a71..209fd50c935 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextResourcePatternResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ public class ServletContextResourcePatternResolver extends PathMatchingResourceP ServletContextResource scResource = (ServletContextResource) rootDirResource; ServletContext sc = scResource.getServletContext(); String fullPattern = scResource.getPath() + subPattern; - Set result = new LinkedHashSet(8); + Set result = new LinkedHashSet<>(8); doRetrieveMatchingServletContextResources(sc, fullPattern, scResource.getPath(), result); return result; } diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java index d16a99d3f34..3f1c8969610 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ public class ServletContextScope implements Scope, DisposableBean { private final ServletContext servletContext; - private final Map destructionCallbacks = new LinkedHashMap(); + private final Map destructionCallbacks = new LinkedHashMap<>(); /** diff --git a/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java b/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java index 34b57869166..cd34437310f 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java @@ -223,7 +223,7 @@ public abstract class WebApplicationContextUtils { } if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) { - Map parameterMap = new HashMap(); + Map parameterMap = new HashMap<>(); if (servletContext != null) { Enumeration paramNameEnum = servletContext.getInitParameterNames(); while (paramNameEnum.hasMoreElements()) { @@ -243,7 +243,7 @@ public abstract class WebApplicationContextUtils { } if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) { - Map attributeMap = new HashMap(); + Map attributeMap = new HashMap<>(); if (servletContext != null) { Enumeration attrNameEnum = servletContext.getAttributeNames(); while (attrNameEnum.hasMoreElements()) { diff --git a/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java b/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java index 016a355be49..a9b09a4e84a 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java +++ b/spring-web/src/main/java/org/springframework/web/cors/CorsConfiguration.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -108,7 +108,7 @@ public class CorsConfiguration { if (source == null || source.contains(ALL)) { return other; } - List combined = new ArrayList(source); + List combined = new ArrayList<>(source); combined.addAll(other); return combined; } @@ -120,7 +120,7 @@ public class CorsConfiguration { *

By default this is not set. */ public void setAllowedOrigins(List allowedOrigins) { - this.allowedOrigins = (allowedOrigins != null ? new ArrayList(allowedOrigins) : null); + this.allowedOrigins = (allowedOrigins != null ? new ArrayList<>(allowedOrigins) : null); } /** @@ -137,7 +137,7 @@ public class CorsConfiguration { */ public void addAllowedOrigin(String origin) { if (this.allowedOrigins == null) { - this.allowedOrigins = new ArrayList(); + this.allowedOrigins = new ArrayList<>(); } this.allowedOrigins.add(origin); } @@ -150,7 +150,7 @@ public class CorsConfiguration { *

By default this is not set. */ public void setAllowedMethods(List allowedMethods) { - this.allowedMethods = (allowedMethods != null ? new ArrayList(allowedMethods) : null); + this.allowedMethods = (allowedMethods != null ? new ArrayList<>(allowedMethods) : null); } /** @@ -179,7 +179,7 @@ public class CorsConfiguration { public void addAllowedMethod(String method) { if (StringUtils.hasText(method)) { if (this.allowedMethods == null) { - this.allowedMethods = new ArrayList(); + this.allowedMethods = new ArrayList<>(); } this.allowedMethods.add(method); } @@ -196,7 +196,7 @@ public class CorsConfiguration { *

By default this is not set. */ public void setAllowedHeaders(List allowedHeaders) { - this.allowedHeaders = (allowedHeaders != null ? new ArrayList(allowedHeaders) : null); + this.allowedHeaders = (allowedHeaders != null ? new ArrayList<>(allowedHeaders) : null); } /** @@ -213,7 +213,7 @@ public class CorsConfiguration { */ public void addAllowedHeader(String allowedHeader) { if (this.allowedHeaders == null) { - this.allowedHeaders = new ArrayList(); + this.allowedHeaders = new ArrayList<>(); } this.allowedHeaders.add(allowedHeader); } @@ -230,7 +230,7 @@ public class CorsConfiguration { if (exposedHeaders != null && exposedHeaders.contains(ALL)) { throw new IllegalArgumentException("'*' is not a valid exposed header value"); } - this.exposedHeaders = (exposedHeaders == null ? null : new ArrayList(exposedHeaders)); + this.exposedHeaders = (exposedHeaders == null ? null : new ArrayList<>(exposedHeaders)); } /** @@ -251,7 +251,7 @@ public class CorsConfiguration { throw new IllegalArgumentException("'*' is not a valid exposed header value"); } if (this.exposedHeaders == null) { - this.exposedHeaders = new ArrayList(); + this.exposedHeaders = new ArrayList<>(); } this.exposedHeaders.add(exposedHeader); } @@ -334,7 +334,7 @@ public class CorsConfiguration { return null; } List allowedMethods = - (this.allowedMethods != null ? this.allowedMethods : new ArrayList()); + (this.allowedMethods != null ? this.allowedMethods : new ArrayList<>()); if (allowedMethods.contains(ALL)) { return Collections.singletonList(requestMethod); } @@ -342,7 +342,7 @@ public class CorsConfiguration { allowedMethods.add(HttpMethod.GET.name()); allowedMethods.add(HttpMethod.HEAD.name()); } - List result = new ArrayList(allowedMethods.size()); + List result = new ArrayList<>(allowedMethods.size()); boolean allowed = false; for (String method : allowedMethods) { if (requestMethod.matches(method)) { @@ -376,7 +376,7 @@ public class CorsConfiguration { } boolean allowAnyHeader = this.allowedHeaders.contains(ALL); - List result = new ArrayList(); + List result = new ArrayList<>(); for (String requestHeader : requestHeaders) { if (StringUtils.hasText(requestHeader)) { requestHeader = requestHeader.trim(); diff --git a/spring-web/src/main/java/org/springframework/web/cors/DefaultCorsProcessor.java b/spring-web/src/main/java/org/springframework/web/cors/DefaultCorsProcessor.java index 3a564f80826..b06280c4d3e 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/DefaultCorsProcessor.java +++ b/spring-web/src/main/java/org/springframework/web/cors/DefaultCorsProcessor.java @@ -193,7 +193,7 @@ public class DefaultCorsProcessor implements CorsProcessor { private List getHeadersToUse(ServerHttpRequest request, boolean isPreFlight) { HttpHeaders headers = request.getHeaders(); - return (isPreFlight ? headers.getAccessControlRequestHeaders() : new ArrayList(headers.keySet())); + return (isPreFlight ? headers.getAccessControlRequestHeaders() : new ArrayList<>(headers.keySet())); } } diff --git a/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java b/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java index 749696ce04d..0d4eb11406a 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java +++ b/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.web.util.UrlPathHelper; */ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource { - private final Map corsConfigurations = new LinkedHashMap(); + private final Map corsConfigurations = new LinkedHashMap<>(); private PathMatcher pathMatcher = new AntPathMatcher(); diff --git a/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java b/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java index 43db6b06efc..0f88930163f 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/CompositeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ import javax.servlet.ServletResponse; */ public class CompositeFilter implements Filter { - private List filters = new ArrayList(); + private List filters = new ArrayList<>(); public void setFilters(List filters) { diff --git a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java index a1196ec2fd0..d95316f5cab 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java @@ -53,7 +53,7 @@ import org.springframework.web.util.UrlPathHelper; public class ForwardedHeaderFilter extends OncePerRequestFilter { private static final Set FORWARDED_HEADER_NAMES = - Collections.newSetFromMap(new LinkedCaseInsensitiveMap(5, Locale.ENGLISH)); + Collections.newSetFromMap(new LinkedCaseInsensitiveMap<>(5, Locale.ENGLISH)); static { FORWARDED_HEADER_NAMES.add("Forwarded"); @@ -156,7 +156,7 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { * Copy the headers excluding any {@link #FORWARDED_HEADER_NAMES}. */ private static Map> initHeaders(HttpServletRequest request) { - Map> headers = new LinkedCaseInsensitiveMap>(Locale.ENGLISH); + Map> headers = new LinkedCaseInsensitiveMap<>(Locale.ENGLISH); Enumeration names = request.getHeaderNames(); while (names.hasMoreElements()) { String name = names.nextElement(); diff --git a/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java b/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java index 1ba6be4f231..c73add0ac7c 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java +++ b/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public abstract class GenericFilterBean implements * Set of required properties (Strings) that must be supplied as * config parameters to this filter. */ - private final Set requiredProperties = new HashSet(); + private final Set requiredProperties = new HashSet<>(); private FilterConfig filterConfig; @@ -301,7 +301,7 @@ public abstract class GenericFilterBean implements throws ServletException { Set missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ? - new HashSet(requiredProperties) : null; + new HashSet<>(requiredProperties) : null; Enumeration en = config.getInitParameterNames(); while (en.hasMoreElements()) { diff --git a/spring-web/src/main/java/org/springframework/web/filter/HttpPutFormContentFilter.java b/spring-web/src/main/java/org/springframework/web/filter/HttpPutFormContentFilter.java index 74664a9cca0..da172d4f062 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/HttpPutFormContentFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/HttpPutFormContentFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,7 +110,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter { public HttpPutFormContentRequestWrapper(HttpServletRequest request, MultiValueMap parameters) { super(request); - this.formParameters = (parameters != null) ? parameters : new LinkedMultiValueMap(); + this.formParameters = (parameters != null) ? parameters : new LinkedMultiValueMap<>(); } @Override @@ -122,7 +122,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter { @Override public Map getParameterMap() { - Map result = new LinkedHashMap(); + Map result = new LinkedHashMap<>(); Enumeration names = this.getParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); @@ -133,7 +133,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter { @Override public Enumeration getParameterNames() { - Set names = new LinkedHashSet(); + Set names = new LinkedHashSet<>(); names.addAll(Collections.list(super.getParameterNames())); names.addAll(this.formParameters.keySet()); return Collections.enumeration(names); @@ -150,7 +150,7 @@ public class HttpPutFormContentFilter extends OncePerRequestFilter { return formValues.toArray(new String[formValues.size()]); } else { - List result = new ArrayList(); + List result = new ArrayList<>(); result.addAll(Arrays.asList(queryStringValues)); result.addAll(formValues); return result.toArray(new String[result.size()]); diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index 1567b39b2a5..89f9470163a 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -211,7 +211,7 @@ public class ControllerAdviceBean implements Ordered { * ApplicationContext and wrap them as {@code ControllerAdviceBean} instances. */ public static List findAnnotatedBeans(ApplicationContext applicationContext) { - List beans = new ArrayList(); + List beans = new ArrayList<>(); for (String name : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(applicationContext, Object.class)) { if (applicationContext.findAnnotationOnBean(name, ControllerAdvice.class) != null) { beans.add(new ControllerAdviceBean(name, applicationContext)); @@ -229,7 +229,7 @@ public class ControllerAdviceBean implements Ordered { } private static Set initBasePackages(ControllerAdvice annotation) { - Set basePackages = new LinkedHashSet(); + Set basePackages = new LinkedHashSet<>(); for (String basePackage : annotation.basePackages()) { if (StringUtils.hasText(basePackage)) { basePackages.add(adaptBasePackage(basePackage)); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java index e2e92d64393..678fc300d06 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/AbstractNamedValueMethodArgumentResolver.java @@ -63,7 +63,7 @@ public abstract class AbstractNamedValueMethodArgumentResolver implements Handle private final BeanExpressionContext expressionContext; - private final Map namedValueInfoCache = new ConcurrentHashMap(256); + private final Map namedValueInfoCache = new ConcurrentHashMap<>(256); public AbstractNamedValueMethodArgumentResolver() { diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolver.java index 6d9b11cc7ec..fd6744a7354 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class ErrorsMethodArgumentResolver implements HandlerMethodArgumentResolv ModelMap model = mavContainer.getModel(); if (model.size() > 0) { int lastIndex = model.size()-1; - String lastKey = new ArrayList(model.keySet()).get(lastIndex); + String lastKey = new ArrayList<>(model.keySet()).get(lastIndex); if (lastKey.startsWith(BindingResult.MODEL_KEY_PREFIX)) { return model.get(lastKey); } diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java index c121f575bf2..b56b3a4ddde 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java @@ -60,10 +60,10 @@ public class ExceptionHandlerMethodResolver { private final Map, Method> mappedMethods = - new ConcurrentHashMap, Method>(16); + new ConcurrentHashMap<>(16); private final Map, Method> exceptionLookupCache = - new ConcurrentHashMap, Method>(16); + new ConcurrentHashMap<>(16); /** @@ -85,7 +85,7 @@ public class ExceptionHandlerMethodResolver { */ @SuppressWarnings("unchecked") private List> detectExceptionMappings(Method method) { - List> result = new ArrayList>(); + List> result = new ArrayList<>(); detectAnnotationExceptionMappings(method, result); if (result.isEmpty()) { for (Class paramType : method.getParameterTypes()) { @@ -154,7 +154,7 @@ public class ExceptionHandlerMethodResolver { * Return the {@link Method} mapped to the given exception type, or {@code null} if none. */ private Method getMappedMethod(Class exceptionType) { - List> matches = new ArrayList>(); + List> matches = new ArrayList<>(); for (Class mappedException : this.mappedMethods.keySet()) { if (mappedException.isAssignableFrom(exceptionType)) { matches.add(mappedException); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/InitBinderDataBinderFactory.java b/spring-web/src/main/java/org/springframework/web/method/annotation/InitBinderDataBinderFactory.java index b00f6e46d82..0d58c140ad1 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/InitBinderDataBinderFactory.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/InitBinderDataBinderFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class InitBinderDataBinderFactory extends DefaultDataBinderFactory { */ public InitBinderDataBinderFactory(List binderMethods, WebBindingInitializer initializer) { super(initializer); - this.binderMethods = (binderMethods != null) ? binderMethods : new ArrayList(); + this.binderMethods = (binderMethods != null) ? binderMethods : new ArrayList<>(); } /** diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java index be4472d3e9a..07fac01a493 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ModelFactory.java @@ -61,7 +61,7 @@ public final class ModelFactory { private static final Log logger = LogFactory.getLog(ModelFactory.class); - private final List modelMethods = new ArrayList(); + private final List modelMethods = new ArrayList<>(); private final WebDataBinderFactory dataBinderFactory; @@ -172,7 +172,7 @@ public final class ModelFactory { * Find {@code @ModelAttribute} arguments also listed as {@code @SessionAttributes}. */ private List findSessionAttributeArguments(HandlerMethod handlerMethod) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (MethodParameter parameter : handlerMethod.getMethodParameters()) { if (parameter.hasParameterAnnotation(ModelAttribute.class)) { String name = getNameForParameter(parameter); @@ -247,7 +247,7 @@ public final class ModelFactory { * Add {@link BindingResult} attributes to the model for attributes that require it. */ private void updateBindingResult(NativeWebRequest request, ModelMap model) throws Exception { - List keyNames = new ArrayList(model.keySet()); + List keyNames = new ArrayList<>(model.keySet()); for (String name : keyNames) { Object value = model.get(name); @@ -284,7 +284,7 @@ public final class ModelFactory { private final InvocableHandlerMethod handlerMethod; - private final Set dependencies = new HashSet(); + private final Set dependencies = new HashSet<>(); private ModelMethod(InvocableHandlerMethod handlerMethod) { this.handlerMethod = handlerMethod; @@ -309,7 +309,7 @@ public final class ModelFactory { } public List getUnresolvedDependencies(ModelAndViewContainer mavContainer) { - List result = new ArrayList(this.dependencies.size()); + List result = new ArrayList<>(this.dependencies.size()); for (String name : this.dependencies) { if (!mavContainer.containsAttribute(name)) { result.add(name); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolver.java index f2ad4a429ee..f462a0a4646 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolver.java @@ -62,7 +62,7 @@ public class RequestHeaderMapMethodArgumentResolver implements HandlerMethodArgu result = new HttpHeaders(); } else { - result = new LinkedMultiValueMap(); + result = new LinkedMultiValueMap<>(); } for (Iterator iterator = webRequest.getHeaderNames(); iterator.hasNext();) { String headerName = iterator.next(); @@ -76,7 +76,7 @@ public class RequestHeaderMapMethodArgumentResolver implements HandlerMethodArgu return result; } else { - Map result = new LinkedHashMap(); + Map result = new LinkedHashMap<>(); for (Iterator iterator = webRequest.getHeaderNames(); iterator.hasNext();) { String headerName = iterator.next(); String headerValue = webRequest.getHeader(headerName); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolver.java index 39fce258011..c756dd6f728 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class RequestParamMapMethodArgumentResolver implements HandlerMethodArgum Map parameterMap = webRequest.getParameterMap(); if (MultiValueMap.class.isAssignableFrom(paramType)) { - MultiValueMap result = new LinkedMultiValueMap(parameterMap.size()); + MultiValueMap result = new LinkedMultiValueMap<>(parameterMap.size()); for (Map.Entry entry : parameterMap.entrySet()) { for (String value : entry.getValue()) { result.add(entry.getKey(), value); @@ -75,7 +75,7 @@ public class RequestParamMapMethodArgumentResolver implements HandlerMethodArgum return result; } else { - Map result = new LinkedHashMap(parameterMap.size()); + Map result = new LinkedHashMap<>(parameterMap.size()); for (Map.Entry entry : parameterMap.entrySet()) { if (entry.getValue().length > 0) { result.put(entry.getKey(), entry.getValue()[0]); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java b/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java index 8cc07e465d0..aa54a71fb0c 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java @@ -47,9 +47,9 @@ import org.springframework.web.context.request.WebRequest; */ public class SessionAttributesHandler { - private final Set attributeNames = new HashSet(); + private final Set attributeNames = new HashSet<>(); - private final Set> attributeTypes = new HashSet>(); + private final Set> attributeTypes = new HashSet<>(); private final Set knownAttributeNames = Collections.newSetFromMap(new ConcurrentHashMap(4)); @@ -135,7 +135,7 @@ public class SessionAttributesHandler { * @return a map with handler session attributes, possibly empty */ public Map retrieveAttributes(WebRequest request) { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); for (String name : this.knownAttributeNames) { Object value = this.sessionAttributeStore.retrieveAttribute(request, name); if (value != null) { diff --git a/spring-web/src/main/java/org/springframework/web/method/support/CompositeUriComponentsContributor.java b/spring-web/src/main/java/org/springframework/web/method/support/CompositeUriComponentsContributor.java index 1df794a7c51..01f028b0aba 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/CompositeUriComponentsContributor.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/CompositeUriComponentsContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.web.util.UriComponentsBuilder; */ public class CompositeUriComponentsContributor implements UriComponentsContributor { - private final List contributors = new LinkedList(); + private final List contributors = new LinkedList<>(); private final ConversionService conversionService; diff --git a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java b/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java index e80655a9b00..c119f6dd21c 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodArgumentResolverComposite.java @@ -42,10 +42,10 @@ public class HandlerMethodArgumentResolverComposite implements HandlerMethodArgu protected final Log logger = LogFactory.getLog(getClass()); private final List argumentResolvers = - new LinkedList(); + new LinkedList<>(); private final Map argumentResolverCache = - new ConcurrentHashMap(256); + new ConcurrentHashMap<>(256); /** diff --git a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.java b/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.java index 847068de2ea..ad23c2c927e 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite.java @@ -38,7 +38,7 @@ public class HandlerMethodReturnValueHandlerComposite implements AsyncHandlerMet protected final Log logger = LogFactory.getLog(getClass()); private final List returnValueHandlers = - new ArrayList(); + new ArrayList<>(); /** diff --git a/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java b/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java index ec97682464c..08af03d8310 100644 --- a/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java +++ b/spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java @@ -58,7 +58,7 @@ public class ModelAndViewContainer { private boolean redirectModelScenario = false; /* Names of attributes with binding disabled */ - private final Set bindingDisabledAttributes = new HashSet(4); + private final Set bindingDisabledAttributes = new HashSet<>(4); private HttpStatus status; diff --git a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java index 17af1ce15bf..e2339b58707 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java @@ -221,9 +221,9 @@ public abstract class CommonsFileUploadSupport { * @see CommonsMultipartFile#CommonsMultipartFile(org.apache.commons.fileupload.FileItem) */ protected MultipartParsingResult parseFileItems(List fileItems, String encoding) { - MultiValueMap multipartFiles = new LinkedMultiValueMap(); - Map multipartParameters = new HashMap(); - Map multipartParameterContentTypes = new HashMap(); + MultiValueMap multipartFiles = new LinkedMultiValueMap<>(); + Map multipartParameters = new HashMap<>(); + Map multipartParameterContentTypes = new HashMap<>(); // Extract multipart files and multipart parameters. for (FileItem fileItem : fileItems) { diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java index 4e423e44966..dcdcb3d0a6e 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/AbstractMultipartHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ public abstract class AbstractMultipartHttpServletRequest extends HttpServletReq */ protected final void setMultipartFiles(MultiValueMap multipartFiles) { this.multipartFiles = - new LinkedMultiValueMap(Collections.unmodifiableMap(multipartFiles)); + new LinkedMultiValueMap<>(Collections.unmodifiableMap(multipartFiles)); } /** diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequest.java index 41f9420d8b4..2a2bd3aad07 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequest.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,7 +100,7 @@ public class DefaultMultipartHttpServletRequest extends AbstractMultipartHttpSer return super.getParameterNames(); } - Set paramNames = new LinkedHashSet(); + Set paramNames = new LinkedHashSet<>(); Enumeration paramEnum = super.getParameterNames(); while (paramEnum.hasMoreElements()) { paramNames.add(paramEnum.nextElement()); @@ -116,7 +116,7 @@ public class DefaultMultipartHttpServletRequest extends AbstractMultipartHttpSer return super.getParameterMap(); } - Map paramMap = new LinkedHashMap(); + Map paramMap = new LinkedHashMap<>(); paramMap.putAll(super.getParameterMap()); paramMap.putAll(multipartParameters); return paramMap; diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java index d7ca57f1997..ef3770c0b28 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java @@ -144,7 +144,7 @@ public abstract class MultipartResolutionDelegate { private static List resolvePartList(HttpServletRequest servletRequest, String name) throws Exception { Collection parts = servletRequest.getParts(); - List result = new ArrayList(parts.size()); + List result = new ArrayList<>(parts.size()); for (Part part : parts) { if (part.getName().equals(name)) { result.add(part); @@ -155,7 +155,7 @@ public abstract class MultipartResolutionDelegate { private static Part[] resolvePartArray(HttpServletRequest servletRequest, String name) throws Exception { Collection parts = servletRequest.getParts(); - List result = new ArrayList(parts.size()); + List result = new ArrayList<>(parts.size()); for (Part part : parts) { if (part.getName().equals(name)) { result.add(part); diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java index a86f713e67f..0e599a0f0d4 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,8 +90,8 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe private void parseRequest(HttpServletRequest request) { try { Collection parts = request.getParts(); - this.multipartParameterNames = new LinkedHashSet(parts.size()); - MultiValueMap files = new LinkedMultiValueMap(parts.size()); + this.multipartParameterNames = new LinkedHashSet<>(parts.size()); + MultiValueMap files = new LinkedMultiValueMap<>(parts.size()); for (Part part : parts) { String disposition = part.getHeader(CONTENT_DISPOSITION); String filename = extractFilename(disposition); @@ -184,7 +184,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe // Servlet 3.0 getParameterNames() not guaranteed to include multipart form items // (e.g. on WebLogic 12) -> need to merge them here to be on the safe side - Set paramNames = new LinkedHashSet(); + Set paramNames = new LinkedHashSet<>(); Enumeration paramEnum = super.getParameterNames(); while (paramEnum.hasMoreElements()) { paramNames.add(paramEnum.nextElement()); @@ -204,7 +204,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe // Servlet 3.0 getParameterMap() not guaranteed to include multipart form items // (e.g. on WebLogic 12) -> need to merge them here to be on the safe side - Map paramMap = new LinkedHashMap(); + Map paramMap = new LinkedHashMap<>(); paramMap.putAll(super.getParameterMap()); for (String paramName : this.multipartParameterNames) { if (!paramMap.containsKey(paramName)) { @@ -232,7 +232,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe if (part != null) { HttpHeaders headers = new HttpHeaders(); for (String headerName : part.getHeaderNames()) { - headers.put(headerName, new ArrayList(part.getHeaders(headerName))); + headers.put(headerName, new ArrayList<>(part.getHeaders(headerName))); } return headers; } diff --git a/spring-web/src/main/java/org/springframework/web/util/AbstractUriTemplateHandler.java b/spring-web/src/main/java/org/springframework/web/util/AbstractUriTemplateHandler.java index 1323bc9485c..b4a8cbb3186 100644 --- a/spring-web/src/main/java/org/springframework/web/util/AbstractUriTemplateHandler.java +++ b/spring-web/src/main/java/org/springframework/web/util/AbstractUriTemplateHandler.java @@ -38,7 +38,7 @@ public abstract class AbstractUriTemplateHandler implements UriTemplateHandler { private String baseUrl; - private final Map defaultUriVariables = new HashMap(); + private final Map defaultUriVariables = new HashMap<>(); /** @@ -92,7 +92,7 @@ public abstract class AbstractUriTemplateHandler implements UriTemplateHandler { @Override public URI expand(String uriTemplate, Map uriVariables) { if (!getDefaultUriVariables().isEmpty()) { - Map map = new HashMap(); + Map map = new HashMap<>(); map.putAll(getDefaultUriVariables()); map.putAll(uriVariables); uriVariables = map; diff --git a/spring-web/src/main/java/org/springframework/web/util/DefaultUriTemplateHandler.java b/spring-web/src/main/java/org/springframework/web/util/DefaultUriTemplateHandler.java index 1116df9e6bb..b6e3ea69001 100644 --- a/spring-web/src/main/java/org/springframework/web/util/DefaultUriTemplateHandler.java +++ b/spring-web/src/main/java/org/springframework/web/util/DefaultUriTemplateHandler.java @@ -127,7 +127,7 @@ public class DefaultUriTemplateHandler extends AbstractUriTemplateHandler { return builder.buildAndExpand(uriVariables).encode(); } else { - Map encodedUriVars = new HashMap(uriVariables.size()); + Map encodedUriVars = new HashMap<>(uriVariables.size()); for (Map.Entry entry : uriVariables.entrySet()) { encodedUriVars.put(entry.getKey(), applyStrictEncoding(entry.getValue())); } diff --git a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java index 3cc6f52498c..a1625910300 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java @@ -83,7 +83,7 @@ final class HierarchicalUriComponents extends UriComponents { this.port = port; this.path = path != null ? path : NULL_PATH_COMPONENT; this.queryParams = CollectionUtils.unmodifiableMultiValueMap( - queryParams != null ? queryParams : new LinkedMultiValueMap(0)); + queryParams != null ? queryParams : new LinkedMultiValueMap<>(0)); this.encoded = encoded; if (verify) { verify(); @@ -200,10 +200,10 @@ final class HierarchicalUriComponents extends UriComponents { private MultiValueMap encodeQueryParams(String encoding) throws UnsupportedEncodingException { int size = this.queryParams.size(); - MultiValueMap result = new LinkedMultiValueMap(size); + MultiValueMap result = new LinkedMultiValueMap<>(size); for (Map.Entry> entry : this.queryParams.entrySet()) { String name = encodeUriComponent(entry.getKey(), encoding, Type.QUERY_PARAM); - List values = new ArrayList(entry.getValue().size()); + List values = new ArrayList<>(entry.getValue().size()); for (String value : entry.getValue()) { values.add(encodeUriComponent(value, encoding, Type.QUERY_PARAM)); } @@ -335,11 +335,11 @@ final class HierarchicalUriComponents extends UriComponents { private MultiValueMap expandQueryParams(UriTemplateVariables variables) { int size = this.queryParams.size(); - MultiValueMap result = new LinkedMultiValueMap(size); + MultiValueMap result = new LinkedMultiValueMap<>(size); variables = new QueryUriTemplateVariables(variables); for (Map.Entry> entry : this.queryParams.entrySet()) { String name = expandUriComponent(entry.getKey(), variables); - List values = new ArrayList(entry.getValue().size()); + List values = new ArrayList<>(entry.getValue().size()); for (String value : entry.getValue()) { values.add(expandUriComponent(value, variables)); } @@ -714,7 +714,7 @@ final class HierarchicalUriComponents extends UriComponents { public PathSegmentComponent(List pathSegments) { Assert.notNull(pathSegments); - this.pathSegments = Collections.unmodifiableList(new ArrayList(pathSegments)); + this.pathSegments = Collections.unmodifiableList(new ArrayList<>(pathSegments)); } @Override @@ -739,7 +739,7 @@ final class HierarchicalUriComponents extends UriComponents { @Override public PathComponent encode(String encoding) throws UnsupportedEncodingException { List pathSegments = getPathSegments(); - List encodedPathSegments = new ArrayList(pathSegments.size()); + List encodedPathSegments = new ArrayList<>(pathSegments.size()); for (String pathSegment : pathSegments) { String encodedPathSegment = encodeUriComponent(pathSegment, encoding, Type.PATH_SEGMENT); encodedPathSegments.add(encodedPathSegment); @@ -757,7 +757,7 @@ final class HierarchicalUriComponents extends UriComponents { @Override public PathComponent expand(UriTemplateVariables uriVariables) { List pathSegments = getPathSegments(); - List expandedPathSegments = new ArrayList(pathSegments.size()); + List expandedPathSegments = new ArrayList<>(pathSegments.size()); for (String pathSegment : pathSegments) { String expandedPathSegment = expandUriComponent(pathSegment, uriVariables); expandedPathSegments.add(expandedPathSegment); @@ -806,7 +806,7 @@ final class HierarchicalUriComponents extends UriComponents { @Override public List getPathSegments() { - List result = new ArrayList(); + List result = new ArrayList<>(); for (PathComponent pathComponent : this.pathComponents) { result.addAll(pathComponent.getPathSegments()); } @@ -815,7 +815,7 @@ final class HierarchicalUriComponents extends UriComponents { @Override public PathComponent encode(String encoding) throws UnsupportedEncodingException { - List encodedComponents = new ArrayList(this.pathComponents.size()); + List encodedComponents = new ArrayList<>(this.pathComponents.size()); for (PathComponent pathComponent : this.pathComponents) { encodedComponents.add(pathComponent.encode(encoding)); } @@ -831,7 +831,7 @@ final class HierarchicalUriComponents extends UriComponents { @Override public PathComponent expand(UriTemplateVariables uriVariables) { - List expandedComponents = new ArrayList(this.pathComponents.size()); + List expandedComponents = new ArrayList<>(this.pathComponents.size()); for (PathComponent pathComponent : this.pathComponents) { expandedComponents.add(pathComponent.expand(uriVariables)); } diff --git a/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java b/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java index fb58aa63ba6..2757be91728 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java +++ b/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityReferences.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ class HtmlCharacterEntityReferences { private final String[] characterToEntityReferenceMap = new String[3000]; - private final Map entityReferenceToCharacterMap = new HashMap(252); + private final Map entityReferenceToCharacterMap = new HashMap<>(252); /** diff --git a/spring-web/src/main/java/org/springframework/web/util/OpaqueUriComponents.java b/spring-web/src/main/java/org/springframework/web/util/OpaqueUriComponents.java index e71f1b30a63..8a9780cc4f2 100644 --- a/spring-web/src/main/java/org/springframework/web/util/OpaqueUriComponents.java +++ b/spring-web/src/main/java/org/springframework/web/util/OpaqueUriComponents.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ import org.springframework.util.ObjectUtils; @SuppressWarnings("serial") final class OpaqueUriComponents extends UriComponents { - private static final MultiValueMap QUERY_PARAMS_NONE = new LinkedMultiValueMap(0); + private static final MultiValueMap QUERY_PARAMS_NONE = new LinkedMultiValueMap<>(0); private final String ssp; diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index 74d0105e1b1..aa56a877e9d 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -106,7 +106,7 @@ public class UriComponentsBuilder implements Cloneable { private CompositePathComponentBuilder pathBuilder; - private final MultiValueMap queryParams = new LinkedMultiValueMap(); + private final MultiValueMap queryParams = new LinkedMultiValueMap<>(); private String fragment; @@ -760,7 +760,7 @@ public class UriComponentsBuilder implements Cloneable { private static class CompositePathComponentBuilder implements PathComponentBuilder { - private final LinkedList builders = new LinkedList(); + private final LinkedList builders = new LinkedList<>(); public CompositePathComponentBuilder() { } @@ -813,7 +813,7 @@ public class UriComponentsBuilder implements Cloneable { @Override public PathComponent build() { int size = this.builders.size(); - List components = new ArrayList(size); + List components = new ArrayList<>(size); for (PathComponentBuilder componentBuilder : this.builders) { PathComponent pathComponent = componentBuilder.build(); if (pathComponent != null) { @@ -882,7 +882,7 @@ public class UriComponentsBuilder implements Cloneable { private static class PathSegmentComponentBuilder implements PathComponentBuilder { - private final List pathSegments = new LinkedList(); + private final List pathSegments = new LinkedList<>(); public void append(String... pathSegments) { for (String pathSegment : pathSegments) { diff --git a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java index 659030af113..c925758732a 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,7 +146,7 @@ public class UriTemplate implements Serializable { */ public Map match(String uri) { Assert.notNull(uri, "'uri' must not be null"); - Map result = new LinkedHashMap(this.variableNames.size()); + Map result = new LinkedHashMap<>(this.variableNames.size()); Matcher matcher = this.matchPattern.matcher(uri); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { @@ -189,7 +189,7 @@ public class UriTemplate implements Serializable { private static TemplateInfo parse(String uriTemplate) { int level = 0; - List variableNames = new ArrayList(); + List variableNames = new ArrayList<>(); StringBuilder pattern = new StringBuilder(); StringBuilder builder = new StringBuilder(); for (int i = 0 ; i < uriTemplate.length(); i++) { diff --git a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java index 1a7a4fe3221..31b21879181 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -526,7 +526,7 @@ public class UrlPathHelper { return vars; } else { - Map decodedVars = new LinkedHashMap(vars.size()); + Map decodedVars = new LinkedHashMap<>(vars.size()); for (Entry entry : vars.entrySet()) { decodedVars.put(entry.getKey(), decodeInternal(request, entry.getValue())); } @@ -550,7 +550,7 @@ public class UrlPathHelper { return vars; } else { - MultiValueMap decodedVars = new LinkedMultiValueMap (vars.size()); + MultiValueMap decodedVars = new LinkedMultiValueMap<>(vars.size()); for (String key : vars.keySet()) { for (String value : vars.get(key)) { decodedVars.add(key, decodeInternal(request, value)); diff --git a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java index 17dd339411f..aca26544fc7 100644 --- a/spring-web/src/main/java/org/springframework/web/util/WebUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/WebUtils.java @@ -641,7 +641,7 @@ public abstract class WebUtils { public static Map getParametersStartingWith(ServletRequest request, String prefix) { Assert.notNull(request, "Request must not be null"); Enumeration paramNames = request.getParameterNames(); - Map params = new TreeMap(); + Map params = new TreeMap<>(); if (prefix == null) { prefix = ""; } @@ -737,7 +737,7 @@ public abstract class WebUtils { * @since 3.2 */ public static MultiValueMap parseMatrixVariables(String matrixVariables) { - MultiValueMap result = new LinkedMultiValueMap(); + MultiValueMap result = new LinkedMultiValueMap<>(); if (!StringUtils.hasText(matrixVariables)) { return result; } diff --git a/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java b/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java index 5db52000a60..547575d0cde 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class HttpEntityTests { @Test public void noHeaders() { String body = "foo"; - HttpEntity entity = new HttpEntity(body); + HttpEntity entity = new HttpEntity<>(body); assertSame(body, entity.getBody()); assertTrue(entity.getHeaders().isEmpty()); } @@ -43,7 +43,7 @@ public class HttpEntityTests { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); String body = "foo"; - HttpEntity entity = new HttpEntity(body, headers); + HttpEntity entity = new HttpEntity<>(body, headers); assertEquals(body, entity.getBody()); assertEquals(MediaType.TEXT_PLAIN, entity.getHeaders().getContentType()); assertEquals("text/plain", entity.getHeaders().getFirst("Content-Type")); @@ -51,10 +51,10 @@ public class HttpEntityTests { @Test public void multiValueMap() { - MultiValueMap map = new LinkedMultiValueMap(); + MultiValueMap map = new LinkedMultiValueMap<>(); map.set("Content-Type", "text/plain"); String body = "foo"; - HttpEntity entity = new HttpEntity(body, map); + HttpEntity entity = new HttpEntity<>(body, map); assertEquals(body, entity.getBody()); assertEquals(MediaType.TEXT_PLAIN, entity.getHeaders().getContentType()); assertEquals("text/plain", entity.getHeaders().getFirst("Content-Type")); @@ -62,25 +62,25 @@ public class HttpEntityTests { @Test public void testEquals() { - MultiValueMap map1 = new LinkedMultiValueMap(); + MultiValueMap map1 = new LinkedMultiValueMap<>(); map1.set("Content-Type", "text/plain"); - MultiValueMap map2 = new LinkedMultiValueMap(); + MultiValueMap map2 = new LinkedMultiValueMap<>(); map2.set("Content-Type", "application/json"); - assertTrue(new HttpEntity().equals(new HttpEntity())); - assertFalse(new HttpEntity(map1).equals(new HttpEntity())); - assertFalse(new HttpEntity().equals(new HttpEntity(map2))); + assertTrue(new HttpEntity<>().equals(new HttpEntity())); + assertFalse(new HttpEntity<>(map1).equals(new HttpEntity())); + assertFalse(new HttpEntity<>().equals(new HttpEntity(map2))); - assertTrue(new HttpEntity(map1).equals(new HttpEntity(map1))); - assertFalse(new HttpEntity(map1).equals(new HttpEntity(map2))); + assertTrue(new HttpEntity<>(map1).equals(new HttpEntity(map1))); + assertFalse(new HttpEntity<>(map1).equals(new HttpEntity(map2))); assertTrue(new HttpEntity(null, null).equals(new HttpEntity(null, null))); - assertFalse(new HttpEntity("foo", null).equals(new HttpEntity(null, null))); - assertFalse(new HttpEntity(null, null).equals(new HttpEntity("bar", null))); + assertFalse(new HttpEntity<>("foo", null).equals(new HttpEntity(null, null))); + assertFalse(new HttpEntity(null, null).equals(new HttpEntity<>("bar", null))); - assertTrue(new HttpEntity("foo", map1).equals(new HttpEntity("foo", map1))); - assertFalse(new HttpEntity("foo", map1).equals(new HttpEntity("bar", map1))); + assertTrue(new HttpEntity<>("foo", map1).equals(new HttpEntity("foo", map1))); + assertFalse(new HttpEntity<>("foo", map1).equals(new HttpEntity("bar", map1))); } @Test @@ -88,9 +88,9 @@ public class HttpEntityTests { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); String body = "foo"; - HttpEntity httpEntity = new HttpEntity(body, headers); - ResponseEntity responseEntity = new ResponseEntity(body, headers, HttpStatus.OK); - ResponseEntity responseEntity2 = new ResponseEntity(body, headers, HttpStatus.OK); + HttpEntity httpEntity = new HttpEntity<>(body, headers); + ResponseEntity responseEntity = new ResponseEntity<>(body, headers, HttpStatus.OK); + ResponseEntity responseEntity2 = new ResponseEntity<>(body, headers, HttpStatus.OK); assertEquals(body, responseEntity.getBody()); assertEquals(MediaType.TEXT_PLAIN, responseEntity.getHeaders().getContentType()); @@ -108,9 +108,9 @@ public class HttpEntityTests { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); String body = "foo"; - HttpEntity httpEntity = new HttpEntity(body, headers); - RequestEntity requestEntity = new RequestEntity(body, headers, HttpMethod.GET, new URI("/")); - RequestEntity requestEntity2 = new RequestEntity(body, headers, HttpMethod.GET, new URI("/")); + HttpEntity httpEntity = new HttpEntity<>(body, headers); + RequestEntity requestEntity = new RequestEntity<>(body, headers, HttpMethod.GET, new URI("/")); + RequestEntity requestEntity2 = new RequestEntity<>(body, headers, HttpMethod.GET, new URI("/")); assertEquals(body, requestEntity.getBody()); assertEquals(MediaType.TEXT_PLAIN, requestEntity.getHeaders().getContentType()); diff --git a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java index 019cbbdcfaf..3e1a2ac0286 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java @@ -58,7 +58,7 @@ public class HttpHeadersTests { public void accept() { MediaType mediaType1 = new MediaType("text", "html"); MediaType mediaType2 = new MediaType("text", "plain"); - List mediaTypes = new ArrayList(2); + List mediaTypes = new ArrayList<>(2); mediaTypes.add(mediaType1); mediaTypes.add(mediaType2); headers.setAccept(mediaTypes); @@ -78,7 +78,7 @@ public class HttpHeadersTests { public void acceptCharsets() { Charset charset1 = Charset.forName("UTF-8"); Charset charset2 = Charset.forName("ISO-8859-1"); - List charsets = new ArrayList(2); + List charsets = new ArrayList<>(2); charsets.add(charset1); charsets.add(charset2); headers.setAcceptCharset(charsets); @@ -184,7 +184,7 @@ public class HttpHeadersTests { public void ifNoneMatchList() { String ifNoneMatch1 = "\"v2.6\""; String ifNoneMatch2 = "\"v2.7\", \"v2.8\""; - List ifNoneMatchList = new ArrayList(2); + List ifNoneMatchList = new ArrayList<>(2); ifNoneMatchList.add(ifNoneMatch1); ifNoneMatchList.add(ifNoneMatch2); headers.setIfNoneMatch(ifNoneMatchList); diff --git a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java index 3624ece763c..a7ba7bfe3dd 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import static org.junit.Assert.*; /** @author Arjen Poutsma */ public class HttpStatusTests { - private Map statusCodes = new LinkedHashMap(); + private Map statusCodes = new LinkedHashMap<>(); @Before public void createStatusCodes() { diff --git a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java index 99665b93eae..364db2ed259 100644 --- a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java +++ b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,14 +158,14 @@ public class MediaTypeTests { assertTrue("Invalid comparison result", audioBasicLevel.compareTo(audio) > 0); - List expected = new ArrayList(); + List expected = new ArrayList<>(); expected.add(audio); expected.add(audioBasic); expected.add(audioBasicLevel); expected.add(audioBasic07); expected.add(audioWave); - List result = new ArrayList(expected); + List result = new ArrayList<>(expected); Random rnd = new Random(); // shuffle & sort 10 times for (int i = 0; i < 10; i++) { @@ -277,7 +277,7 @@ public class MediaTypeTests { MediaType audioBasicLevel = new MediaType("audio", "basic", Collections.singletonMap("level", "1")); MediaType all = MediaType.ALL; - List expected = new ArrayList(); + List expected = new ArrayList<>(); expected.add(audioBasicLevel); expected.add(audioBasic); expected.add(audio); @@ -285,7 +285,7 @@ public class MediaTypeTests { expected.add(audio03); expected.add(all); - List result = new ArrayList(expected); + List result = new ArrayList<>(expected); Random rnd = new Random(); // shuffle & sort 10 times for (int i = 0; i < 10; i++) { @@ -304,12 +304,12 @@ public class MediaTypeTests { MediaType audioWave = new MediaType("audio", "wave"); MediaType textHtml = new MediaType("text", "html"); - List expected = new ArrayList(); + List expected = new ArrayList<>(); expected.add(textHtml); expected.add(audioBasic); expected.add(audioWave); - List result = new ArrayList(expected); + List result = new ArrayList<>(expected); MediaType.sortBySpecificity(result); for (int i = 0; i < result.size(); i++) { @@ -381,7 +381,7 @@ public class MediaTypeTests { MediaType audioBasicLevel = new MediaType("audio", "basic", Collections.singletonMap("level", "1")); MediaType all = MediaType.ALL; - List expected = new ArrayList(); + List expected = new ArrayList<>(); expected.add(audioBasicLevel); expected.add(audioBasic); expected.add(audio); @@ -389,7 +389,7 @@ public class MediaTypeTests { expected.add(audio07); expected.add(audio03); - List result = new ArrayList(expected); + List result = new ArrayList<>(expected); Random rnd = new Random(); // shuffle & sort 10 times for (int i = 0; i < 10; i++) { @@ -408,12 +408,12 @@ public class MediaTypeTests { MediaType audioWave = new MediaType("audio", "wave"); MediaType textHtml = new MediaType("text", "html"); - List expected = new ArrayList(); + List expected = new ArrayList<>(); expected.add(textHtml); expected.add(audioBasic); expected.add(audioWave); - List result = new ArrayList(expected); + List result = new ArrayList<>(expected); MediaType.sortBySpecificity(result); for (int i = 0; i < result.size(); i++) { diff --git a/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java index 2df6331b8e3..cde47f12979 100644 --- a/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class InterceptingClientHttpRequestFactoryTests { @Test public void basic() throws Exception { - List interceptors = new ArrayList(); + List interceptors = new ArrayList<>(); interceptors.add(new NoOpInterceptor()); interceptors.add(new NoOpInterceptor()); interceptors.add(new NoOpInterceptor()); @@ -77,7 +77,7 @@ public class InterceptingClientHttpRequestFactoryTests { @Test public void noExecution() throws Exception { - List interceptors = new ArrayList(); + List interceptors = new ArrayList<>(); interceptors.add(new ClientHttpRequestInterceptor() { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) diff --git a/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java index aaa03b596d0..af07211004a 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ public class FormHttpMessageConverterTests { @Test public void writeForm() throws IOException { - MultiValueMap body = new LinkedMultiValueMap(); + MultiValueMap body = new LinkedMultiValueMap<>(); body.set("name 1", "value 1"); body.add("name 2", "value 2+1"); body.add("name 2", "value 2+2"); @@ -130,7 +130,7 @@ public class FormHttpMessageConverterTests { @Test public void writeMultipart() throws Exception { - MultiValueMap parts = new LinkedMultiValueMap(); + MultiValueMap parts = new LinkedMultiValueMap<>(); parts.add("name 1", "value 1"); parts.add("name 2", "value 2+1"); parts.add("name 2", "value 2+2"); @@ -151,7 +151,7 @@ public class FormHttpMessageConverterTests { Source xml = new StreamSource(new StringReader("")); HttpHeaders entityHeaders = new HttpHeaders(); entityHeaders.setContentType(MediaType.TEXT_XML); - HttpEntity entity = new HttpEntity(xml, entityHeaders); + HttpEntity entity = new HttpEntity<>(xml, entityHeaders); parts.add("xml", entity); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); @@ -209,12 +209,12 @@ public class FormHttpMessageConverterTests { MyBean myBean = new MyBean(); myBean.setString("foo"); - MultiValueMap parts = new LinkedMultiValueMap(); + MultiValueMap parts = new LinkedMultiValueMap<>(); parts.add("part1", myBean); HttpHeaders entityHeaders = new HttpHeaders(); entityHeaders.setContentType(MediaType.TEXT_XML); - HttpEntity entity = new HttpEntity(myBean, entityHeaders); + HttpEntity entity = new HttpEntity<>(myBean, entityHeaders); parts.add("part2", entity); MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); diff --git a/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java index 10a52d919dc..479b9aeeeae 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class HttpMessageConverterTests { @Test public void canRead() { MediaType mediaType = new MediaType("foo", "bar"); - HttpMessageConverter converter = new MyHttpMessageConverter(mediaType); + HttpMessageConverter converter = new MyHttpMessageConverter<>(mediaType); assertTrue(converter.canRead(MyType.class, mediaType)); assertFalse(converter.canRead(MyType.class, new MediaType("foo", "*"))); @@ -50,7 +50,7 @@ public class HttpMessageConverterTests { @Test public void canReadWithWildcardSubtype() { MediaType mediaType = new MediaType("foo"); - HttpMessageConverter converter = new MyHttpMessageConverter(mediaType); + HttpMessageConverter converter = new MyHttpMessageConverter<>(mediaType); assertTrue(converter.canRead(MyType.class, new MediaType("foo", "bar"))); assertTrue(converter.canRead(MyType.class, new MediaType("foo", "*"))); @@ -60,7 +60,7 @@ public class HttpMessageConverterTests { @Test public void canWrite() { MediaType mediaType = new MediaType("foo", "bar"); - HttpMessageConverter converter = new MyHttpMessageConverter(mediaType); + HttpMessageConverter converter = new MyHttpMessageConverter<>(mediaType); assertTrue(converter.canWrite(MyType.class, mediaType)); assertTrue(converter.canWrite(MyType.class, new MediaType("foo", "*"))); @@ -70,7 +70,7 @@ public class HttpMessageConverterTests { @Test public void canWriteWithWildcardInSupportedSubtype() { MediaType mediaType = new MediaType("foo"); - HttpMessageConverter converter = new MyHttpMessageConverter(mediaType); + HttpMessageConverter converter = new MyHttpMessageConverter<>(mediaType); assertTrue(converter.canWrite(MyType.class, new MediaType("foo", "bar"))); assertTrue(converter.canWrite(MyType.class, new MediaType("foo", "*"))); diff --git a/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java index a4f9c46584e..f28e8b7c36f 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java @@ -105,7 +105,7 @@ public class ResourceRegionHttpMessageConverterTests { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); Resource body = new ClassPathResource("byterangeresource.txt", getClass()); List rangeList = HttpRange.parseRanges("bytes=0-5,7-15,17-20,22-38"); - List regions = new ArrayList(); + List regions = new ArrayList<>(); for(HttpRange range : rangeList) { regions.add(range.toResourceRegion(body)); } diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java index bcaa76b98cf..fe48bcb663e 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class AtomFeedHttpMessageConverterTests { entry2.setId("id2"); entry2.setTitle("title2"); - List entries = new ArrayList(2); + List entries = new ArrayList<>(2); entries.add(entry1); entries.add(entry2); feed.setEntries(entries); diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index 16fcfc00f22..65dfc2bcb78 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class RssChannelHttpMessageConverterTests { Item item2 = new Item(); item2.setTitle("title2"); - List items = new ArrayList(2); + List items = new ArrayList<>(2); items.add(item1); items.add(item2); channel.setItems(items); diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java index c71f750b33a..388d944009b 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,7 +94,7 @@ public class GsonHttpMessageConverterTests { assertEquals(42, n.longValue()); n = (Number) result.get("fraction"); assertEquals(42D, n.doubleValue(), 0D); - List array = new ArrayList(); + List array = new ArrayList<>(); array.add("Foo"); array.add("Bar"); assertEquals(array, result.get("array")); diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java index ddb9e1e6ebe..ec9910750b4 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java @@ -344,7 +344,7 @@ public class Jackson2ObjectMapperBuilderTests { public void mixIns() { Class target = String.class; Class mixInSource = Object.class; - Map, Class> mixIns = new HashMap, Class>(); + Map, Class> mixIns = new HashMap<>(); mixIns.put(target, mixInSource); ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().modules() @@ -374,7 +374,7 @@ public class Jackson2ObjectMapperBuilderTests { public void completeSetup() throws JsonMappingException { NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance; - Map, JsonDeserializer> deserializerMap = new HashMap, JsonDeserializer>(); + Map, JsonDeserializer> deserializerMap = new HashMap<>(); JsonDeserializer deserializer = new DateDeserializers.DateDeserializer(); deserializerMap.put(Date.class, deserializer); diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java index d678c660399..094c516f141 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java @@ -283,7 +283,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { public void setMixIns() { Class target = String.class; Class mixinSource = Object.class; - Map, Class> mixIns = new HashMap, Class>(); + Map, Class> mixIns = new HashMap<>(); mixIns.put(target, mixinSource); this.factory.setModules(Collections.emptyList()); @@ -316,7 +316,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { assertTrue(this.factory.isSingleton()); assertEquals(ObjectMapper.class, this.factory.getObjectType()); - Map, JsonDeserializer> deserializers = new HashMap, JsonDeserializer>(); + Map, JsonDeserializer> deserializers = new HashMap<>(); deserializers.put(Date.class, new DateDeserializer()); JsonSerializer> serializer1 = new ClassSerializer(); diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java index e2b15b08619..d9c1731c170 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java @@ -99,7 +99,7 @@ public class MappingJackson2HttpMessageConverterTests { assertEquals("Foo", result.get("string")); assertEquals(42, result.get("number")); assertEquals(42D, (Double) result.get("fraction"), 0D); - List array = new ArrayList(); + List array = new ArrayList<>(); array.add("Foo"); array.add("Bar"); assertEquals(array, result.get("array")); @@ -329,7 +329,7 @@ public class MappingJackson2HttpMessageConverterTests { @Test // SPR-13318 public void writeSubTypeList() throws Exception { MockHttpOutputMessage outputMessage = new MockHttpOutputMessage(); - List beans = new ArrayList(); + List beans = new ArrayList<>(); MyBean foo = new MyBean(); foo.setString("Foo"); foo.setNumber(42); diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java index f88088eaa22..557a66e17b0 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ public class SourceHttpMessageConverterTests { @Before public void setUp() throws IOException { - converter = new SourceHttpMessageConverter(); + converter = new SourceHttpMessageConverter<>(); Resource external = new ClassPathResource("external.txt", getClass()); bodyExternal = " values = new LinkedList(); + private final List values = new LinkedList<>(); public void setValue(Object value) { @@ -60,7 +60,7 @@ class HeaderValueHolder { } public List getStringValues() { - List stringList = new ArrayList(this.values.size()); + List stringList = new ArrayList<>(this.values.size()); for (Object value : this.values) { stringList.add(value.toString()); } diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java index 7fb4f8ec953..1a04889667b 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockAsyncContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,13 +45,13 @@ public class MockAsyncContext implements AsyncContext { private final HttpServletResponse response; - private final List listeners = new ArrayList(); + private final List listeners = new ArrayList<>(); private String dispatchedPath; private long timeout = 10 * 1000L; // 10 seconds is Tomcat's default - private final List dispatchHandlers = new ArrayList(); + private final List dispatchHandlers = new ArrayList<>(); public MockAsyncContext(ServletRequest request, ServletResponse response) { diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterConfig.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterConfig.java index 116312d4c45..276d8759d39 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterConfig.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockFilterConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class MockFilterConfig implements FilterConfig { private final String filterName; - private final Map initParameters = new LinkedHashMap(); + private final Map initParameters = new LinkedHashMap<>(); /** diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java index da21c6e27d4..1406333d820 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,7 +144,7 @@ public class MockHttpServletRequest implements HttpServletRequest { // ServletRequest properties // --------------------------------------------------------------------- - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private String characterEncoding; @@ -152,7 +152,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private String contentType; - private final Map parameters = new LinkedHashMap(16); + private final Map parameters = new LinkedHashMap<>(16); private String protocol = DEFAULT_PROTOCOL; @@ -167,7 +167,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private String remoteHost = DEFAULT_REMOTE_HOST; /** List of locales in descending order */ - private final List locales = new LinkedList(); + private final List locales = new LinkedList<>(); private boolean secure = false; @@ -198,7 +198,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private Cookie[] cookies; - private final Map headers = new LinkedCaseInsensitiveMap(); + private final Map headers = new LinkedCaseInsensitiveMap<>(); private String method; @@ -210,7 +210,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private String remoteUser; - private final Set userRoles = new HashSet(); + private final Set userRoles = new HashSet<>(); private Principal userPrincipal; @@ -228,7 +228,7 @@ public class MockHttpServletRequest implements HttpServletRequest { private boolean requestedSessionIdFromURL = false; - private final MultiValueMap parts = new LinkedMultiValueMap(); + private final MultiValueMap parts = new LinkedMultiValueMap<>(); // --------------------------------------------------------------------- @@ -347,7 +347,7 @@ public class MockHttpServletRequest implements HttpServletRequest { @Override public Enumeration getAttributeNames() { checkActive(); - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override @@ -973,7 +973,7 @@ public class MockHttpServletRequest implements HttpServletRequest { @Override public Enumeration getHeaders(String name) { HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name); - return Collections.enumeration(header != null ? header.getStringValues() : new LinkedList()); + return Collections.enumeration(header != null ? header.getStringValues() : new LinkedList<>()); } @Override @@ -1213,7 +1213,7 @@ public class MockHttpServletRequest implements HttpServletRequest { @Override public Collection getParts() throws IOException, IllegalStateException, ServletException { - List result = new LinkedList(); + List result = new LinkedList<>(); for (List list : this.parts.values()) { result.addAll(list); } diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java index c0986b29557..5f3f56eefd2 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpServletResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,9 +102,9 @@ public class MockHttpServletResponse implements HttpServletResponse { // HttpServletResponse properties //--------------------------------------------------------------------- - private final List cookies = new ArrayList(); + private final List cookies = new ArrayList<>(); - private final Map headers = new LinkedCaseInsensitiveMap(); + private final Map headers = new LinkedCaseInsensitiveMap<>(); private int status = HttpServletResponse.SC_OK; @@ -112,7 +112,7 @@ public class MockHttpServletResponse implements HttpServletResponse { private String forwardedUrl; - private final List includedUrls = new ArrayList(); + private final List includedUrls = new ArrayList<>(); //--------------------------------------------------------------------- diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpSession.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpSession.java index 6e1b21f0be4..2c8a411d404 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpSession.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockHttpSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ public class MockHttpSession implements HttpSession { private final ServletContext servletContext; - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private boolean invalid = false; @@ -166,7 +166,7 @@ public class MockHttpSession implements HttpSession { @Override public Enumeration getAttributeNames() { assertIsValid(); - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override @@ -270,7 +270,7 @@ public class MockHttpSession implements HttpSession { * @return a representation of this session's serialized state */ public Serializable serializeState() { - HashMap state = new HashMap(); + HashMap state = new HashMap<>(); for (Iterator> it = this.attributes.entrySet().iterator(); it.hasNext();) { Map.Entry entry = it.next(); String name = entry.getKey(); diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java index 7f218695a52..8a92ffefe6b 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockMultipartHttpServletRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest; public class MockMultipartHttpServletRequest extends MockHttpServletRequest implements MultipartHttpServletRequest { private final MultiValueMap multipartFiles = - new LinkedMultiValueMap(); + new LinkedMultiValueMap<>(); /** @@ -112,7 +112,7 @@ public class MockMultipartHttpServletRequest extends MockHttpServletRequest impl @Override public MultiValueMap getMultiFileMap() { - return new LinkedMultiValueMap(this.multipartFiles); + return new LinkedMultiValueMap<>(this.multipartFiles); } @Override diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java index 95acca3f91d..020d57866c7 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockPageContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class MockPageContext extends PageContext { private final ServletConfig servletConfig; - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private JspWriter out; @@ -257,7 +257,7 @@ public class MockPageContext extends PageContext { } public Enumeration getAttributeNames() { - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletConfig.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockServletConfig.java index d7738c95273..1da0f87349a 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletConfig.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockServletConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public class MockServletConfig implements ServletConfig { private final String servletName; - private final Map initParameters = new LinkedHashMap(); + private final Map initParameters = new LinkedHashMap<>(); /** diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java b/spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java index acaef598c34..2d334ee8a91 100644 --- a/spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java +++ b/spring-web/src/test/java/org/springframework/mock/web/test/MockServletContext.java @@ -106,7 +106,7 @@ public class MockServletContext implements ServletContext { private static final String TEMP_DIR_SYSTEM_PROPERTY = "java.io.tmpdir"; private static final Set DEFAULT_SESSION_TRACKING_MODES = - new LinkedHashSet(3); + new LinkedHashSet<>(3); static { DEFAULT_SESSION_TRACKING_MODES.add(SessionTrackingMode.COOKIE); @@ -123,7 +123,7 @@ public class MockServletContext implements ServletContext { private String contextPath = ""; - private final Map contexts = new HashMap(); + private final Map contexts = new HashMap<>(); private int majorVersion = 3; @@ -133,17 +133,17 @@ public class MockServletContext implements ServletContext { private int effectiveMinorVersion = 0; - private final Map namedRequestDispatchers = new HashMap(); + private final Map namedRequestDispatchers = new HashMap<>(); private String defaultServletName = COMMON_DEFAULT_SERVLET_NAME; - private final Map initParameters = new LinkedHashMap(); + private final Map initParameters = new LinkedHashMap<>(); - private final Map attributes = new LinkedHashMap(); + private final Map attributes = new LinkedHashMap<>(); private String servletContextName = "MockServletContext"; - private final Set declaredRoles = new LinkedHashSet(); + private final Set declaredRoles = new LinkedHashSet<>(); private Set sessionTrackingModes; @@ -304,7 +304,7 @@ public class MockServletContext implements ServletContext { if (ObjectUtils.isEmpty(fileList)) { return null; } - Set resourcePaths = new LinkedHashSet(fileList.length); + Set resourcePaths = new LinkedHashSet<>(fileList.length); for (String fileEntry : fileList) { String resultPath = actualPath + fileEntry; if (resource.createRelative(fileEntry).getFile().isDirectory()) { @@ -502,7 +502,7 @@ public class MockServletContext implements ServletContext { @Override public Enumeration getAttributeNames() { - return Collections.enumeration(new LinkedHashSet(this.attributes.keySet())); + return Collections.enumeration(new LinkedHashSet<>(this.attributes.keySet())); } @Override diff --git a/spring-web/src/test/java/org/springframework/protobuf/Msg.java b/spring-web/src/test/java/org/springframework/protobuf/Msg.java index 0d111ad213d..20547ce7228 100644 --- a/spring-web/src/test/java/org/springframework/protobuf/Msg.java +++ b/spring-web/src/test/java/org/springframework/protobuf/Msg.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Generated by the protocol buffer compiler. DO NOT EDIT! // source: sample.proto @@ -614,11 +630,10 @@ public final class Msg extends org.springframework.protobuf.SecondMsg, org.springframework.protobuf.SecondMsg.Builder, org.springframework.protobuf.SecondMsgOrBuilder> getBlahFieldBuilder() { if (blahBuilder_ == null) { - blahBuilder_ = new com.google.protobuf.SingleFieldBuilder< - org.springframework.protobuf.SecondMsg, org.springframework.protobuf.SecondMsg.Builder, org.springframework.protobuf.SecondMsgOrBuilder>( - blah_, - getParentForChildren(), - isClean()); + blahBuilder_ = new com.google.protobuf.SingleFieldBuilder<>( + blah_, + getParentForChildren(), + isClean()); blah_ = null; } return blahBuilder_; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java index 82b6482a1ca..05dbfd78cd1 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -242,7 +242,7 @@ public class ServletRequestDataBinderTests { assertTrue("Doesn't contain tory", !pvs.contains("tory")); PropertyValue[] ps = pvs.getPropertyValues(); - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("forname", "Tony"); m.put("surname", "Blair"); m.put("age", "50"); diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java index c12711dc231..2b39e1fa164 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,7 +105,7 @@ public class WebRequestDataBinderIntegrationTests { PartsBean bean = new PartsBean(); partsServlet.setBean(bean); - MultiValueMap parts = new LinkedMultiValueMap(); + MultiValueMap parts = new LinkedMultiValueMap<>(); Resource firstPart = new ClassPathResource("/org/springframework/http/converter/logo.jpg"); parts.add("firstPart", firstPart); parts.add("secondPart", "secondValue"); @@ -122,7 +122,7 @@ public class WebRequestDataBinderIntegrationTests { PartListBean bean = new PartListBean(); partListServlet.setBean(bean); - MultiValueMap parts = new LinkedMultiValueMap(); + MultiValueMap parts = new LinkedMultiValueMap<>(); parts.add("partList", "first value"); parts.add("partList", "second value"); Resource logo = new ClassPathResource("/org/springframework/http/converter/logo.jpg"); diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java index 508be6d3ab3..38c986d79be 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java @@ -319,7 +319,7 @@ public class WebRequestDataBinderTests { assertTrue("Doesn't contain tory", !pvs.contains("tory")); PropertyValue[] pvArray = pvs.getPropertyValues(); - Map m = new HashMap(); + Map m = new HashMap<>(); m.put("forname", "Tony"); m.put("surname", "Blair"); m.put("age", "50"); diff --git a/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java b/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java index 3a59757e6ca..9916e084afe 100644 --- a/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -56,7 +56,7 @@ public class HttpMessageConverterExtractorTests { @Test public void noContent() throws IOException { HttpMessageConverter converter = mock(HttpMessageConverter.class); - extractor = new HttpMessageConverterExtractor(String.class, createConverterList(converter)); + extractor = new HttpMessageConverterExtractor<>(String.class, createConverterList(converter)); given(response.getStatusCode()).willReturn(HttpStatus.NO_CONTENT); Object result = extractor.extractData(response); @@ -67,7 +67,7 @@ public class HttpMessageConverterExtractorTests { @Test public void notModified() throws IOException { HttpMessageConverter converter = mock(HttpMessageConverter.class); - extractor = new HttpMessageConverterExtractor(String.class, createConverterList(converter)); + extractor = new HttpMessageConverterExtractor<>(String.class, createConverterList(converter)); given(response.getStatusCode()).willReturn(HttpStatus.NOT_MODIFIED); Object result = extractor.extractData(response); @@ -78,7 +78,7 @@ public class HttpMessageConverterExtractorTests { @Test public void informational() throws IOException { HttpMessageConverter converter = mock(HttpMessageConverter.class); - extractor = new HttpMessageConverterExtractor(String.class, createConverterList(converter)); + extractor = new HttpMessageConverterExtractor<>(String.class, createConverterList(converter)); given(response.getStatusCode()).willReturn(HttpStatus.CONTINUE); Object result = extractor.extractData(response); @@ -91,7 +91,7 @@ public class HttpMessageConverterExtractorTests { HttpMessageConverter converter = mock(HttpMessageConverter.class); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentLength(0); - extractor = new HttpMessageConverterExtractor(String.class, createConverterList(converter)); + extractor = new HttpMessageConverterExtractor<>(String.class, createConverterList(converter)); given(response.getStatusCode()).willReturn(HttpStatus.OK); given(response.getHeaders()).willReturn(responseHeaders); @@ -104,10 +104,10 @@ public class HttpMessageConverterExtractorTests { @SuppressWarnings("unchecked") public void emptyMessageBody() throws IOException { HttpMessageConverter converter = mock(HttpMessageConverter.class); - List> converters = new ArrayList>(); + List> converters = new ArrayList<>(); converters.add(converter); HttpHeaders responseHeaders = new HttpHeaders(); - extractor = new HttpMessageConverterExtractor(String.class, createConverterList(converter)); + extractor = new HttpMessageConverterExtractor<>(String.class, createConverterList(converter)); given(response.getStatusCode()).willReturn(HttpStatus.OK); given(response.getHeaders()).willReturn(responseHeaders); given(response.getBody()).willReturn(new ByteArrayInputStream("".getBytes())); @@ -120,13 +120,13 @@ public class HttpMessageConverterExtractorTests { @SuppressWarnings("unchecked") public void normal() throws IOException { HttpMessageConverter converter = mock(HttpMessageConverter.class); - List> converters = new ArrayList>(); + List> converters = new ArrayList<>(); converters.add(converter); HttpHeaders responseHeaders = new HttpHeaders(); MediaType contentType = MediaType.TEXT_PLAIN; responseHeaders.setContentType(contentType); String expected = "Foo"; - extractor = new HttpMessageConverterExtractor(String.class, converters); + extractor = new HttpMessageConverterExtractor<>(String.class, converters); given(response.getStatusCode()).willReturn(HttpStatus.OK); given(response.getHeaders()).willReturn(responseHeaders); given(response.getBody()).willReturn(new ByteArrayInputStream(expected.getBytes())); @@ -142,12 +142,12 @@ public class HttpMessageConverterExtractorTests { @SuppressWarnings("unchecked") public void cannotRead() throws IOException { HttpMessageConverter converter = mock(HttpMessageConverter.class); - List> converters = new ArrayList>(); + List> converters = new ArrayList<>(); converters.add(converter); HttpHeaders responseHeaders = new HttpHeaders(); MediaType contentType = MediaType.TEXT_PLAIN; responseHeaders.setContentType(contentType); - extractor = new HttpMessageConverterExtractor(String.class, converters); + extractor = new HttpMessageConverterExtractor<>(String.class, converters); given(response.getStatusCode()).willReturn(HttpStatus.OK); given(response.getHeaders()).willReturn(responseHeaders); given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes())); @@ -181,7 +181,7 @@ public class HttpMessageConverterExtractorTests { private List> createConverterList( HttpMessageConverter converter) { - List> converters = new ArrayList>(1); + List> converters = new ArrayList<>(1); converters.add(converter); return converters; } diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java index d5f00fc2548..251a744e620 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java @@ -113,7 +113,7 @@ public class RestTemplateIntegrationTests extends AbstractJettyServerTestCase { public void postForLocationEntity() throws URISyntaxException { HttpHeaders entityHeaders = new HttpHeaders(); entityHeaders.setContentType(new MediaType("text", "plain", Charset.forName("ISO-8859-15"))); - HttpEntity entity = new HttpEntity(helloWorld, entityHeaders); + HttpEntity entity = new HttpEntity<>(helloWorld, entityHeaders); URI location = template.postForLocation(baseUrl + "/{method}", entity, "post"); assertEquals("Invalid location", new URI(baseUrl + "/post/1"), location); } @@ -171,7 +171,7 @@ public class RestTemplateIntegrationTests extends AbstractJettyServerTestCase { @Test public void multipart() throws UnsupportedEncodingException { - MultiValueMap parts = new LinkedMultiValueMap(); + MultiValueMap parts = new LinkedMultiValueMap<>(); parts.add("name 1", "value 1"); parts.add("name 2", "value 2+1"); parts.add("name 2", "value 2+2"); @@ -183,7 +183,7 @@ public class RestTemplateIntegrationTests extends AbstractJettyServerTestCase { @Test public void form() throws UnsupportedEncodingException { - MultiValueMap form = new LinkedMultiValueMap(); + MultiValueMap form = new LinkedMultiValueMap<>(); form.add("name 1", "value 1"); form.add("name 2", "value 2+1"); form.add("name 2", "value 2+2"); @@ -195,7 +195,7 @@ public class RestTemplateIntegrationTests extends AbstractJettyServerTestCase { public void exchangeGet() throws Exception { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("MyHeader", "MyValue"); - HttpEntity requestEntity = new HttpEntity(requestHeaders); + HttpEntity requestEntity = new HttpEntity<>(requestHeaders); ResponseEntity response = template.exchange(baseUrl + "/{method}", HttpMethod.GET, requestEntity, String.class, "get"); assertEquals("Invalid content", helloWorld, response.getBody()); @@ -206,7 +206,7 @@ public class RestTemplateIntegrationTests extends AbstractJettyServerTestCase { HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("MyHeader", "MyValue"); requestHeaders.setContentType(MediaType.TEXT_PLAIN); - HttpEntity requestEntity = new HttpEntity(helloWorld, requestHeaders); + HttpEntity requestEntity = new HttpEntity<>(helloWorld, requestHeaders); HttpEntity result = template.exchange(baseUrl + "/{method}", HttpMethod.POST, requestEntity, Void.class, "post"); assertEquals("Invalid location", new URI(baseUrl + "/post/1"), result.getHeaders().getLocation()); assertFalse(result.hasBody()); @@ -220,7 +220,7 @@ public class RestTemplateIntegrationTests extends AbstractJettyServerTestCase { bean.setWith1("with"); bean.setWith2("with"); bean.setWithout("without"); - HttpEntity entity = new HttpEntity(bean, entityHeaders); + HttpEntity entity = new HttpEntity<>(bean, entityHeaders); String s = template.postForObject(baseUrl + "/jsonpost", entity, String.class); assertTrue(s.contains("\"with1\":\"with\"")); assertTrue(s.contains("\"with2\":\"with\"")); @@ -234,7 +234,7 @@ public class RestTemplateIntegrationTests extends AbstractJettyServerTestCase { MySampleBean bean = new MySampleBean("with", "with", "without"); MappingJacksonValue jacksonValue = new MappingJacksonValue(bean); jacksonValue.setSerializationView(MyJacksonView1.class); - HttpEntity entity = new HttpEntity(jacksonValue, entityHeaders); + HttpEntity entity = new HttpEntity<>(jacksonValue, entityHeaders); String s = template.postForObject(baseUrl + "/jsonpost", entity, String.class); assertTrue(s.contains("\"with1\":\"with\"")); assertFalse(s.contains("\"with2\":\"with\"")); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java index 4a60a85e297..62c81cf18a8 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public class DeferredResultTests { public void setResult() { DeferredResultHandler handler = mock(DeferredResultHandler.class); - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); @@ -45,7 +45,7 @@ public class DeferredResultTests { public void setResultTwice() { DeferredResultHandler handler = mock(DeferredResultHandler.class); - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); result.setResultHandler(handler); assertTrue(result.setResult("hello")); @@ -58,7 +58,7 @@ public class DeferredResultTests { public void isSetOrExpired() { DeferredResultHandler handler = mock(DeferredResultHandler.class); - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); result.setResultHandler(handler); assertFalse(result.isSetOrExpired()); @@ -74,7 +74,7 @@ public class DeferredResultTests { public void hasResult() { DeferredResultHandler handler = mock(DeferredResultHandler.class); - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); result.setResultHandler(handler); assertFalse(result.hasResult()); @@ -89,7 +89,7 @@ public class DeferredResultTests { public void onCompletion() throws Exception { final StringBuilder sb = new StringBuilder(); - DeferredResult result = new DeferredResult(); + DeferredResult result = new DeferredResult<>(); result.onCompletion(new Runnable() { @Override public void run() { @@ -109,7 +109,7 @@ public class DeferredResultTests { DeferredResultHandler handler = mock(DeferredResultHandler.class); - DeferredResult result = new DeferredResult(null, "timeout result"); + DeferredResult result = new DeferredResult<>(null, "timeout result"); result.setResultHandler(handler); result.onTimeout(new Runnable() { @Override diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java index d4a2ad47355..384299da3c8 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -233,7 +233,7 @@ public class WebAsyncManagerTests { given(this.asyncWebRequest.getNativeRequest(HttpServletRequest.class)).willReturn(this.servletRequest); @SuppressWarnings("unchecked") - WebAsyncTask asyncTask = new WebAsyncTask(1000L, executor, mock(Callable.class)); + WebAsyncTask asyncTask = new WebAsyncTask<>(1000L, executor, mock(Callable.class)); this.asyncManager.startCallableProcessing(asyncTask); verify(executor).submit((Runnable) notNull()); @@ -256,7 +256,7 @@ public class WebAsyncManagerTests { @Test public void startDeferredResultProcessing() throws Exception { - DeferredResult deferredResult = new DeferredResult(1000L); + DeferredResult deferredResult = new DeferredResult<>(1000L); String concurrentResult = "abc"; DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class); @@ -278,7 +278,7 @@ public class WebAsyncManagerTests { @Test public void startDeferredResultProcessingBeforeConcurrentHandlingException() throws Exception { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); Exception exception = new Exception(); DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class); @@ -303,7 +303,7 @@ public class WebAsyncManagerTests { @Test public void startDeferredResultProcessingPreProcessException() throws Exception { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); Exception exception = new Exception(); DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class); @@ -323,7 +323,7 @@ public class WebAsyncManagerTests { @Test public void startDeferredResultProcessingPostProcessException() throws Exception { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); Exception exception = new Exception(); DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java index 766942dc027..30b1a13a201 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ public class WebAsyncManagerTimeoutTests { public void startCallableProcessingTimeoutAndResumeThroughCallback() throws Exception { StubCallable callable = new StubCallable(); - WebAsyncTask webAsyncTask = new WebAsyncTask(callable); + WebAsyncTask webAsyncTask = new WebAsyncTask<>(callable); webAsyncTask.onTimeout(new Callable() { @Override public Object call() throws Exception { @@ -152,7 +152,7 @@ public class WebAsyncManagerTimeoutTests { @Test public void startDeferredResultProcessingTimeoutAndComplete() throws Exception { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); DeferredResultProcessingInterceptor interceptor = mock(DeferredResultProcessingInterceptor.class); given(interceptor.handleTimeout(this.asyncWebRequest, deferredResult)).willReturn(true); @@ -175,7 +175,7 @@ public class WebAsyncManagerTimeoutTests { @Test public void startDeferredResultProcessingTimeoutAndResumeWithDefaultResult() throws Exception { - DeferredResult deferredResult = new DeferredResult(null, 23); + DeferredResult deferredResult = new DeferredResult<>(null, 23); this.asyncManager.startDeferredResultProcessing(deferredResult); AsyncEvent event = null; @@ -189,7 +189,7 @@ public class WebAsyncManagerTimeoutTests { @Test public void startDeferredResultProcessingTimeoutAndResumeThroughCallback() throws Exception { - final DeferredResult deferredResult = new DeferredResult(); + final DeferredResult deferredResult = new DeferredResult<>(); deferredResult.onTimeout(new Runnable() { @Override public void run() { @@ -210,7 +210,7 @@ public class WebAsyncManagerTimeoutTests { @Test public void startDeferredResultProcessingTimeoutAndResumeThroughInterceptor() throws Exception { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() { @Override @@ -234,7 +234,7 @@ public class WebAsyncManagerTimeoutTests { @Test public void startDeferredResultProcessingAfterTimeoutException() throws Exception { - DeferredResult deferredResult = new DeferredResult(); + DeferredResult deferredResult = new DeferredResult<>(); final Exception exception = new Exception(); DeferredResultProcessingInterceptor interceptor = new DeferredResultProcessingInterceptorAdapter() { diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java index 8d5c7aed344..bab96d3d349 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,7 +120,7 @@ public class ModelFactoryOrderingTests { Class type = controller.getClass(); Set methods = MethodIntrospector.selectMethods(type, METHOD_FILTER); - List modelMethods = new ArrayList(); + List modelMethods = new ArrayList<>(); for (Method method : methods) { InvocableHandlerMethod modelMethod = new InvocableHandlerMethod(controller, method); modelMethod.setHandlerMethodArgumentResolvers(resolvers); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java index ef2a3f01831..717dc58d2d2 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -104,7 +104,7 @@ public class RequestHeaderMapMethodArgumentResolverTests { request.addHeader(name, value1); request.addHeader(name, value2); - MultiValueMap expected = new LinkedMultiValueMap(1); + MultiValueMap expected = new LinkedMultiValueMap<>(1); expected.add(name, value1); expected.add(name, value2); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java index cae73f460d7..1d60508c0e3 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ public class RequestParamMapMethodArgumentResolverTests { String value2 = "baz"; request.addParameter(name, new String[]{value1, value2}); - MultiValueMap expected = new LinkedMultiValueMap(1); + MultiValueMap expected = new LinkedMultiValueMap<>(1); expected.add(name, value1); expected.add(name, value2); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java index 51d791eb80a..06c15bf8d51 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,14 +64,14 @@ public class SessionAttributesHandlerTests { sessionAttributeStore.storeAttribute(request, "attr4", new TestBean()); assertEquals("Named attributes (attr1, attr2) should be 'known' right away", - new HashSet(asList("attr1", "attr2")), + new HashSet<>(asList("attr1", "attr2")), sessionAttributesHandler.retrieveAttributes(request).keySet()); // Resolve 'attr3' by type sessionAttributesHandler.isHandlerSessionAttribute("attr3", TestBean.class); assertEquals("Named attributes (attr1, attr2) and resolved attribute (att3) should be 'known'", - new HashSet(asList("attr1", "attr2", "attr3")), + new HashSet<>(asList("attr1", "attr2", "attr3")), sessionAttributesHandler.retrieveAttributes(request).keySet()); } diff --git a/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java b/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java index 7a7b3abcae3..ad41044af07 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class CompositeUriComponentsContributorTests { @Test public void supportsParameter() { - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); resolvers.add(new RequestParamMethodArgumentResolver(false)); resolvers.add(new RequestHeaderMethodArgumentResolver(null)); resolvers.add(new RequestParamMethodArgumentResolver(true)); diff --git a/spring-web/src/test/java/org/springframework/web/method/support/StubArgumentResolver.java b/spring-web/src/test/java/org/springframework/web/method/support/StubArgumentResolver.java index 2110548d81a..66720bf8d11 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/StubArgumentResolver.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/StubArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class StubArgumentResolver implements HandlerMethodArgumentResolver { private final Object stubValue; - private List resolvedParameters = new ArrayList(); + private List resolvedParameters = new ArrayList<>(); public StubArgumentResolver(Class supportedParameterType, Object stubValue) { this.parameterType = supportedParameterType; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java index e0c963df8dd..f59b1486c23 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,7 +116,7 @@ public class CommonsMultipartResolverTests { } private void doTestParameters(MultipartHttpServletRequest request) { - Set parameterNames = new HashSet(); + Set parameterNames = new HashSet<>(); Enumeration parameterEnum = request.getParameterNames(); while (parameterEnum.hasMoreElements()) { parameterNames.add(parameterEnum.nextElement()); @@ -137,8 +137,8 @@ public class CommonsMultipartResolverTests { assertEquals("value4", request.getParameter("field4")); assertEquals("getValue", request.getParameter("getField")); - List parameterMapKeys = new ArrayList(); - List parameterMapValues = new ArrayList(); + List parameterMapKeys = new ArrayList<>(); + List parameterMapValues = new ArrayList<>(); for (Object o : request.getParameterMap().keySet()) { String key = (String) o; parameterMapKeys.add(key); @@ -165,7 +165,7 @@ public class CommonsMultipartResolverTests { } private void doTestFiles(MultipartHttpServletRequest request) throws IOException { - Set fileNames = new HashSet(); + Set fileNames = new HashSet<>(); Iterator fileIter = request.getFileNames(); while (fileIter.hasNext()) { fileNames.add(fileIter.next()); @@ -284,7 +284,7 @@ public class CommonsMultipartResolverTests { final MultipartFilter filter = new MultipartFilter(); filter.init(filterConfig); - final List files = new ArrayList(); + final List files = new ArrayList<>(); final FilterChain filterChain = new FilterChain() { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) { @@ -322,7 +322,7 @@ public class CommonsMultipartResolverTests { MockFilterConfig filterConfig = new MockFilterConfig(wac.getServletContext(), "filter"); filterConfig.addInitParameter("multipartResolverBeanName", "myMultipartResolver"); - final List files = new ArrayList(); + final List files = new ArrayList<>(); FilterChain filterChain = new FilterChain() { @Override public void doFilter(ServletRequest originalRequest, ServletResponse response) { @@ -377,7 +377,7 @@ public class CommonsMultipartResolverTests { if (request instanceof MultipartHttpServletRequest) { throw new IllegalStateException("Already a multipart request"); } - List fileItems = new ArrayList(); + List fileItems = new ArrayList<>(); MockFileItem fileItem1 = new MockFileItem( "field1", "type1", empty ? "" : "field1.txt", empty ? "" : "text1"); MockFileItem fileItem1x = new MockFileItem( diff --git a/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java b/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java index f0b2c1c9994..ccd0b54a1e3 100644 --- a/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,7 +92,7 @@ public class HtmlCharacterEntityReferencesTests { private Map getReferenceCharacterMap() { CharacterEntityResourceIterator entityIterator = new CharacterEntityResourceIterator(); - Map referencedCharactersMap = new HashMap(); + Map referencedCharactersMap = new HashMap<>(); while (entityIterator.hasNext()) { int character = entityIterator.getReferredCharacter(); String entityName = entityIterator.nextEntry(); diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index 6b5e40e806e..3ed08765cb0 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,7 +157,7 @@ public class UriComponentsBuilderTests { assertEquals(80, result.getPort()); assertEquals("/javase/6/docs/api/java/util/BitSet.html", result.getPath()); assertEquals("foo=bar", result.getQuery()); - MultiValueMap expectedQueryParams = new LinkedMultiValueMap(1); + MultiValueMap expectedQueryParams = new LinkedMultiValueMap<>(1); expectedQueryParams.add("foo", "bar"); assertEquals(expectedQueryParams, result.getQueryParams()); assertEquals("and(java.util.BitSet)", result.getFragment()); @@ -550,7 +550,7 @@ public class UriComponentsBuilderTests { UriComponents result = builder.queryParam("baz", "qux", 42).build(); assertEquals("baz=qux&baz=42", result.getQuery()); - MultiValueMap expectedQueryParams = new LinkedMultiValueMap(2); + MultiValueMap expectedQueryParams = new LinkedMultiValueMap<>(2); expectedQueryParams.add("baz", "qux"); expectedQueryParams.add("baz", "42"); assertEquals(expectedQueryParams, result.getQueryParams()); @@ -562,7 +562,7 @@ public class UriComponentsBuilderTests { UriComponents result = builder.queryParam("baz").build(); assertEquals("baz", result.getQuery()); - MultiValueMap expectedQueryParams = new LinkedMultiValueMap(2); + MultiValueMap expectedQueryParams = new LinkedMultiValueMap<>(2); expectedQueryParams.add("baz", null); assertEquals(expectedQueryParams, result.getQueryParams()); } @@ -587,7 +587,7 @@ public class UriComponentsBuilderTests { UriComponents result = UriComponentsBuilder.fromPath("/{foo}").buildAndExpand("fooValue"); assertEquals("/fooValue", result.toUriString()); - Map values = new HashMap(); + Map values = new HashMap<>(); values.put("foo", "fooValue"); values.put("bar", "barValue"); result = UriComponentsBuilder.fromPath("/{foo}/{bar}").buildAndExpand(values); @@ -599,7 +599,7 @@ public class UriComponentsBuilderTests { UriComponents result = UriComponentsBuilder.fromUriString("mailto:{user}@{domain}").buildAndExpand("foo", "example.com"); assertEquals("mailto:foo@example.com", result.toUriString()); - Map values = new HashMap(); + Map values = new HashMap<>(); values.put("user", "foo"); values.put("domain", "example.com"); UriComponentsBuilder.fromUriString("mailto:{user}@{domain}").buildAndExpand(values); diff --git a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java index 1ad98fd255b..be7a5b55348 100644 --- a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class WebUtilsTests { @Test public void findParameterValue() { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("myKey1", "myValue1"); params.put("myKey2_myValue2", "xxx"); params.put("myKey3_myValue3.x", "xxx"); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index b1c5274dcaf..d99214be6e4 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -571,7 +571,7 @@ public class DispatcherServlet extends FrameworkServlet { Map matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerMapping.class, true, false); if (!matchingBeans.isEmpty()) { - this.handlerMappings = new ArrayList(matchingBeans.values()); + this.handlerMappings = new ArrayList<>(matchingBeans.values()); // We keep HandlerMappings in sorted order. AnnotationAwareOrderComparator.sort(this.handlerMappings); } @@ -609,7 +609,7 @@ public class DispatcherServlet extends FrameworkServlet { Map matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, HandlerAdapter.class, true, false); if (!matchingBeans.isEmpty()) { - this.handlerAdapters = new ArrayList(matchingBeans.values()); + this.handlerAdapters = new ArrayList<>(matchingBeans.values()); // We keep HandlerAdapters in sorted order. AnnotationAwareOrderComparator.sort(this.handlerAdapters); } @@ -647,7 +647,7 @@ public class DispatcherServlet extends FrameworkServlet { Map matchingBeans = BeanFactoryUtils .beansOfTypeIncludingAncestors(context, HandlerExceptionResolver.class, true, false); if (!matchingBeans.isEmpty()) { - this.handlerExceptionResolvers = new ArrayList(matchingBeans.values()); + this.handlerExceptionResolvers = new ArrayList<>(matchingBeans.values()); // We keep HandlerExceptionResolvers in sorted order. AnnotationAwareOrderComparator.sort(this.handlerExceptionResolvers); } @@ -709,7 +709,7 @@ public class DispatcherServlet extends FrameworkServlet { Map matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(context, ViewResolver.class, true, false); if (!matchingBeans.isEmpty()) { - this.viewResolvers = new ArrayList(matchingBeans.values()); + this.viewResolvers = new ArrayList<>(matchingBeans.values()); // We keep ViewResolvers in sorted order. AnnotationAwareOrderComparator.sort(this.viewResolvers); } @@ -814,7 +814,7 @@ public class DispatcherServlet extends FrameworkServlet { String value = defaultStrategies.getProperty(key); if (value != null) { String[] classNames = StringUtils.commaDelimitedListToStringArray(value); - List strategies = new ArrayList(classNames.length); + List strategies = new ArrayList<>(classNames.length); for (String className : classNames) { try { Class clazz = ClassUtils.forName(className, DispatcherServlet.class.getClassLoader()); @@ -835,7 +835,7 @@ public class DispatcherServlet extends FrameworkServlet { return strategies; } else { - return new LinkedList(); + return new LinkedList<>(); } } @@ -870,7 +870,7 @@ public class DispatcherServlet extends FrameworkServlet { // to be able to restore the original attributes after the include. Map attributesSnapshot = null; if (WebUtils.isIncludeRequest(request)) { - attributesSnapshot = new HashMap(); + attributesSnapshot = new HashMap<>(); Enumeration attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); @@ -1319,7 +1319,7 @@ public class DispatcherServlet extends FrameworkServlet { private void restoreAttributesAfterInclude(HttpServletRequest request, Map attributesSnapshot) { // Need to copy into separate Collection here, to avoid side effects // on the Enumeration when removing attributes. - Set attrsToCheck = new HashSet(); + Set attrsToCheck = new HashSet<>(); Enumeration attrNames = request.getAttributeNames(); while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java index cc752af734a..df35f702d62 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public final class FlashMap extends HashMap implements Comparabl private String targetRequestPath; - private final MultiValueMap targetRequestParams = new LinkedMultiValueMap(4); + private final MultiValueMap targetRequestParams = new LinkedMultiValueMap<>(4); private long expirationTime = -1; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java index 69366940aa9..04b15a81835 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java @@ -179,7 +179,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic /** Actual ApplicationContextInitializer instances to apply to the context */ private final List> contextInitializers = - new ArrayList>(); + new ArrayList<>(); /** Comma-delimited ApplicationContextInitializer class names set through init param */ private String contextInitializerClasses; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerExecutionChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerExecutionChain.java index 6fab48f2027..073d55d6768 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerExecutionChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerExecutionChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public class HandlerExecutionChain { if (handler instanceof HandlerExecutionChain) { HandlerExecutionChain originalChain = (HandlerExecutionChain) handler; this.handler = originalChain.getHandler(); - this.interceptorList = new ArrayList(); + this.interceptorList = new ArrayList<>(); CollectionUtils.mergeArrayIntoCollection(originalChain.getInterceptors(), this.interceptorList); CollectionUtils.mergeArrayIntoCollection(interceptors, this.interceptorList); } @@ -98,7 +98,7 @@ public class HandlerExecutionChain { private List initInterceptorList() { if (this.interceptorList == null) { - this.interceptorList = new ArrayList(); + this.interceptorList = new ArrayList<>(); if (this.interceptors != null) { // An interceptor array specified through the constructor this.interceptorList.addAll(Arrays.asList(this.interceptors)); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/HttpServletBean.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/HttpServletBean.java index 5460207d1b3..c5f3146939b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/HttpServletBean.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/HttpServletBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ public abstract class HttpServletBean extends HttpServlet * Set of required properties (Strings) that must be supplied as * config parameters to this servlet. */ - private final Set requiredProperties = new HashSet(); + private final Set requiredProperties = new HashSet<>(); private ConfigurableEnvironment environment; @@ -232,7 +232,7 @@ public abstract class HttpServletBean extends HttpServlet throws ServletException { Set missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ? - new HashSet(requiredProperties) : null; + new HashSet<>(requiredProperties) : null; Enumeration en = config.getInitParameterNames(); while (en.hasMoreElements()) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java index dd80a15a9a9..b45a2d7e66a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java @@ -469,7 +469,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { } private ManagedList getCallableInterceptors(Element element, Object source, ParserContext parserContext) { - ManagedList interceptors = new ManagedList(); + ManagedList interceptors = new ManagedList<>(); Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support"); if (asyncElement != null) { Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "callable-interceptors"); @@ -486,7 +486,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { } private ManagedList getDeferredResultInterceptors(Element element, Object source, ParserContext parserContext) { - ManagedList interceptors = new ManagedList(); + ManagedList interceptors = new ManagedList<>(); Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support"); if (asyncElement != null) { Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "deferred-result-interceptors"); @@ -512,7 +512,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { } private ManagedList wrapLegacyResolvers(List list, ParserContext context) { - ManagedList result = new ManagedList(); + ManagedList result = new ManagedList<>(); for (Object object : list) { if (object instanceof BeanDefinitionHolder) { BeanDefinitionHolder beanDef = (BeanDefinitionHolder) object; @@ -537,7 +537,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { private ManagedList getMessageConverters(Element element, Object source, ParserContext parserContext) { Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters"); - ManagedList messageConverters = new ManagedList(); + ManagedList messageConverters = new ManagedList<>(); if (convertersElement != null) { messageConverters.setSource(source); for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) { @@ -604,7 +604,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { private ManagedList extractBeanSubElements(Element parentElement, ParserContext parserContext) { - ManagedList list = new ManagedList(); + ManagedList list = new ManagedList<>(); list.setSource(parserContext.extractSource(parentElement)); for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) { Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null); @@ -614,7 +614,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { } private ManagedList extractBeanRefSubElements(Element parentElement, ParserContext parserContext){ - ManagedList list = new ManagedList(); + ManagedList list = new ManagedList<>(); list.setSource(parserContext.extractSource(parentElement)); for (Element refElement : DomUtils.getChildElementsByTagName(parentElement, "ref")) { BeanReference reference; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/CorsBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/CorsBeanDefinitionParser.java index c62f70dcdf4..af0c7068abc 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/CorsBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/CorsBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class CorsBeanDefinitionParser implements BeanDefinitionParser { @Override public BeanDefinition parse(Element element, ParserContext parserContext) { - Map corsConfigurations = new LinkedHashMap(); + Map corsConfigurations = new LinkedHashMap<>(); List mappings = DomUtils.getChildElementsByTagName(element, "mapping"); if (mappings.isEmpty()) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/DefaultServletHandlerBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/DefaultServletHandlerBeanDefinitionParser.java index 42f1dca52d5..4851b9dd1dd 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/DefaultServletHandlerBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/DefaultServletHandlerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ class DefaultServletHandlerBeanDefinitionParser implements BeanDefinitionParser parserContext.getRegistry().registerBeanDefinition(defaultServletHandlerName, defaultServletHandlerDef); parserContext.registerComponent(new BeanComponentDefinition(defaultServletHandlerDef, defaultServletHandlerName)); - Map urlMap = new ManagedMap(); + Map urlMap = new ManagedMap<>(); urlMap.put("/**", defaultServletHandlerName); RootBeanDefinition handlerMappingDef = new RootBeanDefinition(SimpleUrlHandlerMapping.class); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/FreeMarkerConfigurerBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/FreeMarkerConfigurerBeanDefinitionParser.java index 7ceec049bdd..643b8ab0c7c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/FreeMarkerConfigurerBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/FreeMarkerConfigurerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class FreeMarkerConfigurerBeanDefinitionParser extends AbstractSingleBean protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List childElements = DomUtils.getChildElementsByTagName(element, "template-loader-path"); if (!childElements.isEmpty()) { - List locations = new ArrayList(childElements.size()); + List locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java index e6dee9825bd..7c631e50e89 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/InterceptorsBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ class InterceptorsBeanDefinitionParser implements BeanDefinitionParser { private ManagedList getIncludePatterns(Element interceptor, String elementName) { List paths = DomUtils.getChildElementsByTagName(interceptor, elementName); - ManagedList patterns = new ManagedList(paths.size()); + ManagedList patterns = new ManagedList<>(paths.size()); for (Element path : paths) { patterns.add(path.getAttribute("path")); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java index e8059186a06..0f40ad90b08 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java @@ -96,7 +96,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { return null; } - Map urlMap = new ManagedMap(); + Map urlMap = new ManagedMap<>(); String resourceRequestPath = element.getAttribute("mapping"); if (!StringUtils.hasText(resourceRequestPath)) { parserContext.getReaderContext().error("The 'mapping' attribute is required.", parserContext.extractSource(element)); @@ -160,7 +160,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { return null; } - ManagedList locations = new ManagedList(); + ManagedList locations = new ManagedList<>(); locations.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(locationAttr))); RootBeanDefinition resourceHandlerDef = new RootBeanDefinition(ResourceHttpRequestHandler.class); @@ -204,9 +204,9 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { String autoRegistration = element.getAttribute("auto-registration"); boolean isAutoRegistration = !(StringUtils.hasText(autoRegistration) && "false".equals(autoRegistration)); - ManagedList resourceResolvers = new ManagedList(); + ManagedList resourceResolvers = new ManagedList<>(); resourceResolvers.setSource(source); - ManagedList resourceTransformers = new ManagedList(); + ManagedList resourceTransformers = new ManagedList<>(); resourceTransformers.setSource(source); parseResourceCache(resourceResolvers, resourceTransformers, element, source); @@ -348,7 +348,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { } private RootBeanDefinition parseVersionResolver(ParserContext parserContext, Element element, Object source) { - ManagedMap strategyMap = new ManagedMap(); + ManagedMap strategyMap = new ManagedMap<>(); strategyMap.setSource(source); RootBeanDefinition versionResolverDef = new RootBeanDefinition(VersionResourceResolver.class); versionResolverDef.setSource(source); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ScriptTemplateConfigurerBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ScriptTemplateConfigurerBeanDefinitionParser.java index 13a71ac1e5d..b195a6df946 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ScriptTemplateConfigurerBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ScriptTemplateConfigurerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class ScriptTemplateConfigurerBeanDefinitionParser extends AbstractSimple protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List childElements = DomUtils.getChildElementsByTagName(element, "script"); if (!childElements.isEmpty()) { - List locations = new ArrayList(childElements.size()); + List locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/TilesConfigurerBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/TilesConfigurerBeanDefinitionParser.java index 3b6079930a4..cfdd51ae950 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/TilesConfigurerBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/TilesConfigurerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class TilesConfigurerBeanDefinitionParser extends AbstractSingleBeanDefin protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { List childElements = DomUtils.getChildElementsByTagName(element, "definitions"); if (!childElements.isEmpty()) { - List locations = new ArrayList(childElements.size()); + List locations = new ArrayList<>(childElements.size()); for (Element childElement : childElements) { locations.add(childElement.getAttribute("location")); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java index 06d61dc1c04..81955c9bbbd 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,7 +105,7 @@ class ViewControllerBeanDefinitionParser implements BeanDefinitionParser { urlMap = (Map) hm.getPropertyValues().getPropertyValue("urlMap").getValue(); } else { - urlMap = new ManagedMap(); + urlMap = new ManagedMap<>(); hm.getPropertyValues().add("urlMap", urlMap); } urlMap.put(element.getAttribute("path"), controller); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java index c31a7ca85ac..8390c11677d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewResolversBeanDefinitionParser.java @@ -70,7 +70,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { Object source = context.extractSource(element); context.pushContainingComponent(new CompositeComponentDefinition(element.getTagName(), source)); - ManagedList resolvers = new ManagedList(4); + ManagedList resolvers = new ManagedList<>(4); resolvers.setSource(context.extractSource(element)); String[] names = new String[] {"jsp", "tiles", "bean-name", "freemarker", "groovy", "script-template", "bean", "ref"}; @@ -130,7 +130,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { else if (contentnNegotiationElements.size() == 1) { BeanDefinition beanDef = createContentNegotiatingViewResolver(contentnNegotiationElements.get(0), context); beanDef.getPropertyValues().add("viewResolvers", resolvers); - ManagedList list = new ManagedList(1); + ManagedList list = new ManagedList<>(1); list.add(beanDef); compositeResolverBeanDef.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE); compositeResolverBeanDef.getPropertyValues().add("viewResolvers", list); @@ -175,7 +175,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser { List elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"}); if (!elements.isEmpty()) { - ManagedList list = new ManagedList(); + ManagedList list = new ManagedList<>(); for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) { list.add(context.getDelegate().parsePropertySubElement(element, null)); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java index 8a164b574c4..3955a9672a6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/AsyncSupportConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,10 +41,10 @@ public class AsyncSupportConfigurer { private Long timeout; private final List callableInterceptors = - new ArrayList(); + new ArrayList<>(); private final List deferredResultInterceptors = - new ArrayList(); + new ArrayList<>(); /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java index c22dda7312d..68d0f053fd7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ public class ContentNegotiationConfigurer { private final ContentNegotiationManagerFactoryBean factory = new ContentNegotiationManagerFactoryBean(); - private final Map mediaTypes = new HashMap(); + private final Map mediaTypes = new HashMap<>(); /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistration.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistration.java index 75d315b567f..41a3ae56bc5 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistration.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,22 +59,22 @@ public class CorsRegistration { } public CorsRegistration allowedOrigins(String... origins) { - this.config.setAllowedOrigins(new ArrayList(Arrays.asList(origins))); + this.config.setAllowedOrigins(new ArrayList<>(Arrays.asList(origins))); return this; } public CorsRegistration allowedMethods(String... methods) { - this.config.setAllowedMethods(new ArrayList(Arrays.asList(methods))); + this.config.setAllowedMethods(new ArrayList<>(Arrays.asList(methods))); return this; } public CorsRegistration allowedHeaders(String... headers) { - this.config.setAllowedHeaders(new ArrayList(Arrays.asList(headers))); + this.config.setAllowedHeaders(new ArrayList<>(Arrays.asList(headers))); return this; } public CorsRegistration exposedHeaders(String... headers) { - this.config.setExposedHeaders(new ArrayList(Arrays.asList(headers))); + this.config.setExposedHeaders(new ArrayList<>(Arrays.asList(headers))); return this; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java index 3f4e334effc..366d3a4e05b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/CorsRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.web.cors.CorsConfiguration; */ public class CorsRegistry { - private final List registrations = new ArrayList(); + private final List registrations = new ArrayList<>(); /** @@ -53,7 +53,7 @@ public class CorsRegistry { } protected Map getCorsConfigurations() { - Map configs = new LinkedHashMap(this.registrations.size()); + Map configs = new LinkedHashMap<>(this.registrations.size()); for (CorsRegistration registration : this.registrations) { configs.put(registration.getPathPattern(), registration.getCorsConfiguration()); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurer.java index 76db94f9700..c1e617836e5 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class DefaultServletHandlerConfigurer { return null; } - Map urlMap = new HashMap(); + Map urlMap = new HashMap<>(); urlMap.put("/**", handler); SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistration.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistration.java index 025eef884d3..cd856ada9ae 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistration.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,9 +37,9 @@ public class InterceptorRegistration { private final HandlerInterceptor interceptor; - private final List includePatterns = new ArrayList(); + private final List includePatterns = new ArrayList<>(); - private final List excludePatterns = new ArrayList(); + private final List excludePatterns = new ArrayList<>(); private PathMatcher pathMatcher; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistry.java index 5e2f45eecf6..e1611f625b7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/InterceptorRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapt */ public class InterceptorRegistry { - private final List registrations = new ArrayList(); + private final List registrations = new ArrayList<>(); /** * Adds the provided {@link HandlerInterceptor}. @@ -64,7 +64,7 @@ public class InterceptorRegistry { * Returns all registered interceptors. */ protected List getInterceptors() { - List interceptors = new ArrayList(); + List interceptors = new ArrayList<>(); for (InterceptorRegistration registration : registrations) { interceptors.add(registration.getInterceptor()); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceChainRegistration.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceChainRegistration.java index 93a21b89388..507145c2685 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceChainRegistration.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceChainRegistration.java @@ -46,9 +46,9 @@ public class ResourceChainRegistration { "org.webjars.WebJarAssetLocator", ResourceChainRegistration.class.getClassLoader()); - private final List resolvers = new ArrayList(4); + private final List resolvers = new ArrayList<>(4); - private final List transformers = new ArrayList(4); + private final List transformers = new ArrayList<>(4); private boolean hasVersionResolver; @@ -108,7 +108,7 @@ public class ResourceChainRegistration { protected List getResourceResolvers() { if (!this.hasPathResolver) { - List result = new ArrayList(this.resolvers); + List result = new ArrayList<>(this.resolvers); if (isWebJarsAssetLocatorPresent && !this.hasWebjarsResolver) { result.add(new WebJarsResourceResolver()); } @@ -120,7 +120,7 @@ public class ResourceChainRegistration { protected List getResourceTransformers() { if (this.hasVersionResolver && !this.hasCssLinkTransformer) { - List result = new ArrayList(this.transformers); + List result = new ArrayList<>(this.transformers); boolean hasTransformers = !this.transformers.isEmpty(); boolean hasCaching = hasTransformers && this.transformers.get(0) instanceof CachingResourceTransformer; result.add(hasCaching ? 1 : 0, new CssLinkResourceTransformer()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistration.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistration.java index 54c15642966..9ef04fce48f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistration.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public class ResourceHandlerRegistration { private final String[] pathPatterns; - private final List locations = new ArrayList(); + private final List locations = new ArrayList<>(); private Integer cachePeriod; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java index a4c7c02a0c4..e0936638826 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public class ResourceHandlerRegistry { private final ContentNegotiationManager contentNegotiationManager; - private final List registrations = new ArrayList(); + private final List registrations = new ArrayList<>(); private int order = Integer.MAX_VALUE -1; @@ -116,7 +116,7 @@ public class ResourceHandlerRegistry { return null; } - Map urlMap = new LinkedHashMap(); + Map urlMap = new LinkedHashMap<>(); for (ResourceHandlerRegistration registration : this.registrations) { for (String pathPattern : registration.getPathPatterns()) { ResourceHttpRequestHandler handler = registration.getRequestHandler(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java index 3a2de78a4de..25b9311eac4 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,10 +36,10 @@ import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; */ public class ViewControllerRegistry { - private final List registrations = new ArrayList(4); + private final List registrations = new ArrayList<>(4); private final List redirectRegistrations = - new ArrayList(10); + new ArrayList<>(10); private int order = 1; @@ -106,7 +106,7 @@ public class ViewControllerRegistry { if (this.registrations.isEmpty() && this.redirectRegistrations.isEmpty()) { return null; } - Map urlMap = new LinkedHashMap(); + Map urlMap = new LinkedHashMap<>(); for (ViewControllerRegistration registration : this.registrations) { urlMap.put(registration.getUrlPath(), registration.getViewController()); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistry.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistry.java index 946ef655395..71ca63442ba 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistry.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class ViewResolverRegistry { private ContentNegotiatingViewResolver contentNegotiatingResolver; - private final List viewResolvers = new ArrayList(4); + private final List viewResolvers = new ArrayList<>(4); private Integer order; @@ -113,7 +113,7 @@ public class ViewResolverRegistry { if (this.contentNegotiatingResolver != null) { if (!ObjectUtils.isEmpty(defaultViews)) { if (!CollectionUtils.isEmpty(this.contentNegotiatingResolver.getDefaultViews())) { - List views = new ArrayList(this.contentNegotiatingResolver.getDefaultViews()); + List views = new ArrayList<>(this.contentNegotiatingResolver.getDefaultViews()); views.addAll(Arrays.asList(defaultViews)); this.contentNegotiatingResolver.setDefaultViews(views); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 3a114972154..f58e5bdcdd6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -339,7 +339,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv } protected Map getDefaultMediaTypes() { - Map map = new HashMap(); + Map map = new HashMap<>(); if (romePresent) { map.put("atom", MediaType.APPLICATION_ATOM_XML); map.put("rss", MediaType.valueOf("application/rss+xml")); @@ -487,11 +487,11 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv adapter.setCustomReturnValueHandlers(getReturnValueHandlers()); if (jackson2Present) { - List requestBodyAdvices = new ArrayList(); + List requestBodyAdvices = new ArrayList<>(); requestBodyAdvices.add(new JsonViewRequestBodyAdvice()); adapter.setRequestBodyAdvice(requestBodyAdvices); - List> responseBodyAdvices = new ArrayList>(); + List> responseBodyAdvices = new ArrayList<>(); responseBodyAdvices.add(new JsonViewResponseBodyAdvice()); adapter.setResponseBodyAdvice(responseBodyAdvices); } @@ -632,7 +632,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv */ protected final List getArgumentResolvers() { if (this.argumentResolvers == null) { - this.argumentResolvers = new ArrayList(); + this.argumentResolvers = new ArrayList<>(); addArgumentResolvers(this.argumentResolvers); } return this.argumentResolvers; @@ -660,7 +660,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv */ protected final List getReturnValueHandlers() { if (this.returnValueHandlers == null) { - this.returnValueHandlers = new ArrayList(); + this.returnValueHandlers = new ArrayList<>(); addReturnValueHandlers(this.returnValueHandlers); } return this.returnValueHandlers; @@ -691,7 +691,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv */ protected final List> getMessageConverters() { if (this.messageConverters == null) { - this.messageConverters = new ArrayList>(); + this.messageConverters = new ArrayList<>(); configureMessageConverters(this.messageConverters); if (this.messageConverters.isEmpty()) { addDefaultHttpMessageConverters(this.messageConverters); @@ -737,7 +737,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv messageConverters.add(new ByteArrayHttpMessageConverter()); messageConverters.add(stringConverter); messageConverters.add(new ResourceHttpMessageConverter()); - messageConverters.add(new SourceHttpMessageConverter()); + messageConverters.add(new SourceHttpMessageConverter<>()); messageConverters.add(new AllEncompassingFormHttpMessageConverter()); if (romePresent) { @@ -815,7 +815,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv */ @Bean public HandlerExceptionResolver handlerExceptionResolver() { - List exceptionResolvers = new ArrayList(); + List exceptionResolvers = new ArrayList<>(); configureHandlerExceptionResolvers(exceptionResolvers); if (exceptionResolvers.isEmpty()) { @@ -871,7 +871,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv exceptionHandlerResolver.setCustomArgumentResolvers(getArgumentResolvers()); exceptionHandlerResolver.setCustomReturnValueHandlers(getReturnValueHandlers()); if (jackson2Present) { - List> interceptors = new ArrayList>(); + List> interceptors = new ArrayList<>(); interceptors.add(new JsonViewResponseBodyAdvice()); exceptionHandlerResolver.setResponseBodyAdvice(interceptors); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurerComposite.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurerComposite.java index 1b6d6e53cb7..8c8a4ae3782 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurerComposite.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurerComposite.java @@ -35,7 +35,7 @@ import org.springframework.web.servlet.HandlerExceptionResolver; */ class WebMvcConfigurerComposite implements WebMvcConfigurer { - private final List delegates = new ArrayList(); + private final List delegates = new ArrayList<>(); public void addWebMvcConfigurers(List configurers) { if (configurers != null) { @@ -150,7 +150,7 @@ class WebMvcConfigurerComposite implements WebMvcConfigurer { @Override public Validator getValidator() { - List candidates = new ArrayList(); + List candidates = new ArrayList<>(); for (WebMvcConfigurer configurer : this.delegates) { Validator validator = configurer.getValidator(); if (validator != null) { @@ -182,7 +182,7 @@ class WebMvcConfigurerComposite implements WebMvcConfigurer { @Override public MessageCodesResolver getMessageCodesResolver() { - List candidates = new ArrayList(); + List candidates = new ArrayList<>(); for (WebMvcConfigurer configurer : this.delegates) { MessageCodesResolver messageCodesResolver = configurer.getMessageCodesResolver(); if (messageCodesResolver != null) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java index 1af14127152..98b7a440926 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,9 +75,9 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport private PathMatcher pathMatcher = new AntPathMatcher(); - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); - private final List adaptedInterceptors = new ArrayList(); + private final List adaptedInterceptors = new ArrayList<>(); private CorsProcessor corsProcessor = new DefaultCorsProcessor(); @@ -329,7 +329,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport * @return the array of {@link MappedInterceptor}s, or {@code null} if none */ protected final MappedInterceptor[] getMappedInterceptors() { - List mappedInterceptors = new ArrayList(); + List mappedInterceptors = new ArrayList<>(); for (HandlerInterceptor interceptor : this.adaptedInterceptors) { if (interceptor instanceof MappedInterceptor) { mappedInterceptors.add((MappedInterceptor) interceptor); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index 266cdfb78ea..d9a19657b2f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -468,17 +468,17 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap */ class MappingRegistry { - private final Map> registry = new HashMap>(); + private final Map> registry = new HashMap<>(); - private final Map mappingLookup = new LinkedHashMap(); + private final Map mappingLookup = new LinkedHashMap<>(); - private final MultiValueMap urlLookup = new LinkedMultiValueMap(); + private final MultiValueMap urlLookup = new LinkedMultiValueMap<>(); private final Map> nameLookup = - new ConcurrentHashMap>(); + new ConcurrentHashMap<>(); private final Map corsLookup = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock(); @@ -554,7 +554,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap this.corsLookup.put(handlerMethod, corsConfig); } - this.registry.put(mapping, new MappingRegistration(mapping, handlerMethod, directUrls, name)); + this.registry.put(mapping, new MappingRegistration<>(mapping, handlerMethod, directUrls, name)); } finally { this.readWriteLock.writeLock().unlock(); @@ -572,7 +572,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap } private List getDirectUrls(T mapping) { - List urls = new ArrayList(1); + List urls = new ArrayList<>(1); for (String path : getMappingPathPatterns(mapping)) { if (!getPathMatcher().isPattern(path)) { urls.add(path); @@ -597,7 +597,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap logger.trace("Mapping name '" + name + "'"); } - List newList = new ArrayList(oldList.size() + 1); + List newList = new ArrayList<>(oldList.size() + 1); newList.addAll(oldList); newList.add(handlerMethod); this.nameLookup.put(name, newList); @@ -653,7 +653,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap this.nameLookup.remove(name); return; } - List newList = new ArrayList(oldList.size() - 1); + List newList = new ArrayList<>(oldList.size() - 1); for (HandlerMethod current : oldList) { if (!current.equals(handlerMethod)) { newList.add(current); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java index 51bed445cf2..71b82a74181 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java @@ -57,7 +57,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i private boolean lazyInitHandlers = false; - private final Map handlerMap = new LinkedHashMap(); + private final Map handlerMap = new LinkedHashMap<>(); /** @@ -171,7 +171,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i return buildPathExposingHandler(handler, urlPath, urlPath, null); } // Pattern match? - List matchingPatterns = new ArrayList(); + List matchingPatterns = new ArrayList<>(); for (String registeredPattern : this.handlerMap.keySet()) { if (getPathMatcher().match(registeredPattern, urlPath)) { matchingPatterns.add(registeredPattern); @@ -207,7 +207,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i // There might be multiple 'best patterns', let's make sure we have the correct URI template variables // for all of them - Map uriTemplateVariables = new LinkedHashMap(); + Map uriTemplateVariables = new LinkedHashMap<>(); for (String matchingPattern : matchingPatterns) { if (patternComparator.compare(bestPatternMatch, matchingPattern) == 0) { Map vars = getPathMatcher().extractUriTemplateVariables(matchingPattern, urlPath); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java index e6e6033a2d0..f02c1429218 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMapping.java @@ -55,7 +55,7 @@ public class BeanNameUrlHandlerMapping extends AbstractDetectingUrlHandlerMappin */ @Override protected String[] determineUrlsForHandler(String beanName) { - List urls = new ArrayList(); + List urls = new ArrayList<>(); if (beanName.startsWith("/")) { urls.add(beanName); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java index 1c7fa9b6b38..21a815ab64e 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerMappingIntrospector.java @@ -73,7 +73,7 @@ public class HandlerMappingIntrospector implements CorsConfigurationSource { Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors( context, HandlerMapping.class, true, false); if (!beans.isEmpty()) { - List mappings = new ArrayList(beans.values()); + List mappings = new ArrayList<>(beans.values()); AnnotationAwareOrderComparator.sort(mappings); return mappings; } @@ -93,7 +93,7 @@ public class HandlerMappingIntrospector implements CorsConfigurationSource { String value = props.getProperty(HandlerMapping.class.getName()); String[] names = StringUtils.commaDelimitedListToStringArray(value); - List result = new ArrayList(names.length); + List result = new ArrayList<>(names.length); for (String name : names) { try { Class clazz = ClassUtils.forName(name, DispatcherServlet.class.getClassLoader()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java index b24363f10b3..17d764b91e7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso private Integer defaultStatusCode; - private Map statusCodes = new HashMap(); + private Map statusCodes = new HashMap<>(); private String exceptionAttribute = DEFAULT_EXCEPTION_ATTRIBUTE; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.java index 16a333c2435..4589470aee5 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ import org.springframework.util.CollectionUtils; */ public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping { - private final Map urlMap = new LinkedHashMap(); + private final Map urlMap = new LinkedHashMap<>(); /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java index c8bfa23cf65..cb2cf44b12c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java @@ -40,7 +40,7 @@ import org.springframework.web.servlet.LocaleResolver; */ public class AcceptHeaderLocaleResolver implements LocaleResolver { - private final List supportedLocales = new ArrayList(4); + private final List supportedLocales = new ArrayList<>(4); private Locale defaultLocale; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java index d244bf543d1..6fee8be2e41 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/UrlFilenameViewController.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class UrlFilenameViewController extends AbstractUrlViewController { private String suffix = ""; /** Request URL path String --> view name String */ - private final Map viewNameCache = new ConcurrentHashMap(256); + private final Map viewNameCache = new ConcurrentHashMap<>(256); /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java index 038667f4b67..7eb293d6bf8 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,9 +55,9 @@ public class WebContentInterceptor extends WebContentGenerator implements Handle private PathMatcher pathMatcher = new AntPathMatcher(); - private Map cacheMappings = new HashMap(); + private Map cacheMappings = new HashMap<>(); - private Map cacheControlMappings = new HashMap(); + private Map cacheControlMappings = new HashMap<>(); public WebContentInterceptor() { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.java index 221a9cda4eb..97949e21677 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ public class CompositeRequestCondition extends AbstractRequestCondition> unwrap() { - List> result = new ArrayList>(); + List> result = new ArrayList<>(); for (RequestConditionHolder holder : this.requestConditions) { result.add(holder.getCondition()); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java index e7a6af41e58..d87ac50c8c6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestCondition.java @@ -80,13 +80,13 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition expressions) { - this.expressions = new ArrayList(expressions); + this.expressions = new ArrayList<>(expressions); Collections.sort(this.expressions); } private static Set parseExpressions(String[] consumes, String[] headers) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); if (headers != null) { for (String header : headers) { HeaderExpression expr = new HeaderExpression(header); @@ -110,14 +110,14 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition getExpressions() { - return new LinkedHashSet(this.expressions); + return new LinkedHashSet<>(this.expressions); } /** * Returns the media types for this condition excluding negated expressions. */ public Set getConsumableMediaTypes() { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (ConsumeMediaTypeExpression expression : this.expressions) { if (!expression.isNegated()) { result.add(expression.getMediaType()); @@ -180,7 +180,7 @@ public final class ConsumesRequestCondition extends AbstractRequestCondition result = new LinkedHashSet(this.expressions); + Set result = new LinkedHashSet<>(this.expressions); for (Iterator iterator = result.iterator(); iterator.hasNext();) { ConsumeMediaTypeExpression expression = iterator.next(); if (!expression.match(contentType)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/HeadersRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/HeadersRequestCondition.java index aaa0847c7a0..0958d1767be 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/HeadersRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/HeadersRequestCondition.java @@ -57,12 +57,12 @@ public final class HeadersRequestCondition extends AbstractRequestCondition conditions) { - this.expressions = Collections.unmodifiableSet(new LinkedHashSet(conditions)); + this.expressions = Collections.unmodifiableSet(new LinkedHashSet<>(conditions)); } private static Collection parseExpressions(String... headers) { - Set expressions = new LinkedHashSet(); + Set expressions = new LinkedHashSet<>(); if (headers != null) { for (String header : headers) { HeaderExpression expr = new HeaderExpression(header); @@ -79,7 +79,7 @@ public final class HeadersRequestCondition extends AbstractRequestCondition> getExpressions() { - return new LinkedHashSet>(this.expressions); + return new LinkedHashSet<>(this.expressions); } @Override @@ -98,7 +98,7 @@ public final class HeadersRequestCondition extends AbstractRequestCondition set = new LinkedHashSet(this.expressions); + Set set = new LinkedHashSet<>(this.expressions); set.addAll(other.expressions); return new HeadersRequestCondition(set); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java index 7510646204e..84952a729a7 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ParamsRequestCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,12 +48,12 @@ public final class ParamsRequestCondition extends AbstractRequestCondition conditions) { - this.expressions = Collections.unmodifiableSet(new LinkedHashSet(conditions)); + this.expressions = Collections.unmodifiableSet(new LinkedHashSet<>(conditions)); } private static Collection parseExpressions(String... params) { - Set expressions = new LinkedHashSet(); + Set expressions = new LinkedHashSet<>(); if (params != null) { for (String param : params) { expressions.add(new ParamExpression(param)); @@ -67,7 +67,7 @@ public final class ParamsRequestCondition extends AbstractRequestCondition> getExpressions() { - return new LinkedHashSet>(this.expressions); + return new LinkedHashSet<>(this.expressions); } @Override @@ -86,7 +86,7 @@ public final class ParamsRequestCondition extends AbstractRequestCondition set = new LinkedHashSet(this.expressions); + Set set = new LinkedHashSet<>(this.expressions); set.addAll(other.expressions); return new ParamsRequestCondition(set); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java index 43f5b496149..43d14fd453a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition fileExtensions = new ArrayList(); + private final List fileExtensions = new ArrayList<>(); /** @@ -126,7 +126,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition result = new LinkedHashSet(patterns.size()); + Set result = new LinkedHashSet<>(patterns.size()); for (String pattern : patterns) { if (StringUtils.hasLength(pattern) && !pattern.startsWith("/")) { pattern = "/" + pattern; @@ -162,7 +162,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); if (!this.patterns.isEmpty() && !other.patterns.isEmpty()) { for (String pattern1 : this.patterns) { for (String pattern2 : other.patterns) { @@ -224,7 +224,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition getMatchingPatterns(String lookupPath) { - List matches = new ArrayList(); + List matches = new ArrayList<>(); for (String pattern : this.patterns) { String match = getMatchingPattern(pattern, lookupPath); if (match != null) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java index 55931d4bfd0..5e6545fb14b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/ProducesRequestCondition.java @@ -89,7 +89,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition(parseExpressions(produces, headers)); + this.expressions = new ArrayList<>(parseExpressions(produces, headers)); Collections.sort(this.expressions); this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager()); } @@ -98,14 +98,14 @@ public final class ProducesRequestCondition extends AbstractRequestCondition expressions, ContentNegotiationManager manager) { - this.expressions = new ArrayList(expressions); + this.expressions = new ArrayList<>(expressions); Collections.sort(this.expressions); this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager()); } private Set parseExpressions(String[] produces, String[] headers) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); if (headers != null) { for (String header : headers) { HeaderExpression expr = new HeaderExpression(header); @@ -128,14 +128,14 @@ public final class ProducesRequestCondition extends AbstractRequestCondition getExpressions() { - return new LinkedHashSet(this.expressions); + return new LinkedHashSet<>(this.expressions); } /** * Return the contained producible media types excluding negated expressions. */ public Set getProducibleMediaTypes() { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (ProduceMediaTypeExpression expression : this.expressions) { if (!expression.isNegated()) { result.add(expression.getMediaType()); @@ -196,7 +196,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition result = new LinkedHashSet(expressions); + Set result = new LinkedHashSet<>(expressions); for (Iterator iterator = result.iterator(); iterator.hasNext();) { ProduceMediaTypeExpression expression = iterator.next(); if (!expression.match(acceptedMediaTypes)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java index b044ae5b42d..c26b5576170 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestCondition.java @@ -57,7 +57,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi } private RequestMethodsRequestCondition(Collection requestMethods) { - this.methods = Collections.unmodifiableSet(new LinkedHashSet(requestMethods)); + this.methods = Collections.unmodifiableSet(new LinkedHashSet<>(requestMethods)); } @@ -89,7 +89,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi */ @Override public RequestMethodsRequestCondition combine(RequestMethodsRequestCondition other) { - Set set = new LinkedHashSet(this.methods); + Set set = new LinkedHashSet<>(this.methods); set.addAll(other.methods); return new RequestMethodsRequestCondition(set); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java index df3a198f863..c404e7fbe7c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMapping.java @@ -154,7 +154,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe private Map> extractMatrixVariables( HttpServletRequest request, Map uriVariables) { - Map> result = new LinkedHashMap>(); + Map> result = new LinkedHashMap<>(); for (Entry uriVar : uriVariables.entrySet()) { String uriVarValue = uriVar.getValue(); @@ -219,12 +219,12 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe throw new HttpMediaTypeNotSupportedException(ex.getMessage()); } } - throw new HttpMediaTypeNotSupportedException(contentType, new ArrayList(mediaTypes)); + throw new HttpMediaTypeNotSupportedException(contentType, new ArrayList<>(mediaTypes)); } if (helper.hasProducesMismatch()) { Set mediaTypes = helper.getProducibleMediaTypes(); - throw new HttpMediaTypeNotAcceptableException(new ArrayList(mediaTypes)); + throw new HttpMediaTypeNotAcceptableException(new ArrayList<>(mediaTypes)); } if (helper.hasParamsMismatch()) { @@ -241,7 +241,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe */ private static class PartialMatchHelper { - private final List partialMatches = new ArrayList(); + private final List partialMatches = new ArrayList<>(); public PartialMatchHelper(Set infos, HttpServletRequest request) { @@ -312,7 +312,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe * Return declared HTTP methods. */ public Set getAllowedMethods() { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (PartialMatch match : this.partialMatches) { for (RequestMethod method : match.getInfo().getMethodsCondition().getMethods()) { result.add(method.name()); @@ -326,7 +326,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe * match the "methods" condition. */ public Set getConsumableMediaTypes() { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (PartialMatch match : this.partialMatches) { if (match.hasMethodsMatch()) { result.addAll(match.getInfo().getConsumesCondition().getConsumableMediaTypes()); @@ -340,7 +340,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe * match the "methods" and "consumes" conditions. */ public Set getProducibleMediaTypes() { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet<>(); for (PartialMatch match : this.partialMatches) { if (match.hasConsumesMatch()) { result.addAll(match.getInfo().getProducesCondition().getProducibleMediaTypes()); @@ -354,7 +354,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe * match the "methods", "consumes", and "params" conditions. */ public List getParamConditions() { - List result = new ArrayList(); + List result = new ArrayList<>(); for (PartialMatch match : this.partialMatches) { if (match.hasProducesMatch()) { Set> set = match.getInfo().getParamsCondition().getExpressions(); @@ -441,7 +441,7 @@ public abstract class RequestMappingInfoHandlerMapping extends AbstractHandlerMe } private static Set initAllowedHttpMethods(Set declaredMethods) { - Set result = new LinkedHashSet(declaredMethods.size()); + Set result = new LinkedHashSet<>(declaredMethods.size()); if (declaredMethods.isEmpty()) { for (HttpMethod method : HttpMethod.values()) { if (!HttpMethod.TRACE.equals(method)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java index 75c78a91052..7e1287b82c2 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -104,11 +104,11 @@ public abstract class AbstractMessageConverterMethodArgumentResolver implements * by specificity via {@link MediaType#sortBySpecificity(List)}. */ private static List getAllSupportedMediaTypes(List> messageConverters) { - Set allSupportedMediaTypes = new LinkedHashSet(); + Set allSupportedMediaTypes = new LinkedHashSet<>(); for (HttpMessageConverter messageConverter : messageConverters) { allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes()); } - List result = new ArrayList(allSupportedMediaTypes); + List result = new ArrayList<>(allSupportedMediaTypes); MediaType.sortBySpecificity(result); return Collections.unmodifiableList(result); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java index c05101720e9..9f0340c5909 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java @@ -63,12 +63,12 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe implements HandlerMethodReturnValueHandler { /* Extensions associated with the built-in message converters */ - private static final Set WHITELISTED_EXTENSIONS = new HashSet(Arrays.asList( + private static final Set WHITELISTED_EXTENSIONS = new HashSet<>(Arrays.asList( "txt", "text", "yml", "properties", "csv", "json", "xml", "atom", "rss", "png", "jpe", "jpeg", "jpg", "gif", "wbmp", "bmp")); - private static final Set WHITELISTED_MEDIA_BASE_TYPES = new HashSet( + private static final Set WHITELISTED_MEDIA_BASE_TYPES = new HashSet<>( Arrays.asList("audio", "image", "video")); private static final MediaType MEDIA_TYPE_APPLICATION = new MediaType("application"); @@ -87,7 +87,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe private final PathExtensionContentNegotiationStrategy pathStrategy; - private final Set safeExtensions = new HashSet(); + private final Set safeExtensions = new HashSet<>(); @@ -188,7 +188,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe throw new IllegalArgumentException("No converter found for return value of type: " + valueType); } - Set compatibleMediaTypes = new LinkedHashSet(); + Set compatibleMediaTypes = new LinkedHashSet<>(); for (MediaType requestedType : requestedMediaTypes) { for (MediaType producibleType : producibleMediaTypes) { if (requestedType.isCompatibleWith(producibleType)) { @@ -203,7 +203,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe return; } - List mediaTypes = new ArrayList(compatibleMediaTypes); + List mediaTypes = new ArrayList<>(compatibleMediaTypes); MediaType.sortBySpecificityAndQuality(mediaTypes); MediaType selectedMediaType = null; @@ -305,10 +305,10 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe protected List getProducibleMediaTypes(HttpServletRequest request, Class valueClass, Type declaredType) { Set mediaTypes = (Set) request.getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); if (!CollectionUtils.isEmpty(mediaTypes)) { - return new ArrayList(mediaTypes); + return new ArrayList<>(mediaTypes); } else if (!this.allSupportedMediaTypes.isEmpty()) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (HttpMessageConverter converter : this.messageConverters) { if (converter instanceof GenericHttpMessageConverter && declaredType != null) { if (((GenericHttpMessageConverter) converter).canWrite(declaredType, valueClass, null)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java index b51486a8632..87ef76c8aea 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultMethodReturnValueHandler.java @@ -45,7 +45,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho public DeferredResultMethodReturnValueHandler() { - this.adapterMap = new HashMap, DeferredResultAdapter>(5); + this.adapterMap = new HashMap<>(5); this.adapterMap.put(DeferredResult.class, new SimpleDeferredResultAdapter()); this.adapterMap.put(ListenableFuture.class, new ListenableFutureAdapter()); this.adapterMap.put(CompletionStage.class, new CompletionStageAdapter()); @@ -119,7 +119,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho @Override public DeferredResult adaptToDeferredResult(Object returnValue) { Assert.isInstanceOf(ListenableFuture.class, returnValue); - final DeferredResult result = new DeferredResult(); + final DeferredResult result = new DeferredResult<>(); ((ListenableFuture) returnValue).addCallback(new ListenableFutureCallback() { @Override public void onSuccess(Object value) { @@ -143,7 +143,7 @@ public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMetho @Override public DeferredResult adaptToDeferredResult(Object returnValue) { Assert.isInstanceOf(CompletionStage.class, returnValue); - final DeferredResult result = new DeferredResult(); + final DeferredResult result = new DeferredResult<>(); @SuppressWarnings("unchecked") CompletionStage future = (CompletionStage) returnValue; future.handle(new BiFunction() { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java index 8e5547730d9..4f138e62d5f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java @@ -83,25 +83,25 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce private ContentNegotiationManager contentNegotiationManager = new ContentNegotiationManager(); - private final List responseBodyAdvice = new ArrayList(); + private final List responseBodyAdvice = new ArrayList<>(); private ApplicationContext applicationContext; private final Map, ExceptionHandlerMethodResolver> exceptionHandlerCache = - new ConcurrentHashMap, ExceptionHandlerMethodResolver>(64); + new ConcurrentHashMap<>(64); private final Map exceptionHandlerAdviceCache = - new LinkedHashMap(); + new LinkedHashMap<>(); public ExceptionHandlerExceptionResolver() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 - this.messageConverters = new ArrayList>(); + this.messageConverters = new ArrayList<>(); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); - this.messageConverters.add(new SourceHttpMessageConverter()); + this.messageConverters.add(new SourceHttpMessageConverter<>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); } @@ -293,7 +293,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce * and custom resolvers provided via {@link #setCustomArgumentResolvers}. */ protected List getDefaultArgumentResolvers() { - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); // Annotation-based argument resolution resolvers.add(new SessionAttributeMethodArgumentResolver()); @@ -317,7 +317,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce * custom handlers provided via {@link #setReturnValueHandlers}. */ protected List getDefaultReturnValueHandlers() { - List handlers = new ArrayList(); + List handlers = new ArrayList<>(); // Single-purpose return value types handlers.add(new ModelAndViewMethodReturnValueHandler()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java index 6545d4a8404..164f10537a1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java @@ -124,11 +124,11 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro Object body = readWithMessageConverters(webRequest, parameter, paramType); if (RequestEntity.class == parameter.getParameterType()) { - return new RequestEntity(body, inputMessage.getHeaders(), + return new RequestEntity<>(body, inputMessage.getHeaders(), inputMessage.getMethod(), inputMessage.getURI()); } else { - return new HttpEntity(body, inputMessage.getHeaders()); + return new HttpEntity<>(body, inputMessage.getHeaders()); } } @@ -206,7 +206,7 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro return entityHeaders.getVary(); } List entityHeadersVary = entityHeaders.getVary(); - List result = new ArrayList(entityHeadersVary); + List result = new ArrayList<>(entityHeadersVary); for (String header : responseHeaders.get(HttpHeaders.VARY)) { for (String existing : StringUtils.tokenizeToStringArray(header, ",")) { if ("*".equals(existing)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMapMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMapMethodArgumentResolver.java index 212a826902e..d245403964a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMapMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMapMethodArgumentResolver.java @@ -70,7 +70,7 @@ public class MatrixVariableMapMethodArgumentResolver implements HandlerMethodArg return Collections.emptyMap(); } - MultiValueMap map = new LinkedMultiValueMap(); + MultiValueMap map = new LinkedMultiValueMap<>(); String pathVariable = parameter.getParameterAnnotation(MatrixVariable.class).pathVar(); if (!pathVariable.equals(ValueConstants.DEFAULT_NONE)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java index 1dd9c354a15..4a9157a00fd 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariableMethodArgumentResolver.java @@ -86,7 +86,7 @@ public class MatrixVariableMethodArgumentResolver extends AbstractNamedValueMeth } else { boolean found = false; - paramValues = new ArrayList(); + paramValues = new ArrayList<>(); for (MultiValueMap params : pathParameters.values()) { if (params.containsKey(name)) { if (found) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java index 263d2bca0b6..fd56c92bee9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java @@ -472,7 +472,7 @@ public class MvcUriComponentsBuilder { " does not match number of argument values " + argCount); } - final Map uriVars = new HashMap(); + final Map uriVars = new HashMap<>(); for (int i = 0; i < paramCount; i++) { MethodParameter param = new SynthesizingMethodParameter(method, i); param.initParameterNameDiscovery(parameterNameDiscoverer); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java index 2fc6f46e5ff..810fa8cb5ed 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class PathVariableMapMethodArgumentResolver implements HandlerMethodArgum HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST); if (!CollectionUtils.isEmpty(uriTemplateVars)) { - return new LinkedHashMap(uriTemplateVars); + return new LinkedHashMap<>(uriTemplateVars); } else { return Collections.emptyMap(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java index d7b1cb522ea..12aa853c93d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolver.java @@ -111,7 +111,7 @@ public class PathVariableMethodArgumentResolver extends AbstractNamedValueMethod int scope = RequestAttributes.SCOPE_REQUEST; Map pathVars = (Map) request.getAttribute(key, scope); if (pathVars == null) { - pathVars = new HashMap(); + pathVars = new HashMap<>(); request.setAttribute(key, pathVars, scope); } pathVars.put(name, arg); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java index a48efb1b9ed..13bca3e7453 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java @@ -132,7 +132,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter private List> messageConverters; - private List requestResponseBodyAdvice = new ArrayList(); + private List requestResponseBodyAdvice = new ArrayList<>(); private WebBindingInitializer webBindingInitializer; @@ -158,27 +158,27 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter private final Map, SessionAttributesHandler> sessionAttributesHandlerCache = - new ConcurrentHashMap, SessionAttributesHandler>(64); + new ConcurrentHashMap<>(64); - private final Map, Set> initBinderCache = new ConcurrentHashMap, Set>(64); + private final Map, Set> initBinderCache = new ConcurrentHashMap<>(64); private final Map> initBinderAdviceCache = - new LinkedHashMap>(); + new LinkedHashMap<>(); - private final Map, Set> modelAttributeCache = new ConcurrentHashMap, Set>(64); + private final Map, Set> modelAttributeCache = new ConcurrentHashMap<>(64); private final Map> modelAttributeAdviceCache = - new LinkedHashMap>(); + new LinkedHashMap<>(); public RequestMappingHandlerAdapter() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 - this.messageConverters = new ArrayList>(4); + this.messageConverters = new ArrayList<>(4); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); - this.messageConverters.add(new SourceHttpMessageConverter()); + this.messageConverters.add(new SourceHttpMessageConverter<>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); } @@ -537,7 +537,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter List beans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext()); AnnotationAwareOrderComparator.sort(beans); - List requestResponseBodyAdviceBeans = new ArrayList(); + List requestResponseBodyAdviceBeans = new ArrayList<>(); for (ControllerAdviceBean bean : beans) { Set attrMethods = MethodIntrospector.selectMethods(bean.getBeanType(), MODEL_ATTRIBUTE_METHODS); @@ -578,7 +578,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter * and custom resolvers provided via {@link #setCustomArgumentResolvers}. */ private List getDefaultArgumentResolvers() { - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); // Annotation-based argument resolution resolvers.add(new RequestParamMethodArgumentResolver(getBeanFactory(), false)); @@ -625,7 +625,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter * methods including built-in and custom resolvers. */ private List getDefaultInitBinderArgumentResolvers() { - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); // Annotation-based argument resolution resolvers.add(new RequestParamMethodArgumentResolver(getBeanFactory(), false)); @@ -658,7 +658,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter * custom handlers provided via {@link #setReturnValueHandlers}. */ private List getDefaultReturnValueHandlers() { - List handlers = new ArrayList(); + List handlers = new ArrayList<>(); // Single-purpose return value types handlers.add(new ModelAndViewMethodReturnValueHandler()); @@ -854,7 +854,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter methods = MethodIntrospector.selectMethods(handlerType, MODEL_ATTRIBUTE_METHODS); this.modelAttributeCache.put(handlerType, methods); } - List attrMethods = new ArrayList(); + List attrMethods = new ArrayList<>(); // Global methods first for (Entry> entry : this.modelAttributeAdviceCache.entrySet()) { if (entry.getKey().isApplicableToBeanType(handlerType)) { @@ -886,7 +886,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter methods = MethodIntrospector.selectMethods(handlerType, INIT_BINDER_METHODS); this.initBinderCache.put(handlerType, methods); } - List initBinderMethods = new ArrayList(); + List initBinderMethods = new ArrayList<>(); // Global methods first for (Entry> entry : this.initBinderAdviceCache.entrySet()) { if (entry.getKey().isApplicableToBeanType(handlerType)) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChain.java index d41295cfa11..af9e288783c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,9 +42,9 @@ import org.springframework.web.method.ControllerAdviceBean; */ class RequestResponseBodyAdviceChain implements RequestBodyAdvice, ResponseBodyAdvice { - private final List requestBodyAdvice = new ArrayList(4); + private final List requestBodyAdvice = new ArrayList<>(4); - private final List responseBodyAdvice = new ArrayList(4); + private final List responseBodyAdvice = new ArrayList<>(4); /** @@ -158,7 +158,7 @@ class RequestResponseBodyAdviceChain implements RequestBodyAdvice, ResponseBodyA if (CollectionUtils.isEmpty(availableAdvice)) { return Collections.emptyList(); } - List result = new ArrayList(availableAdvice.size()); + List result = new ArrayList<>(availableAdvice.size()); for (Object advice : availableAdvice) { if (advice instanceof ControllerAdviceBean) { ControllerAdviceBean adviceBean = (ControllerAdviceBean) advice; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java index 18d96b07710..9c35ebe88d3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class ResponseBodyEmitter { private final Long timeout; - private final Set earlySendAttempts = new LinkedHashSet(8); + private final Set earlySendAttempts = new LinkedHashSet<>(8); private Handler handler; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java index 264ca73ce8d..a7e391c0516 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandler.java @@ -65,7 +65,7 @@ public class ResponseBodyEmitterReturnValueHandler implements AsyncHandlerMethod public ResponseBodyEmitterReturnValueHandler(List> messageConverters) { Assert.notEmpty(messageConverters, "'messageConverters' must not be empty"); this.messageConverters = messageConverters; - this.adapterMap = new HashMap, ResponseBodyEmitterAdapter>(3); + this.adapterMap = new HashMap<>(3); this.adapterMap.put(ResponseBodyEmitter.class, new SimpleResponseBodyEmitterAdapter()); } @@ -155,7 +155,7 @@ public class ResponseBodyEmitterReturnValueHandler implements AsyncHandlerMethod outputMessage.flush(); outputMessage = new StreamingServletServerHttpResponse(outputMessage); - DeferredResult deferredResult = new DeferredResult(emitter.getTimeout()); + DeferredResult deferredResult = new DeferredResult<>(emitter.getTimeout()); WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer); HttpMessageConvertingHandler handler = new HttpMessageConvertingHandler(outputMessage, deferredResult); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java index 3e6fa68fb02..5ad128f9ae5 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java @@ -196,7 +196,7 @@ public abstract class ResponseEntityExceptionHandler { if (HttpStatus.INTERNAL_SERVER_ERROR.equals(status)) { request.setAttribute(WebUtils.ERROR_EXCEPTION_ATTRIBUTE, ex, WebRequest.SCOPE_REQUEST); } - return new ResponseEntity(body, headers, status); + return new ResponseEntity<>(body, headers, status); } /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java index 72b283f06a3..608edbd27d8 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitter.java @@ -182,7 +182,7 @@ public class SseEmitter extends ResponseBodyEmitter { */ private static class SseEventBuilderImpl implements SseEventBuilder { - private final Set dataToSend = new LinkedHashSet(4); + private final Set dataToSend = new LinkedHashSet<>(4); private StringBuilder sb; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java index ba4922c27c1..aa07717842d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { private static final Log logger = LogFactory.getLog(AppCacheManifestTransformer.class); - private final Map sectionTransformers = new HashMap(); + private final Map sectionTransformers = new HashMap<>(); private final String fileExtension; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java index 4380246e843..b0fc201c19d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CssLinkResourceTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); - private final List linkParsers = new ArrayList(); + private final List linkParsers = new ArrayList<>(); public CssLinkResourceTransformer() { @@ -81,7 +81,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream()); String content = new String(bytes, DEFAULT_CHARSET); - Set infos = new HashSet(5); + Set infos = new HashSet<>(5); for (CssLinkParser parser : this.linkParsers) { parser.parseLink(content, infos); } @@ -93,7 +93,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport { return resource; } - List sortedInfos = new ArrayList(infos); + List sortedInfos = new ArrayList<>(infos); Collections.sort(sortedInfos); int index = 0; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java index 501f2371c46..354b0f08f3a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java @@ -34,7 +34,7 @@ import org.springframework.util.Assert; */ class DefaultResourceResolverChain implements ResourceResolverChain { - private final List resolvers = new ArrayList(); + private final List resolvers = new ArrayList<>(); private int index = -1; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java index 136d03009bf..7cbb46bfa11 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain { private final ResourceResolverChain resolverChain; - private final List transformers = new ArrayList(); + private final List transformers = new ArrayList<>(); private int index = -1; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java index 55b9e5dac62..26dc9a5754c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java @@ -99,11 +99,11 @@ public class ResourceHttpRequestHandler extends WebContentGenerator private static final Log logger = LogFactory.getLog(ResourceHttpRequestHandler.class); - private final List locations = new ArrayList(4); + private final List locations = new ArrayList<>(4); - private final List resourceResolvers = new ArrayList(4); + private final List resourceResolvers = new ArrayList<>(4); - private final List resourceTransformers = new ArrayList(4); + private final List resourceTransformers = new ArrayList<>(4); private ResourceHttpMessageConverter resourceHttpMessageConverter; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java index 9ee0c5a8b70..375ce974f48 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class ResourceUrlProvider implements ApplicationListener handlerMap = new LinkedHashMap(); + private final Map handlerMap = new LinkedHashMap<>(); private boolean autodetect = true; @@ -139,7 +139,7 @@ public class ResourceUrlProvider implements ApplicationListener map = appContext.getBeansOfType(SimpleUrlHandlerMapping.class); - List handlerMappings = new ArrayList(map.values()); + List handlerMappings = new ArrayList<>(map.values()); AnnotationAwareOrderComparator.sort(handlerMappings); for (SimpleUrlHandlerMapping hm : handlerMappings) { @@ -208,7 +208,7 @@ public class ResourceUrlProvider implements ApplicationListener matchingPatterns = new ArrayList(); + List matchingPatterns = new ArrayList<>(); for (String pattern : this.handlerMap.keySet()) { if (getPathMatcher().match(pattern, lookupPath)) { matchingPatterns.add(pattern); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java index f7eb7cb0144..c3c6557c347 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionResourceResolver.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -65,7 +65,7 @@ public class VersionResourceResolver extends AbstractResourceResolver { private AntPathMatcher pathMatcher = new AntPathMatcher(); /** Map from path pattern -> VersionStrategy */ - private final Map versionStrategyMap = new LinkedHashMap(); + private final Map versionStrategyMap = new LinkedHashMap<>(); /** @@ -121,7 +121,7 @@ public class VersionResourceResolver extends AbstractResourceResolver { */ public VersionResourceResolver addFixedVersionStrategy(String version, String... pathPatterns) { List patternsList = Arrays.asList(pathPatterns); - List prefixedPatterns = new ArrayList(pathPatterns.length); + List prefixedPatterns = new ArrayList<>(pathPatterns.length); String versionPrefix = "/" + version; for (String pattern : patternsList) { prefixedPatterns.add(pattern); @@ -223,7 +223,7 @@ public class VersionResourceResolver extends AbstractResourceResolver { */ protected VersionStrategy getStrategyForPath(String requestPath) { String path = "/".concat(requestPath); - List matchingPatterns = new ArrayList(); + List matchingPatterns = new ArrayList<>(); for (String pattern : this.versionStrategyMap.keySet()) { if (this.pathMatcher.match(pattern, path)) { matchingPatterns.add(pattern); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java index c859a2301a8..61f3ef92169 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractFlashMapManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager { * Return a list of expired FlashMap instances contained in the given list. */ private List getExpiredFlashMaps(List allMaps) { - List result = new LinkedList(); + List result = new LinkedList<>(); for (FlashMap map : allMaps) { if (map.isExpired()) { result.add(map); @@ -145,7 +145,7 @@ public abstract class AbstractFlashMapManager implements FlashMapManager { * @return a matching FlashMap or {@code null} */ private FlashMap getMatchingFlashMap(List allMaps, HttpServletRequest request) { - List result = new LinkedList(); + List result = new LinkedList<>(); for (FlashMap flashMap : allMaps) { if (isFlashMapForRequest(flashMap, request)) { result.add(flashMap); @@ -208,14 +208,14 @@ public abstract class AbstractFlashMapManager implements FlashMapManager { if (mutex != null) { synchronized (mutex) { List allFlashMaps = retrieveFlashMaps(request); - allFlashMaps = (allFlashMaps != null ? allFlashMaps : new CopyOnWriteArrayList()); + allFlashMaps = (allFlashMaps != null ? allFlashMaps : new CopyOnWriteArrayList<>()); allFlashMaps.add(flashMap); updateFlashMaps(allFlashMaps, request, response); } } else { List allFlashMaps = retrieveFlashMaps(request); - allFlashMaps = (allFlashMaps != null ? allFlashMaps : new LinkedList()); + allFlashMaps = (allFlashMaps != null ? allFlashMaps : new LinkedList<>()); allFlashMaps.add(flashMap); updateFlashMaps(allFlashMaps, request, response); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java index c1c9fa2e566..256ed8ce7b9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java @@ -840,7 +840,7 @@ public class RequestContext { */ public Errors getErrors(String name, boolean htmlEscape) { if (this.errorsMap == null) { - this.errorsMap = new HashMap(); + this.errorsMap = new HashMap<>(); } Errors errors = this.errorsMap.get(name); boolean put = false; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java index 099459b0a32..ce8e862f971 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/WebContentGenerator.java @@ -125,7 +125,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { */ public WebContentGenerator(boolean restrictDefaultSupportedMethods) { if (restrictDefaultSupportedMethods) { - this.supportedMethods = new LinkedHashSet(4); + this.supportedMethods = new LinkedHashSet<>(4); this.supportedMethods.add(METHOD_GET); this.supportedMethods.add(METHOD_HEAD); this.supportedMethods.add(METHOD_POST); @@ -149,7 +149,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { */ public final void setSupportedMethods(String... methods) { if (!ObjectUtils.isEmpty(methods)) { - this.supportedMethods = new LinkedHashSet(Arrays.asList(methods)); + this.supportedMethods = new LinkedHashSet<>(Arrays.asList(methods)); } else { this.supportedMethods = null; @@ -167,7 +167,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { private void initAllowHeader() { Collection allowedMethods; if (this.supportedMethods == null) { - allowedMethods = new ArrayList(HttpMethod.values().length - 1); + allowedMethods = new ArrayList<>(HttpMethod.values().length - 1); for (HttpMethod method : HttpMethod.values()) { if (!HttpMethod.TRACE.equals(method)) { allowedMethods.add(method.name()); @@ -178,7 +178,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { allowedMethods = this.supportedMethods; } else { - allowedMethods = new ArrayList(this.supportedMethods); + allowedMethods = new ArrayList<>(this.supportedMethods); allowedMethods.add(HttpMethod.OPTIONS.name()); } @@ -593,7 +593,7 @@ public abstract class WebContentGenerator extends WebApplicationObjectSupport { if (!response.containsHeader(HttpHeaders.VARY)) { return Arrays.asList(getVaryByRequestHeaders()); } - Collection result = new ArrayList(getVaryByRequestHeaders().length); + Collection result = new ArrayList<>(getVaryByRequestHeaders().length); Collections.addAll(result, getVaryByRequestHeaders()); for (String header : response.getHeaders(HttpHeaders.VARY)) { for (String existing : StringUtils.tokenizeToStringArray(header, ",")) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java index 16dc88c8386..eb1bbba3b03 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/MessageTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -161,7 +161,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware { @Override protected final int doStartTagInternal() throws JspException, IOException { - this.nestedArguments = new LinkedList(); + this.nestedArguments = new LinkedList<>(); return EVAL_BODY_INCLUDE; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java index 201a5fb4154..65dfe9cce94 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/UrlTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -161,8 +161,8 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware { @Override public int doStartTagInternal() throws JspException { - this.params = new LinkedList(); - this.templateParams = new HashSet(); + this.params = new LinkedList<>(); + this.templateParams = new HashSet<>(); return EVAL_BODY_INCLUDE; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTag.java index f3da981aa86..bdf1dda7474 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -397,7 +397,7 @@ public abstract class AbstractHtmlElementTag extends AbstractDataBoundFormElemen @Override public void setDynamicAttribute(String uri, String localName, Object value ) throws JspException { if (this.dynamicAttributes == null) { - this.dynamicAttributes = new HashMap(); + this.dynamicAttributes = new HashMap<>(); } if (!isValidDynamicAttribute(localName, value)) { throw new IllegalArgumentException( diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/ErrorsTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/ErrorsTag.java index 1673f18fb75..a55e203acf0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/ErrorsTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/ErrorsTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,7 +170,7 @@ public class ErrorsTag extends AbstractHtmlElementBodyTag implements BodyTag { */ @Override protected void exposeAttributes() throws JspException { - List errorMessages = new ArrayList(); + List errorMessages = new ArrayList<>(); errorMessages.addAll(Arrays.asList(getBindStatus().getErrorMessages())); this.oldMessages = this.pageContext.getAttribute(MESSAGES_ATTRIBUTE, PageContext.PAGE_SCOPE); this.pageContext.setAttribute(MESSAGES_ATTRIBUTE, errorMessages, PageContext.PAGE_SCOPE); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/SelectedValueComparator.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/SelectedValueComparator.java index 35611123732..e0f0ab8605c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/SelectedValueComparator.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/SelectedValueComparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,7 +127,7 @@ abstract class SelectedValueComparator { private static boolean exhaustiveCollectionCompare( Collection collection, Object candidateValue, BindStatus bindStatus) { - Map convertedValueCache = new HashMap(1); + Map convertedValueCache = new HashMap<>(1); PropertyEditor editor = null; boolean candidateIsString = (candidateValue instanceof String); if (!candidateIsString) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java index ac52381d9c0..0f723d1a48b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/TagWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public class TagWriter { /** * Stores {@link TagStateEntry tag state}. Stack model naturally supports tag nesting. */ - private final Stack tagState = new Stack(); + private final Stack tagState = new Stack<>(); /** diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractCachingViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractCachingViewResolver.java index 899313949a7..44b64a194dd 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractCachingViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractCachingViewResolver.java @@ -64,7 +64,7 @@ public abstract class AbstractCachingViewResolver extends WebApplicationObjectSu private boolean cacheUnresolved = true; /** Fast access cache for Views, returning already cached instances without a global lock */ - private final Map viewAccessCache = new ConcurrentHashMap(DEFAULT_CACHE_LIMIT); + private final Map viewAccessCache = new ConcurrentHashMap<>(DEFAULT_CACHE_LIMIT); /** Map from view key to View instance, synchronized for View creation */ @SuppressWarnings("serial") diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java index 83eb9241237..e746c5f5b07 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement private String requestContextAttribute; - private final Map staticAttributes = new LinkedHashMap(); + private final Map staticAttributes = new LinkedHashMap<>(); private boolean exposePathVariables = true; @@ -281,7 +281,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement * flag on but do not list specific bean names for this property. */ public void setExposedContextBeanNames(String... exposedContextBeanNames) { - this.exposedContextBeanNames = new HashSet(Arrays.asList(exposedContextBeanNames)); + this.exposedContextBeanNames = new HashSet<>(Arrays.asList(exposedContextBeanNames)); } @@ -319,7 +319,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement size += (model != null ? model.size() : 0); size += (pathVars != null ? pathVars.size() : 0); - Map mergedModel = new LinkedHashMap(size); + Map mergedModel = new LinkedHashMap<>(size); mergedModel.putAll(this.staticAttributes); if (pathVars != null) { mergedModel.putAll(pathVars); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java index 511cd4c4f9d..078334748cc 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -177,7 +177,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport Collection matchingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(getApplicationContext(), ViewResolver.class).values(); if (this.viewResolvers == null) { - this.viewResolvers = new ArrayList(matchingBeans.size()); + this.viewResolvers = new ArrayList<>(matchingBeans.size()); for (ViewResolver viewResolver : matchingBeans) { if (this != viewResolver) { this.viewResolvers.add(viewResolver); @@ -249,7 +249,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport Collections.singletonList(MediaType.ALL)); List producibleMediaTypes = getProducibleMediaTypes(request); - Set compatibleMediaTypes = new LinkedHashSet(); + Set compatibleMediaTypes = new LinkedHashSet<>(); for (MediaType acceptable : acceptableMediaTypes) { for (MediaType producible : producibleMediaTypes) { if (acceptable.isCompatibleWith(producible)) { @@ -257,7 +257,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport } } } - List selectedMediaTypes = new ArrayList(compatibleMediaTypes); + List selectedMediaTypes = new ArrayList<>(compatibleMediaTypes); MediaType.sortBySpecificityAndQuality(selectedMediaTypes); if (logger.isDebugEnabled()) { logger.debug("Requested media types are " + selectedMediaTypes + " based on Accept header types " + @@ -275,7 +275,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport Set mediaTypes = (Set) request.getAttribute(HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE); if (!CollectionUtils.isEmpty(mediaTypes)) { - return new ArrayList(mediaTypes); + return new ArrayList<>(mediaTypes); } else { return Collections.singletonList(MediaType.ALL); @@ -294,7 +294,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport private List getCandidateViews(String viewName, Locale locale, List requestedMediaTypes) throws Exception { - List candidateViews = new ArrayList(); + List candidateViews = new ArrayList<>(); for (ViewResolver viewResolver : this.viewResolvers) { View view = viewResolver.resolveViewName(viewName, locale); if (view != null) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java index 928e5ef9ee1..0590fee3aec 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java @@ -493,7 +493,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView { * @see #isEligibleProperty(String, Object) */ protected Map queryProperties(Map model) { - Map result = new LinkedHashMap(); + Map result = new LinkedHashMap<>(); for (Map.Entry entry : model.entrySet()) { if (isEligibleProperty(entry.getKey(), entry.getValue())) { result.put(entry.getKey(), entry.getValue()); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java index 78731a71b5b..7593aaf6151 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,11 +78,11 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver /* Locale -> BeanFactory */ private final Map localeCache = - new HashMap(); + new HashMap<>(); /* List of ResourceBundle -> BeanFactory */ private final Map, ConfigurableApplicationContext> bundleCache = - new HashMap, ConfigurableApplicationContext>(); + new HashMap<>(); public void setOrder(int order) { @@ -220,7 +220,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver } // Build list of ResourceBundle references for Locale. - List bundles = new LinkedList(); + List bundles = new LinkedList<>(); for (String basename : this.basenames) { ResourceBundle bundle = getBundle(basename, locale); bundles.add(bundle); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java index a565c350ead..5d126856fdb 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java @@ -116,7 +116,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements private String requestContextAttribute; /** Map of static attributes, keyed by attribute name (String) */ - private final Map staticAttributes = new HashMap(); + private final Map staticAttributes = new HashMap<>(); private Boolean exposePathVariables; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ViewResolverComposite.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ViewResolverComposite.java index fddc5deb8b0..6f82fc5bdca 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ViewResolverComposite.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ViewResolverComposite.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import org.springframework.web.servlet.ViewResolver; public class ViewResolverComposite implements ViewResolver, Ordered, InitializingBean, ApplicationContextAware, ServletContextAware { - private final List viewResolvers = new ArrayList(); + private final List viewResolvers = new ArrayList<>(); private int order = Ordered.LOWEST_PRECEDENCE; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java index 69a5cb36efe..39eead253cb 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -161,7 +161,7 @@ public class GroovyMarkupConfigurer extends TemplateConfiguration */ protected ClassLoader createTemplateClassLoader() throws IOException { String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath()); - List urls = new ArrayList(); + List urls = new ArrayList<>(); for (String path : paths) { Resource[] resources = getApplicationContext().getResources(path); if (resources.length > 0) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java index 1acbcdfc4aa..2d2ddfd1b0d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,7 +156,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView { * Stores the exporter parameters passed in by the user as passed in by the user. May be keyed as * {@code String}s with the fully qualified name of the exporter parameter field. */ - private Map exporterParameters = new HashMap(); + private Map exporterParameters = new HashMap<>(); /** * Stores the converted exporter parameters - keyed by {@code JRExporterParameter}. @@ -317,7 +317,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView { throw new ApplicationContextException( "'reportDataKey' for main report is required when specifying a value for 'subReportDataKeys'"); } - this.subReports = new HashMap(this.subReportUrls.size()); + this.subReports = new HashMap<>(this.subReportUrls.size()); for (Enumeration urls = this.subReportUrls.propertyNames(); urls.hasMoreElements();) { String key = (String) urls.nextElement(); String path = this.subReportUrls.getProperty(key); @@ -358,7 +358,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView { protected final void convertExporterParameters() { if (!CollectionUtils.isEmpty(this.exporterParameters)) { this.convertedExporterParameters = - new HashMap(this.exporterParameters.size()); + new HashMap<>(this.exporterParameters.size()); for (Map.Entry entry : this.exporterParameters.entrySet()) { net.sf.jasperreports.engine.JRExporterParameter exporterParameter = getExporterParameter(entry.getKey()); this.convertedExporterParameters.put( diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java index 7821494d31e..98fd52fcaa2 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ public class JasperReportsMultiFormatView extends AbstractJasperReportsView { * with a default set of mappings. */ public JasperReportsMultiFormatView() { - this.formatMappings = new HashMap>(4); + this.formatMappings = new HashMap<>(4); this.formatMappings.put("csv", JasperReportsCsvView.class); this.formatMappings.put("html", JasperReportsHtmlView.class); this.formatMappings.put("pdf", JasperReportsPdfView.class); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsViewResolver.java index c55192c557a..371b5b562db 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/JasperReportsViewResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class JasperReportsViewResolver extends UrlBasedViewResolver { private Properties headers; - private Map exporterParameters = new HashMap(); + private Map exporterParameters = new HashMap<>(); private DataSource jdbcDataSource; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java index 12a5baa0c2b..b365d2c8f70 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View { private boolean extractValueFromSingleKeyModel = false; - private Set jsonpParameterNames = new LinkedHashSet(Arrays.asList("jsonp", "callback")); + private Set jsonpParameterNames = new LinkedHashSet<>(Arrays.asList("jsonp", "callback")); /** @@ -213,7 +213,7 @@ public class MappingJackson2JsonView extends AbstractJackson2View { */ @Override protected Object filterModel(Map model) { - Map result = new HashMap(model.size()); + Map result = new HashMap<>(model.size()); Set modelKeys = (!CollectionUtils.isEmpty(this.modelKeys) ? this.modelKeys : model.keySet()); for (Map.Entry entry : model.entrySet()) { if (!(entry.getValue() instanceof BindingResult) && modelKeys.contains(entry.getKey()) && diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java index ac8298a8aa3..4dfb0a17482 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java @@ -74,7 +74,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView { private static final ThreadLocal> enginesHolder = - new NamedThreadLocal>("ScriptTemplateView engines"); + new NamedThreadLocal<>("ScriptTemplateView engines"); private ScriptEngine engine; @@ -254,7 +254,7 @@ public class ScriptTemplateView extends AbstractUrlBasedView { if (Boolean.FALSE.equals(this.sharedEngine)) { Map engines = enginesHolder.get(); if (engines == null) { - engines = new HashMap(4); + engines = new HashMap<>(4); enginesHolder.set(engines); } Object engineKey = (!ObjectUtils.isEmpty(this.scripts) ? diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SimpleSpringPreparerFactory.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SimpleSpringPreparerFactory.java index 6efe19a8140..0d6686a4b05 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SimpleSpringPreparerFactory.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SimpleSpringPreparerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import org.springframework.web.context.WebApplicationContext; public class SimpleSpringPreparerFactory extends AbstractSpringPreparerFactory { /** Cache of shared ViewPreparer instances: bean name -> bean instance */ - private final Map sharedPreparers = new ConcurrentHashMap(16); + private final Map sharedPreparers = new ConcurrentHashMap<>(16); @Override diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java index e75e5891ecf..6b1b5cfaab9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +85,7 @@ public class SpringWildcardServletTilesApplicationContext extends ServletApplica return Collections.emptyList(); } - Collection resourceList = new ArrayList(resources.length); + Collection resourceList = new ArrayList<>(resources.length); for (Resource resource : resources) { try { URL url = resource.getURL(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java index 919f83d3997..9e65987c551 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles3/TilesConfigurer.java @@ -300,7 +300,7 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D @Override protected List getSources(ApplicationContext applicationContext) { if (definitions != null) { - List result = new LinkedList(); + List result = new LinkedList<>(); for (String definition : definitions) { Collection resources = applicationContext.getResources(definition); if (resources != null) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java index df0cce924f6..74277c06af8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,7 +119,7 @@ public class ServletContextSupportTests { @Test public void testServletContextAttributeExporter() { TestBean tb = new TestBean(); - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); attributes.put("attr1", "value1"); attributes.put("attr2", tb); @@ -144,7 +144,7 @@ public class ServletContextSupportTests { @Test public void testServletContextResourcePatternResolver() throws IOException { - final Set paths = new HashSet(); + final Set paths = new HashSet<>(); paths.add("/WEB-INF/context1.xml"); paths.add("/WEB-INF/context2.xml"); @@ -160,7 +160,7 @@ public class ServletContextSupportTests { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/*.xml"); - Set foundPaths = new HashSet(); + Set foundPaths = new HashSet<>(); for (Resource resource : found) { foundPaths.add(((ServletContextResource) resource).getPath()); } @@ -171,7 +171,7 @@ public class ServletContextSupportTests { @Test public void testServletContextResourcePatternResolverWithPatternPath() throws IOException { - final Set dirs = new HashSet(); + final Set dirs = new HashSet<>(); dirs.add("/WEB-INF/mydir1/"); dirs.add("/WEB-INF/mydir2/"); @@ -193,7 +193,7 @@ public class ServletContextSupportTests { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/*/*.xml"); - Set foundPaths = new HashSet(); + Set foundPaths = new HashSet<>(); for (Resource resource : found) { foundPaths.add(((ServletContextResource) resource).getPath()); } @@ -204,11 +204,11 @@ public class ServletContextSupportTests { @Test public void testServletContextResourcePatternResolverWithUnboundedPatternPath() throws IOException { - final Set dirs = new HashSet(); + final Set dirs = new HashSet<>(); dirs.add("/WEB-INF/mydir1/"); dirs.add("/WEB-INF/mydir2/"); - final Set paths = new HashSet(); + final Set paths = new HashSet<>(); paths.add("/WEB-INF/mydir2/context2.xml"); paths.add("/WEB-INF/mydir2/mydir3/"); @@ -233,7 +233,7 @@ public class ServletContextSupportTests { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/**/*.xml"); - Set foundPaths = new HashSet(); + Set foundPaths = new HashSet<>(); for (Resource resource : found) { foundPaths.add(((ServletContextResource) resource).getPath()); } @@ -245,7 +245,7 @@ public class ServletContextSupportTests { @Test public void testServletContextResourcePatternResolverWithAbsolutePaths() throws IOException { - final Set paths = new HashSet(); + final Set paths = new HashSet<>(); paths.add("C:/webroot/WEB-INF/context1.xml"); paths.add("C:/webroot/WEB-INF/context2.xml"); paths.add("C:/webroot/someOtherDirThatDoesntContainPath"); @@ -262,7 +262,7 @@ public class ServletContextSupportTests { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/*.xml"); - Set foundPaths = new HashSet(); + Set foundPaths = new HashSet<>(); for (Resource resource : found) { foundPaths.add(((ServletContextResource) resource).getPath()); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java index 3a75d1d20ee..cacb3618ef3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/ComplexWebApplicationContext.java @@ -158,7 +158,7 @@ public class ComplexWebApplicationContext extends StaticWebApplicationContext { pvs = new MutablePropertyValues(); pvs.add("order", "0"); pvs.add("exceptionMappings", "java.lang.Exception=failed1"); - List mappedHandlers = new ManagedList(); + List mappedHandlers = new ManagedList<>(); mappedHandlers.add(new RuntimeBeanReference("anotherLocaleHandler")); pvs.add("mappedHandlers", mappedHandlers); pvs.add("defaultStatusCode", "500"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java index 4b23da89ed8..dc8e683e7e8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ public class FlashMapTests { @Test public void addTargetRequestParamsNullValue() { - MultiValueMap params = new LinkedMultiValueMap(); + MultiValueMap params = new LinkedMultiValueMap<>(); params.add("key", "abc"); params.add("key", " "); params.add("key", null); @@ -108,7 +108,7 @@ public class FlashMapTests { @Test public void addTargetRequestParamsNullKey() { - MultiValueMap params = new LinkedMultiValueMap(); + MultiValueMap params = new LinkedMultiValueMap<>(); params.add(" ", "abc"); params.add(null, " "); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java index 258b67a9a22..476a1804f46 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -117,7 +117,7 @@ public class DelegatingWebMvcConfigurationTests { public void configureMessageConverters() { final HttpMessageConverter customConverter = mock(HttpMessageConverter.class); final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(); - List configurers = new ArrayList(); + List configurers = new ArrayList<>(); configurers.add(new WebMvcConfigurerAdapter() { @Override public void configureMessageConverters(List> converters) { @@ -176,7 +176,7 @@ public class DelegatingWebMvcConfigurationTests { @Test public void configureExceptionResolvers() throws Exception { - List configurers = new ArrayList(); + List configurers = new ArrayList<>(); configurers.add(new WebMvcConfigurerAdapter() { @Override public void configureHandlerExceptionResolvers(List exceptionResolvers) { @@ -195,7 +195,7 @@ public class DelegatingWebMvcConfigurationTests { final PathMatcher pathMatcher = mock(PathMatcher.class); final UrlPathHelper pathHelper = mock(UrlPathHelper.class); - List configurers = new ArrayList(); + List configurers = new ArrayList<>(); configurers.add(new WebMvcConfigurerAdapter() { @Override public void configurePathMatch(PathMatchConfigurer configurer) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java index 4e49bc9cb4a..4e31e6534b7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,7 +153,7 @@ public class InterceptorRegistryTests { private List getInterceptorsForPath(String lookupPath) { PathMatcher pathMatcher = new AntPathMatcher(); - List result = new ArrayList(); + List result = new ArrayList<>(); for (Object interceptor : this.registry.getInterceptors()) { if (interceptor instanceof MappedInterceptor) { MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java index dd6b09bd2c2..a7764e0cbed 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ public class SimpleUrlHandlerMappingTests { SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); handlerMapping.setUrlDecode(false); Object controller = new Object(); - Map urlMap = new LinkedHashMap(); + Map urlMap = new LinkedHashMap<>(); urlMap.put("/*/baz", controller); handlerMapping.setUrlMap(urlMap); handlerMapping.setApplicationContext(new StaticApplicationContext()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java index 0b6fe464e8b..db3198f14f4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class ExtendedServletRequestDataBinderTests { @Test public void createBinder() throws Exception { - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name", "nameValue"); uriTemplateVars.put("age", "25"); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); @@ -63,7 +63,7 @@ public class ExtendedServletRequestDataBinderTests { public void uriTemplateVarAndRequestParam() throws Exception { request.addParameter("age", "35"); - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name", "nameValue"); uriTemplateVars.put("age", "25"); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java index fdf6c652187..57dd208b2c3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java @@ -77,7 +77,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { this.request = new MockHttpServletRequest(); this.webRequest = new ServletWebRequest(request, new MockHttpServletResponse()); - Map> params = new LinkedHashMap>(); + Map> params = new LinkedHashMap<>(); this.request.setAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, params); } @@ -163,7 +163,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { (Map>) this.request.getAttribute( HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE); - MultiValueMap params = new LinkedMultiValueMap(); + MultiValueMap params = new LinkedMultiValueMap<>(); matrixVariables.put(pathVarName, params); return params; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java index f3630df4788..7651b9d57a7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public class MatrixVariablesMethodArgumentResolverTests { this.request = new MockHttpServletRequest(); this.webRequest = new ServletWebRequest(request, new MockHttpServletResponse()); - Map> params = new LinkedHashMap>(); + Map> params = new LinkedHashMap<>(); this.request.setAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, params); } @@ -142,7 +142,7 @@ public class MatrixVariablesMethodArgumentResolverTests { (Map>) this.request.getAttribute( HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE); - MultiValueMap params = new LinkedMultiValueMap(); + MultiValueMap params = new LinkedMultiValueMap<>(); matrixVariables.put(pathVarName, params); return params; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java index b2a6d2aa2b1..4bbd25ab238 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java @@ -53,7 +53,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { @Before public void setUp() { - mavResolvers = new ArrayList(); + mavResolvers = new ArrayList<>(); handler = new ModelAndViewResolverMethodReturnValueHandler(mavResolvers); mavContainer = new ModelAndViewContainer(); request = new ServletWebRequest(new MockHttpServletRequest()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java index fab29a4cec6..78c151928b4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,7 +78,7 @@ public class PathVariableMapMethodArgumentResolverTests { @Test public void resolveArgument() throws Exception { - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name1", "value1"); uriTemplateVars.put("name2", "value2"); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java index 04aefac3cf7..2e291ad3798 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ public class PathVariableMethodArgumentResolverTests { @Test public void resolveArgument() throws Exception { - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name", "value"); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); @@ -92,7 +92,7 @@ public class PathVariableMethodArgumentResolverTests { @SuppressWarnings("unchecked") @Test public void resolveArgumentWithExistingPathVars() throws Exception { - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("name", "value"); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java index 7b67044dd26..702dcc12205 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java @@ -118,7 +118,7 @@ public class RequestMappingHandlerAdapterIntegrationTests { ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); bindingInitializer.setValidator(new StubValidator()); - List customResolvers = new ArrayList(); + List customResolvers = new ArrayList<>(); customResolvers.add(new ServletWebArgumentResolverAdapter(new ColorArgumentResolver())); GenericWebApplicationContext context = new GenericWebApplicationContext(); @@ -172,7 +172,7 @@ public class RequestMappingHandlerAdapterIntegrationTests { request.setContextPath("/contextPath"); request.setServletPath("/main"); System.setProperty("systemHeader", "systemHeaderValue"); - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("pathvar", "pathvarValue"); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); request.getSession().setAttribute("sessionAttribute", sessionAttribute); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java index dcbb9554ecd..33c5570c37d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -319,12 +319,12 @@ public class RequestMappingHandlerAdapterTests { } public ResponseEntity> handleWithResponseEntity() { - return new ResponseEntity>(Collections.singletonMap( + return new ResponseEntity<>(Collections.singletonMap( "foo", "bar"), HttpStatus.OK); } public ResponseEntity handleBadRequest() { - return new ResponseEntity("body", HttpStatus.BAD_REQUEST); + return new ResponseEntity<>("body", HttpStatus.BAD_REQUEST); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java index 13946db1e46..7ba51e41779 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java @@ -86,7 +86,7 @@ public class RequestMappingHandlerMappingTests { PathExtensionContentNegotiationStrategy strategy = new PathExtensionContentNegotiationStrategy(fileExtensions); ContentNegotiationManager manager = new ContentNegotiationManager(strategy); - final Set extensions = new HashSet(); + final Set extensions = new HashSet<>(); RequestMappingHandlerMapping hm = new RequestMappingHandlerMapping() { @Override diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java index 97f42ee8e15..28b112529aa 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -183,14 +183,14 @@ public class RequestPartIntegrationTests { } private void testCreate(String url, String basename) { - MultiValueMap parts = new LinkedMultiValueMap(); - parts.add("json-data", new HttpEntity(new TestData(basename))); + MultiValueMap parts = new LinkedMultiValueMap<>(); + parts.add("json-data", new HttpEntity<>(new TestData(basename))); parts.add("file-data", new ClassPathResource("logo.jpg", getClass())); - parts.add("empty-data", new HttpEntity(new byte[0])); // SPR-12860 + parts.add("empty-data", new HttpEntity<>(new byte[0])); // SPR-12860 HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("application", "octet-stream", Charset.forName("ISO-8859-1"))); - parts.add("iso-8859-1-data", new HttpEntity(new byte[] {(byte) 0xC4}, headers)); // SPR-13096 + parts.add("iso-8859-1-data", new HttpEntity<>(new byte[] {(byte) 0xC4}, headers)); // SPR-13096 URI location = restTemplate.postForLocation(url, parts); assertEquals("http://localhost:8080/test/" + basename + "/logo.jpg", location.toString()); @@ -245,7 +245,7 @@ public class RequestPartIntegrationTests { String url = "http://localhost:8080/test/" + testData.getName() + "/" + file.get().getOriginalFilename(); HttpHeaders headers = new HttpHeaders(); headers.setLocation(URI.create(url)); - return new ResponseEntity(headers, HttpStatus.CREATED); + return new ResponseEntity<>(headers, HttpStatus.CREATED); } @RequestMapping(value = "/spr13319", method = POST, consumes = "multipart/form-data") diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index a442cc3c882..448aaee5db4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -313,7 +313,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl assertEquals("Invalid response status", HttpServletResponse.SC_METHOD_NOT_ALLOWED, response.getStatus()); String allowHeader = response.getHeader("Allow"); assertNotNull("No Allow header", allowHeader); - Set allowedMethods = new HashSet(); + Set allowedMethods = new HashSet<>(); allowedMethods.addAll(Arrays.asList(StringUtils.delimitedListToStringArray(allowHeader, ", "))); assertEquals("Invalid amount of supported methods", 6, allowedMethods.size()); assertTrue("PUT not allowed", allowedMethods.contains("PUT")); @@ -614,7 +614,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class)); RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class); adapterDef.getPropertyValues().add("webBindingInitializer", new MyWebBindingInitializer()); - List argumentResolvers = new ArrayList(); + List argumentResolvers = new ArrayList<>(); argumentResolvers.add(new ServletWebArgumentResolverAdapter(new MySpecialArgumentResolver())); adapterDef.getPropertyValues().add("customArgumentResolvers", argumentResolvers); wac.registerBeanDefinition("handlerAdapter", adapterDef); @@ -984,7 +984,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl @Override public void initialize(GenericWebApplicationContext wac) { RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class); - List> messageConverters = new ArrayList>(); + List> messageConverters = new ArrayList<>(); messageConverters.add(new StringHttpMessageConverter()); messageConverters .add(new SimpleMessageConverter(new MediaType("application","json"), MediaType.ALL)); @@ -2018,7 +2018,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl @Override public List getTestBeans() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new TestBean("tb1")); list.add(new TestBean("tb2")); return list; @@ -2044,7 +2044,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl @Override @ModelAttribute("testBeanList") public List getTestBeans() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new TestBean("tb1")); list.add(new TestBean("tb2")); return list; @@ -2071,7 +2071,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl @ModelAttribute("testBeanList") public List getTestBeans() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new TestBean("tb1")); list.add(new TestBean("tb2")); return list; @@ -2108,7 +2108,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl @ModelAttribute public List getTestBeans() { - List list = new LinkedList(); + List list = new LinkedList<>(); list.add(new TestBean("tb1")); list.add(new TestBean("tb2")); return list; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java index d5f794f97b5..253a9b3d7af 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ public class ServletModelAttributeMethodProcessorTests { @Test public void createAttributeUriTemplateVar() throws Exception { - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("testBean1", "Patty"); this.request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); @@ -102,7 +102,7 @@ public class ServletModelAttributeMethodProcessorTests { @Test public void createAttributeUriTemplateVarCannotConvert() throws Exception { - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("testBean2", "Patty"); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); @@ -115,7 +115,7 @@ public class ServletModelAttributeMethodProcessorTests { @Test public void createAttributeUriTemplateVarWithOptional() throws Exception { - Map uriTemplateVars = new HashMap(); + Map uriTemplateVars = new HashMap<>(); uriTemplateVars.put("testBean3", "Patty"); this.request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriTemplateVars); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java index 0627629acb9..f85faf5dcad 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java @@ -81,7 +81,7 @@ public class UriTemplateServletAnnotationControllerHandlerMethodTests extends Ab @Test public void pathVarsInModel() throws Exception { - final Map pathVars = new HashMap(); + final Map pathVars = new HashMap<>(); pathVars.put("hotel", "42"); pathVars.put("booking", 21); pathVars.put("other", "other"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java index 1e6d8250ada..8e876146657 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public class RedirectAttributesModelMapTests { @Test public void addAttributesMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("person", new TestBean("Fred")); map.put("age", 33); this.redirectAttributes.addAllAttributes(map); @@ -109,7 +109,7 @@ public class RedirectAttributesModelMapTests { @Test public void mergeAttributes() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("person", new TestBean("Fred")); map.put("age", 33); @@ -129,7 +129,7 @@ public class RedirectAttributesModelMapTests { @Test public void putAll() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("person", new TestBean("Fred")); map.put("age", 33); this.redirectAttributes.putAll(map); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipResourceResolverTests.java index 78b86d29067..0ec204c0531 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/GzipResourceResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,13 +84,13 @@ public class GzipResourceResolverTests { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(versionStrategyMap); - List resolvers = new ArrayList(); + List resolvers = new ArrayList<>(); resolvers.add(new CachingResourceResolver(this.cache)); resolvers.add(new GzipResourceResolver()); resolvers.add(versionResolver); resolvers.add(new PathResourceResolver()); resolver = new DefaultResourceResolverChain(resolvers); - locations = new ArrayList(); + locations = new ArrayList<>(); locations.add(new ClassPathResource("test/", getClass())); locations.add(new ClassPathResource("testalternatepath/", getClass())); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java index 843b7037492..e72c658c082 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java @@ -1,11 +1,11 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -75,10 +75,10 @@ public class AnnotationConfigDispatcherServletInitializerTests { public void setUp() throws Exception { servletContext = new MyMockServletContext(); initializer = new MyAnnotationConfigDispatcherServletInitializer(); - servlets = new LinkedHashMap(1); - servletRegistrations = new LinkedHashMap(1); - filters = new LinkedHashMap(1); - filterRegistrations = new LinkedHashMap(); + servlets = new LinkedHashMap<>(1); + servletRegistrations = new LinkedHashMap<>(1); + filters = new LinkedHashMap<>(1); + filterRegistrations = new LinkedHashMap<>(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java index 333a093bb61..8fa215672e3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -180,7 +180,7 @@ public class FlashMapManagerTests { @Test public void retrieveAndUpdateRemoveExpired() throws InterruptedException { - List flashMaps = new ArrayList(); + List flashMaps = new ArrayList<>(); for (int i = 0; i < 5; i++) { FlashMap expiredFlashMap = new FlashMap(); expiredFlashMap.startExpirationPeriod(-1); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockFilterRegistration.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockFilterRegistration.java index 55c20261678..71b44c68af8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockFilterRegistration.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockFilterRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ class MockFilterRegistration implements Dynamic { private boolean asyncSupported = false; - private Map> mappings = new HashMap>(); + private Map> mappings = new HashMap<>(); public Map> getMappings() { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockServletRegistration.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockServletRegistration.java index 54076069807..80e69d0dcfb 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockServletRegistration.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/MockServletRegistration.java @@ -1,11 +1,11 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -29,7 +29,7 @@ class MockServletRegistration implements ServletRegistration.Dynamic { private int loadOnStartup; - private Set mappings = new LinkedHashSet(); + private Set mappings = new LinkedHashSet<>(); private String roleName; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java index 905eae7a7c3..4c8587419d7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class RequestContextTests { private MockServletContext servletContext = new MockServletContext(); - private Map model = new HashMap(); + private Map model = new HashMap<>(); @Before public void init() { @@ -63,7 +63,7 @@ public class RequestContextTests { public void testGetContextUrlWithMap() throws Exception { request.setContextPath("foo/"); RequestContext context = new RequestContext(request, response, servletContext, model); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo", "bar"); map.put("spam", "bucket"); assertEquals("foo/bar?spam=bucket", context.getContextUrl("{foo}?spam={spam}", map)); @@ -73,7 +73,7 @@ public class RequestContextTests { public void testGetContextUrlWithMapEscaping() throws Exception { request.setContextPath("foo/"); RequestContext context = new RequestContext(request, response, servletContext, model); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("foo", "bar baz"); map.put("spam", "&bucket="); assertEquals("foo/bar%20baz?spam=%26bucket%3D", context.getContextUrl("{foo}?spam={spam}", map)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java index 307f7ef840d..fb5bf03b5df 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -151,7 +151,7 @@ public class EvalTagTests extends AbstractTagTests { @Test public void environmentAccess() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key.foo", "value.foo"); GenericApplicationContext wac = (GenericApplicationContext) context.getRequest().getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE); @@ -205,7 +205,7 @@ public class EvalTagTests extends AbstractTagTests { } public Map getMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key", "value"); return map; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java index 1647d4a40b4..f65ee4c1810 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -220,8 +220,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringNoParams() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); String queryString = tag.createQueryString(params, usedParams, true); @@ -230,8 +230,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringOneParam() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -246,8 +246,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringOneParamForExsistingQueryString() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -261,8 +261,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringOneParamEmptyValue() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -276,8 +276,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringOneParamNullValue() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -291,8 +291,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringOneParamAlreadyUsed() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -308,8 +308,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringTwoParams() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -328,8 +328,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringUrlEncoding() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("n me"); @@ -348,8 +348,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringParamNullName() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName(null); @@ -363,8 +363,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void createQueryStringParamEmptyName() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName(""); @@ -378,8 +378,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void replaceUriTemplateParamsNoParams() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); String uri = tag.replaceUriTemplateParams("url/path", params, usedParams); @@ -391,8 +391,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void replaceUriTemplateParamsTemplateWithoutParamMatch() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); String uri = tag.replaceUriTemplateParams("url/{path}", params, usedParams); @@ -404,8 +404,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void replaceUriTemplateParamsTemplateWithParamMatch() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -423,8 +423,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void replaceUriTemplateParamsTemplateWithParamMatchNamePreEncoding() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("n me"); @@ -442,8 +442,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void replaceUriTemplateParamsTemplateWithParamMatchValueEncoded() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -463,8 +463,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void replaceUriTemplateParamsTemplateWithPathSegment() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); @@ -481,8 +481,8 @@ public class UrlTagTests extends AbstractTagTests { @Test public void replaceUriTemplateParamsTemplateWithPath() throws JspException { - List params = new LinkedList(); - Set usedParams = new HashSet(); + List params = new LinkedList<>(); + Set usedParams = new HashSet<>(); Param param = new Param(); param.setName("name"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java index 302f457b062..1e9370dd627 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -168,7 +168,7 @@ public final class OptionsTagTests extends AbstractHtmlElementTagTests { getPageContext().setAttribute( SelectTag.LIST_VALUE_PAGE_ATTRIBUTE, new BindStatus(getRequestContext(), "testBean.myFloat", false)); - List floats = new ArrayList(); + List floats = new ArrayList<>(); floats.add(new Float("12.30")); floats.add(new Float("12.31")); floats.add(new Float("12.32")); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java index 2cf94778c16..6d97b8b1015 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -973,7 +973,7 @@ public class SelectTagTests extends AbstractFormTagTests { } private Map getSexes() { - Map sexes = new HashMap(); + Map sexes = new HashMap<>(); sexes.put("F", "Female"); sexes.put("M", "Male"); return sexes; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java index c464388e1c1..b8da8153a88 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ public class BaseViewTests { tv.setApplicationContext(wac); tv.setApplicationContext(wac); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "bar"); model.put("something", new Object()); tv.render(model, request, response); @@ -89,8 +89,8 @@ public class BaseViewTests { p.setProperty("something", "else"); tv.setAttributes(p); - Map model = new HashMap(); - model.put("one", new HashMap()); + Map model = new HashMap<>(); + model.put("one", new HashMap<>()); model.put("two", new Object()); tv.render(model, request, response); @@ -116,12 +116,12 @@ public class BaseViewTests { p.setProperty("something", "else"); tv.setAttributes(p); - Map pathVars = new HashMap(); - pathVars.put("one", new HashMap()); + Map pathVars = new HashMap<>(); + pathVars.put("one", new HashMap<>()); pathVars.put("two", new Object()); request.setAttribute(View.PATH_VARIABLES, pathVars); - tv.render(new HashMap(), request, response); + tv.render(new HashMap<>(), request, response); checkContainsAll(pathVars, tv.model); @@ -145,8 +145,8 @@ public class BaseViewTests { p.setProperty("something", "else"); tv.setAttributes(p); - Map model = new HashMap(); - model.put("one", new HashMap()); + Map model = new HashMap<>(); + model.put("one", new HashMap<>()); model.put("two", new Object()); tv.render(model, request, response); @@ -169,13 +169,13 @@ public class BaseViewTests { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); - Map pathVars = new HashMap(); + Map pathVars = new HashMap<>(); pathVars.put("one", "bar"); pathVars.put("something", "else"); request.setAttribute(View.PATH_VARIABLES, pathVars); - Map model = new HashMap(); - model.put("one", new HashMap()); + Map model = new HashMap<>(); + model.put("one", new HashMap<>()); model.put("two", new Object()); tv.render(model, request, response); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java index bec2e39d0d1..d79f8076ea8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -281,7 +281,7 @@ public class ContentNegotiatingViewResolverTests { View viewMock2 = mock(View.class, "text_html"); View viewMock3 = mock(View.class, "application_json"); - List defaultViews = new ArrayList(); + List defaultViews = new ArrayList<>(); defaultViews.add(viewMock3); viewResolver.setDefaultViews(defaultViews); @@ -343,7 +343,7 @@ public class ContentNegotiatingViewResolverTests { View viewMock2 = mock(View.class, "text_html"); View viewMock3 = mock(View.class, "application_json"); - List defaultViews = new ArrayList(); + List defaultViews = new ArrayList<>(); defaultViews.add(viewMock3); viewResolver.setDefaultViews(defaultViews); @@ -470,7 +470,7 @@ public class ContentNegotiatingViewResolverTests { InternalResourceViewResolver nestedResolver = new InternalResourceViewResolver(); nestedResolver.setApplicationContext(webAppContext); nestedResolver.setViewClass(InternalResourceView.class); - viewResolver.setViewResolvers(new ArrayList(Arrays.asList(nestedResolver))); + viewResolver.setViewResolvers(new ArrayList<>(Arrays.asList(nestedResolver))); FixedContentNegotiationStrategy fixedStrategy = new FixedContentNegotiationStrategy(MediaType.TEXT_HTML); viewResolver.setContentNegotiationManager(new ContentNegotiationManager(fixedStrategy)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java index ed32bd6cace..8e386b5543a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public class RedirectViewUriTemplateTests { @Test public void uriTemplate() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "bar"); String baseUrl = "http://url.somewhere.com"; @@ -60,7 +60,7 @@ public class RedirectViewUriTemplateTests { @Test public void uriTemplateEncode() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "bar/bar baz"); String baseUrl = "http://url.somewhere.com"; @@ -72,7 +72,7 @@ public class RedirectViewUriTemplateTests { @Test public void uriTemplateAndArrayQueryParam() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "bar"); model.put("fooArr", new String[] { "baz", "bazz" }); @@ -84,7 +84,7 @@ public class RedirectViewUriTemplateTests { @Test public void uriTemplateWithObjectConversion() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", new Long(611)); RedirectView redirectView = new RedirectView("/foo/{foo}"); @@ -95,12 +95,12 @@ public class RedirectViewUriTemplateTests { @Test public void uriTemplateReuseCurrentRequestVars() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("key1", "value1"); model.put("name", "value2"); model.put("key3", "value3"); - Map currentRequestUriTemplateVars = new HashMap(); + Map currentRequestUriTemplateVars = new HashMap<>(); currentRequestUriTemplateVars.put("var1", "v1"); currentRequestUriTemplateVars.put("name", "v2"); currentRequestUriTemplateVars.put("var3", "v3"); @@ -120,7 +120,7 @@ public class RedirectViewUriTemplateTests { @Test public void emptyRedirectString() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); RedirectView redirectView = new RedirectView(""); redirectView.renderMergedOutputModel(model, this.request, this.response); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java index d99e0d67f87..15a6bb06870 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class XlsViewTests { } }; - excelView.render(new HashMap(), request, response); + excelView.render(new HashMap<>(), request, response); Workbook wb = new HSSFWorkbook(new ByteArrayInputStream(response.getContentAsByteArray())); assertEquals("Test Sheet", wb.getSheetName(0)); @@ -85,7 +85,7 @@ public class XlsViewTests { } }; - excelView.render(new HashMap(), request, response); + excelView.render(new HashMap<>(), request, response); Workbook wb = new XSSFWorkbook(new ByteArrayInputStream(response.getContentAsByteArray())); assertEquals("Test Sheet", wb.getSheetName(0)); @@ -108,7 +108,7 @@ public class XlsViewTests { } }; - excelView.render(new HashMap(), request, response); + excelView.render(new HashMap<>(), request, response); Workbook wb = new XSSFWorkbook(new ByteArrayInputStream(response.getContentAsByteArray())); assertEquals("Test Sheet", wb.getSheetName(0)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java index 861e7385e47..34bf5a22420 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class AtomFeedViewTests { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); - Map model = new LinkedHashMap(); + Map model = new LinkedHashMap<>(); model.put("2", "This is entry 2"); model.put("1", "This is entry 1"); @@ -78,7 +78,7 @@ public class AtomFeedViewTests { @Override protected List buildFeedEntries(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { - List entries = new ArrayList(); + List entries = new ArrayList<>(); for (Iterator iterator = model.keySet().iterator(); iterator.hasNext();) { String name = (String) iterator.next(); Entry entry = new Entry(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java index 728d9340692..97efb7e889a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class RssFeedViewTests { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); - Map model = new LinkedHashMap(); + Map model = new LinkedHashMap<>(); model.put("2", "This is entry 2"); model.put("1", "This is entry 1"); @@ -79,7 +79,7 @@ public class RssFeedViewTests { @Override protected List buildFeedItems(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { - List items = new ArrayList(); + List items = new ArrayList<>(); for (String name : model.keySet()) { Item item = new Item(); item.setTitle(name); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java index 61576552142..308e25185ef 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java @@ -107,7 +107,7 @@ public class FreeMarkerMacroTests { fv.setApplicationContext(wac); fv.setExposeSpringMacroHelpers(true); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("tb", new TestBean("juergen", 99)); fv.render(model, request, response); } @@ -126,7 +126,7 @@ public class FreeMarkerMacroTests { fv.setApplicationContext(wac); fv.setExposeSpringMacroHelpers(true); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put(FreeMarkerView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE, helperTool); try { @@ -283,11 +283,11 @@ public class FreeMarkerMacroTests { FileCopyUtils.copy("<#import \"spring.ftl\" as spring />\n" + macro, new FileWriter(resource.getPath())); DummyMacroRequestContext rc = new DummyMacroRequestContext(request); - Map msgMap = new HashMap(); + Map msgMap = new HashMap<>(); msgMap.put("hello", "Howdy"); msgMap.put("world", "Mundo"); rc.setMessageMap(msgMap); - Map themeMsgMap = new HashMap(); + Map themeMsgMap = new HashMap<>(); themeMsgMap.put("hello", "Howdy!"); themeMsgMap.put("world", "Mundo!"); rc.setThemeMessageMap(themeMsgMap); @@ -301,14 +301,14 @@ public class FreeMarkerMacroTests { darren.setStringArray(new String[] {"John", "Fred"}); request.setAttribute("command", darren); - Map names = new HashMap(); + Map names = new HashMap<>(); names.put("Darren", "Darren Davison"); names.put("John", "John Doe"); names.put("Fred", "Fred Bloggs"); names.put("Rob&Harrop", "Rob Harrop"); Configuration config = fc.getConfiguration(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("command", darren); model.put("springMacroRequestContext", rc); model.put("msgArgs", new Object[] { "World" }); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java index 44d3faff6dc..823c5cd7ac8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class FreeMarkerViewTests { FreeMarkerView fv = new FreeMarkerView(); WebApplicationContext wac = mock(WebApplicationContext.class); - given(wac.getBeansOfType(FreeMarkerConfig.class, true, false)).willReturn(new HashMap()); + given(wac.getBeansOfType(FreeMarkerConfig.class, true, false)).willReturn(new HashMap<>()); given(wac.getServletContext()).willReturn(new MockServletContext()); fv.setUrl("anythingButNull"); @@ -92,7 +92,7 @@ public class FreeMarkerViewTests { WebApplicationContext wac = mock(WebApplicationContext.class); MockServletContext sc = new MockServletContext(); - Map configs = new HashMap(); + Map configs = new HashMap<>(); FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setConfiguration(new TestConfiguration()); configs.put("configurer", configurer); @@ -108,7 +108,7 @@ public class FreeMarkerViewTests { request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver()); HttpServletResponse response = new MockHttpServletResponse(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("myattr", "myvalue"); fv.render(model, request, response); @@ -122,7 +122,7 @@ public class FreeMarkerViewTests { WebApplicationContext wac = mock(WebApplicationContext.class); MockServletContext sc = new MockServletContext(); - Map configs = new HashMap(); + Map configs = new HashMap<>(); FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setConfiguration(new TestConfiguration()); configs.put("configurer", configurer); @@ -139,7 +139,7 @@ public class FreeMarkerViewTests { HttpServletResponse response = new MockHttpServletResponse(); response.setContentType("myContentType"); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("myattr", "myvalue"); fv.render(model, request, response); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java index 4c557b444a2..d276be0313b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public class GroovyMarkupViewTests { public void missingGroovyMarkupConfig() throws Exception { GroovyMarkupView view = new GroovyMarkupView(); given(this.webAppContext.getBeansOfType(GroovyMarkupConfig.class, true, false)) - .willReturn(new HashMap()); + .willReturn(new HashMap<>()); view.setUrl("sampleView"); try { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsTests.java index a77ea5bfb23..0c30197b10b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public abstract class AbstractJasperReportsTests { protected Map getModel() { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("ReportTitle", "Dear Lord!"); model.put("dataSource", new JRBeanCollectionDataSource(getData())); extendModel(model); @@ -82,7 +82,7 @@ public abstract class AbstractJasperReportsTests { } protected List getData() { - List list = new ArrayList(); + List list = new ArrayList<>(); for (int x = 0; x < 10; x++) { PersonBean bean = new PersonBean(); bean.setId(x); @@ -94,7 +94,7 @@ public abstract class AbstractJasperReportsTests { } protected List getProductData() { - List list = new ArrayList(); + List list = new ArrayList<>(); for (int x = 0; x < 10; x++) { ProductBean bean = new ProductBean(); bean.setId(x); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsViewTests.java index f5252d8d27e..e1850921a4f 100755 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -242,7 +242,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor String characterEncoding = "UTF-8"; String overiddenCharacterEncoding = "ASCII"; - Map parameters = new HashMap(); + Map parameters = new HashMap<>(); parameters.put(net.sf.jasperreports.engine.JRExporterParameter.CHARACTER_ENCODING, characterEncoding); view.setExporterParameters(parameters); @@ -361,7 +361,7 @@ public abstract class AbstractJasperReportsViewTests extends AbstractJasperRepor String characterEncoding = "UTF-8"; - Map parameters = new HashMap(); + Map parameters = new HashMap<>(); parameters.put(net.sf.jasperreports.engine.JRExporterParameter.CHARACTER_ENCODING, characterEncoding); view.setExporterParameters(parameters); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/ExporterParameterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/ExporterParameterTests.java index 61ba4f5847b..1e62fd72e10 100755 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/ExporterParameterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/ExporterParameterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests { @Test public void parameterParsing() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI", "/foo/bar"); AbstractJasperReportsView view = new AbstractJasperReportsView() { @@ -67,7 +67,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests { @Test(expected = IllegalArgumentException.class) public void invalidClass() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("foo.net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI", "/foo"); AbstractJasperReportsView view = new JasperReportsHtmlView(); @@ -79,7 +79,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests { @Test(expected = IllegalArgumentException.class) public void invalidField() { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IMAGES_URI_FOO", "/foo"); AbstractJasperReportsView view = new JasperReportsHtmlView(); @@ -91,7 +91,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests { @Test(expected = IllegalArgumentException.class) public void invalidType() { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("java.lang.Boolean.TRUE", "/foo"); AbstractJasperReportsView view = new JasperReportsHtmlView(); @@ -103,7 +103,7 @@ public class ExporterParameterTests extends AbstractJasperReportsTests { @Test public void typeConversion() { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("net.sf.jasperreports.engine.export.JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN", "true"); AbstractJasperReportsView view = new JasperReportsHtmlView(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewTests.java index 225a8ec9dab..fe776367496 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,10 +91,10 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView JasperReportsMultiFormatView view = (JasperReportsMultiFormatView) getView(UNCOMPILED_REPORT); Map> mappings = - new HashMap>(); + new HashMap<>(); mappings.put("test", ExporterParameterTestView.class); - Map exporterParameters = new HashMap(); + Map exporterParameters = new HashMap<>(); // test view class performs the assertions - robh exporterParameters.put(ExporterParameterTestView.TEST_PARAM, "foo"); @@ -124,7 +124,7 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView } private Map getBaseModel() { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("ReportTitle", "Foo"); model.put("dataSource", getData()); return model; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewWithCustomMappingsTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewWithCustomMappingsTests.java index 0ad16202a35..537d949f5f6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewWithCustomMappingsTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/jasperreports/JasperReportsMultiFormatViewWithCustomMappingsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public class JasperReportsMultiFormatViewWithCustomMappingsTests extends JasperR JasperReportsMultiFormatView view = new JasperReportsMultiFormatView(); view.setFormatKey("fmt"); Map> mappings = - new HashMap>(); + new HashMap<>(); mappings.put("csv", JasperReportsCsvView.class); mappings.put("comma-separated", JasperReportsCsvView.class); mappings.put("html", JasperReportsHtmlView.class); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java index 4e062b2a005..077f2dfa291 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,7 +96,7 @@ public class MappingJackson2JsonViewTests { @Test public void renderSimpleMap() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", "bar"); @@ -116,7 +116,7 @@ public class MappingJackson2JsonViewTests { @Test public void renderWithSelectedContentType() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "bar"); view.render(model, request, response); @@ -132,7 +132,7 @@ public class MappingJackson2JsonViewTests { public void renderCaching() throws Exception { view.setDisableCaching(false); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", "bar"); @@ -150,7 +150,7 @@ public class MappingJackson2JsonViewTests { @Test public void renderSimpleBean() throws Exception { Object bean = new TestBeanSimple(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", bean); @@ -193,7 +193,7 @@ public class MappingJackson2JsonViewTests { @Test public void renderWithCustomSerializerLocatedByAnnotation() throws Exception { Object bean = new TestBeanSimpleAnnotated(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", bean); view.render(model, request, response); @@ -212,7 +212,7 @@ public class MappingJackson2JsonViewTests { view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", bean); model.put("bar", new TestChildBean()); @@ -228,13 +228,13 @@ public class MappingJackson2JsonViewTests { @Test public void renderOnlyIncludedAttributes() throws Exception { - Set attrs = new HashSet(); + Set attrs = new HashSet<>(); attrs.add("foo"); attrs.add("baz"); attrs.add("nil"); view.setModelKeys(attrs); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "foo"); model.put("bar", "bar"); model.put("baz", "baz"); @@ -283,7 +283,7 @@ public class MappingJackson2JsonViewTests { @Test public void renderSimpleBeanWithJsonView() throws Exception { Object bean = new TestBeanSimple(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", bean); model.put(JsonView.class.getName(), MyJacksonView1.class); @@ -304,7 +304,7 @@ public class MappingJackson2JsonViewTests { TestSimpleBeanFiltered bean = new TestSimpleBeanFiltered(); bean.setProperty1("value"); bean.setProperty2("value"); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", bean); FilterProvider filters = new SimpleFilterProvider().addFilter("myJacksonFilter", @@ -347,7 +347,7 @@ public class MappingJackson2JsonViewTests { } private void testJsonp(String paramName, String paramValue, boolean validValue) throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "bar"); this.request = new MockHttpServletRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java index af4e8251d52..f028d4b17f7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -212,7 +212,7 @@ public class ScriptTemplateViewTests { MockHttpServletRequest request = new MockHttpServletRequest(); request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.wac); MockHttpServletResponse response = new MockHttpServletResponse(); - Map model = new HashMap(); + Map model = new HashMap<>(); InvocableScriptEngine engine = mock(InvocableScriptEngine.class); when(engine.invokeFunction(any(), any(), any(), any())).thenReturn("foo"); this.view.setEngine(engine); @@ -243,7 +243,7 @@ public class ScriptTemplateViewTests { MockHttpServletRequest request = new MockHttpServletRequest(); request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.wac); MockHttpServletResponse response = new MockHttpServletResponse(); - Map model = new HashMap(); + Map model = new HashMap<>(); this.view.setEngine(mock(InvocableScriptEngine.class)); this.view.setRenderFunction("render"); this.view.setResourceLoaderPath("classpath:org/springframework/web/servlet/view/script/"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java index e8099b1148f..2887e83f86d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ public class TilesViewTests { @Test public void render() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("modelAttribute", "modelValue"); view.render(model, request, response); assertEquals("modelValue", request.getAttribute("modelAttribute")); @@ -84,14 +84,14 @@ public class TilesViewTests { @Test public void alwaysIncludeDefaults() throws Exception { - view.render(new HashMap(), request, response); + view.render(new HashMap<>(), request, response); assertNull(request.getAttribute(AbstractRequest.FORCE_INCLUDE_ATTRIBUTE_NAME)); } @Test public void alwaysIncludeEnabled() throws Exception { view.setAlwaysInclude(true); - view.render(new HashMap(), request, response); + view.render(new HashMap<>(), request, response); assertTrue((Boolean)request.getAttribute(AbstractRequest.FORCE_INCLUDE_ATTRIBUTE_NAME)); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java index 1b9e6adce8d..da5d6a508ac 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ public class MappingJackson2XmlViewTests { @Test public void renderSimpleMap() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", "bar"); @@ -103,7 +103,7 @@ public class MappingJackson2XmlViewTests { @Test public void renderWithSelectedContentType() throws Exception { - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "bar"); view.render(model, request, response); @@ -119,7 +119,7 @@ public class MappingJackson2XmlViewTests { public void renderCaching() throws Exception { view.setDisableCaching(false); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", "bar"); @@ -131,7 +131,7 @@ public class MappingJackson2XmlViewTests { @Test public void renderSimpleBean() throws Exception { Object bean = new TestBeanSimple(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", bean); @@ -147,7 +147,7 @@ public class MappingJackson2XmlViewTests { @Test public void renderWithCustomSerializerLocatedByAnnotation() throws Exception { Object bean = new TestBeanSimpleAnnotated(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", bean); view.render(model, request, response); @@ -166,7 +166,7 @@ public class MappingJackson2XmlViewTests { view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", bean); view.render(model, request, response); @@ -182,7 +182,7 @@ public class MappingJackson2XmlViewTests { public void renderOnlySpecifiedModelKey() throws Exception { view.setModelKey("bar"); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("foo", "foo"); model.put("bar", "bar"); model.put("baz", "baz"); @@ -201,7 +201,7 @@ public class MappingJackson2XmlViewTests { @Test(expected = IllegalStateException.class) public void renderModelWithMultipleKeys() throws Exception { - Map model = new TreeMap(); + Map model = new TreeMap<>(); model.put("foo", "foo"); model.put("bar", "bar"); @@ -213,7 +213,7 @@ public class MappingJackson2XmlViewTests { @Test public void renderSimpleBeanWithJsonView() throws Exception { Object bean = new TestBeanSimple(); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put("bindingResult", mock(BindingResult.class, "binding_result")); model.put("foo", bean); model.put(JsonView.class.getName(), MyJacksonView1.class); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java index b1a3475f1cb..a12d32642e3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,7 +73,7 @@ public class MarshallingViewTests { Object toBeMarshalled = new Object(); String modelKey = "key"; view.setModelKey(modelKey); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put(modelKey, toBeMarshalled); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -92,8 +92,8 @@ public class MarshallingViewTests { String toBeMarshalled = "value"; String modelKey = "key"; view.setModelKey(modelKey); - Map model = new HashMap(); - model.put(modelKey, new JAXBElement(new QName("model"), String.class, toBeMarshalled)); + Map model = new HashMap<>(); + model.put(modelKey, new JAXBElement<>(new QName("model"), String.class, toBeMarshalled)); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); @@ -111,7 +111,7 @@ public class MarshallingViewTests { Object toBeMarshalled = new Object(); String modelKey = "key"; view.setModelKey("invalidKey"); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put(modelKey, toBeMarshalled); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -130,7 +130,7 @@ public class MarshallingViewTests { @Test public void renderNullModelValue() throws Exception { String modelKey = "key"; - Map model = new HashMap(); + Map model = new HashMap<>(); model.put(modelKey, null); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -151,7 +151,7 @@ public class MarshallingViewTests { Object toBeMarshalled = new Object(); String modelKey = "key"; view.setModelKey(modelKey); - Map model = new HashMap(); + Map model = new HashMap<>(); model.put(modelKey, toBeMarshalled); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -172,7 +172,7 @@ public class MarshallingViewTests { public void renderNoModelKey() throws Exception { Object toBeMarshalled = new Object(); String modelKey = "key"; - Map model = new HashMap(); + Map model = new HashMap<>(); model.put(modelKey, toBeMarshalled); MockHttpServletRequest request = new MockHttpServletRequest(); @@ -190,7 +190,7 @@ public class MarshallingViewTests { public void renderNoModelKeyAndBindingResultFirst() throws Exception { Object toBeMarshalled = new Object(); String modelKey = "key"; - Map model = new LinkedHashMap(); + Map model = new LinkedHashMap<>(); model.put(BindingResult.MODEL_KEY_PREFIX + modelKey, new BeanPropertyBindingResult(toBeMarshalled, modelKey)); model.put(modelKey, toBeMarshalled); @@ -210,7 +210,7 @@ public class MarshallingViewTests { public void testRenderUnsupportedModel() throws Exception { Object toBeMarshalled = new Object(); String modelKey = "key"; - Map model = new HashMap(); + Map model = new HashMap<>(); model.put(modelKey, toBeMarshalled); MockHttpServletRequest request = new MockHttpServletRequest(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java index 4ec0fe803b3..89fea5fc281 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public class WebSocketExtension { Assert.hasLength(name, "extension name must not be empty"); this.name = name; if (!CollectionUtils.isEmpty(parameters)) { - Map m = new LinkedCaseInsensitiveMap(parameters.size(), Locale.ENGLISH); + Map m = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH); m.putAll(parameters); this.parameters = Collections.unmodifiableMap(m); } @@ -106,7 +106,7 @@ public class WebSocketExtension { return Collections.emptyList(); } else { - List result = new ArrayList(); + List result = new ArrayList<>(); for (String token : extensions.split(",")) { result.add(parseExtension(token)); } @@ -121,7 +121,7 @@ public class WebSocketExtension { Map parameters = null; if (parts.length > 1) { - parameters = new LinkedHashMap(parts.length - 1); + parameters = new LinkedHashMap<>(parts.length - 1); for (int i = 1; i < parts.length; i++) { String parameter = parts[i]; int eqIndex = parameter.indexOf('='); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java index 4cda2747a65..148d8c8b362 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/WebSocketHttpHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,7 +108,7 @@ public class WebSocketHttpHeaders extends HttpHeaders { return Collections.emptyList(); } else { - List result = new ArrayList(values.size()); + List result = new ArrayList<>(values.size()); for (String value : values) { result.addAll(WebSocketExtension.parseExtensions(value)); } @@ -121,7 +121,7 @@ public class WebSocketHttpHeaders extends HttpHeaders { * @param extensions the values for the header */ public void setSecWebSocketExtensions(List extensions) { - List result = new ArrayList(extensions.size()); + List result = new ArrayList<>(extensions.size()); for (WebSocketExtension extension : extensions) { result.add(extension.toString()); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/AbstractWebSocketSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/AbstractWebSocketSession.java index 7db88740f47..469b0150ca3 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/AbstractWebSocketSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/AbstractWebSocketSession.java @@ -45,7 +45,7 @@ public abstract class AbstractWebSocketSession implements NativeWebSocketSess private T nativeSession; - private final Map attributes = new ConcurrentHashMap(); + private final Map attributes = new ConcurrentHashMap<>(); /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java index 2825a482436..745d0d956eb 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSession.java @@ -175,7 +175,7 @@ public class JettyWebSocketSession extends AbstractWebSocketSession { this.acceptedProtocol = session.getUpgradeResponse().getAcceptedSubProtocol(); List source = getNativeSession().getUpgradeResponse().getExtensions(); - this.extensions = new ArrayList(source.size()); + this.extensions = new ArrayList<>(source.size()); for (ExtensionConfig ec : source) { this.extensions.add(new WebSocketExtension(ec.getName(), ec.getParameters())); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java index 2b1837f4c0b..e59853d8bd3 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardToWebSocketExtensionAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public class StandardToWebSocketExtensionAdapter extends WebSocketExtension { private static Map initParameters(Extension extension) { List parameters = extension.getParameters(); - Map result = new LinkedCaseInsensitiveMap(parameters.size(), Locale.ENGLISH); + Map result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH); for (Extension.Parameter parameter : parameters) { result.put(parameter.getName(), parameter.getValue()); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java index fbd3de4db70..862a110dbbc 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -182,7 +182,7 @@ public class StandardWebSocketSession extends AbstractWebSocketSession this.acceptedProtocol = session.getNegotiatedSubprotocol(); List source = getNativeSession().getNegotiatedExtensions(); - this.extensions = new ArrayList(source.size()); + this.extensions = new ArrayList<>(source.size()); for (Extension ext : source) { this.extensions.add(new StandardToWebSocketExtensionAdapter(ext)); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/WebSocketToStandardExtensionAdapter.java b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/WebSocketToStandardExtensionAdapter.java index a8ee747ae8b..c789f4bc39f 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/WebSocketToStandardExtensionAdapter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/adapter/standard/WebSocketToStandardExtensionAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class WebSocketToStandardExtensionAdapter implements Extension { private final String name; - private final List parameters = new ArrayList(); + private final List parameters = new ArrayList<>(); public WebSocketToStandardExtensionAdapter(final WebSocketExtension extension) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java index 92577e1cbae..10b0743bc1d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/AbstractWebSocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public abstract class AbstractWebSocketClient implements WebSocketClient { protected final Log logger = LogFactory.getLog(getClass()); - private static final Set specialHeaders = new HashSet(); + private static final Set specialHeaders = new HashSet<>(); static { specialHeaders.add("cache-control"); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java index 65c240bda0e..a6dfe18208c 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/jetty/JettyWebSocketClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -182,7 +182,7 @@ public class JettyWebSocketClient extends AbstractWebSocketClient implements Lif return this.taskExecutor.submitListenable(connectTask); } else { - ListenableFutureTask task = new ListenableFutureTask(connectTask); + ListenableFutureTask task = new ListenableFutureTask<>(connectTask); task.run(); return task; } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/AnnotatedEndpointConnectionManager.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/AnnotatedEndpointConnectionManager.java index 77de7def22e..f77f12d6340 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/AnnotatedEndpointConnectionManager.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/AnnotatedEndpointConnectionManager.java @@ -60,7 +60,7 @@ public class AnnotatedEndpointConnectionManager extends ConnectionManagerSupport public AnnotatedEndpointConnectionManager(Class endpointClass, String uriTemplate, Object... uriVariables) { super(uriTemplate, uriVariables); - this.endpointProvider = new BeanCreatingHandlerProvider(endpointClass); + this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass); this.endpoint = null; } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/EndpointConnectionManager.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/EndpointConnectionManager.java index 82bc4817e42..c8682a92f3b 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/EndpointConnectionManager.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/EndpointConnectionManager.java @@ -71,7 +71,7 @@ public class EndpointConnectionManager extends ConnectionManagerSupport implemen public EndpointConnectionManager(Class endpointClass, String uriTemplate, Object... uriVars) { super(uriTemplate, uriVars); Assert.notNull(endpointClass, "endpointClass must not be null"); - this.endpointProvider = new BeanCreatingHandlerProvider(endpointClass); + this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass); this.endpoint = null; } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java index 8c3f7833318..908097b7472 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/client/standard/StandardWebSocketClient.java @@ -59,7 +59,7 @@ public class StandardWebSocketClient extends AbstractWebSocketClient { private final WebSocketContainer webSocketContainer; - private final Map userProperties = new HashMap(); + private final Map userProperties = new HashMap<>(); private AsyncListenableTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); @@ -155,14 +155,14 @@ public class StandardWebSocketClient extends AbstractWebSocketClient { return this.taskExecutor.submitListenable(connectTask); } else { - ListenableFutureTask task = new ListenableFutureTask(connectTask); + ListenableFutureTask task = new ListenableFutureTask<>(connectTask); task.run(); return task; } } private static List adaptExtensions(List extensions) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (WebSocketExtension extension : extensions) { result.add(new WebSocketToStandardExtensionAdapter(extension)); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java index deced0d0050..e741b265225 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/HandlersBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser { strategy = new WebSocketHandlerMappingStrategy(handshakeHandler, interceptors); } - ManagedMap urlMap = new ManagedMap(); + ManagedMap urlMap = new ManagedMap<>(); urlMap.setSource(source); for (Element mappingElement : DomUtils.getChildElementsByTagName(element, "mapping")) { strategy.addMapping(mappingElement, urlMap, context); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java index 9caa5a8f2eb..94b81e60504 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParser.java @@ -202,7 +202,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { handlerMappingDef.getPropertyValues().add("urlPathHelper", new RuntimeBeanReference(pathHelper)); } - ManagedMap urlMap = new ManagedMap(); + ManagedMap urlMap = new ManagedMap<>(); urlMap.setSource(source); handlerMappingDef.getPropertyValues().add("urlMap", urlMap); @@ -244,7 +244,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { argValues.addIndexedArgumentValue(0, new RuntimeBeanReference(executorName)); } RootBeanDefinition channelDef = new RootBeanDefinition(ExecutorSubscribableChannel.class, argValues, null); - ManagedList interceptors = new ManagedList(); + ManagedList interceptors = new ManagedList<>(); if (element != null) { Element interceptorsElement = DomUtils.getChildElementByTagName(element, "interceptors"); interceptors.addAll(WebSocketNamespaceUtils.parseBeanSubElements(interceptorsElement, context)); @@ -410,7 +410,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { if (brokerRelayElem.hasAttribute("virtual-host")) { values.add("virtualHost", brokerRelayElem.getAttribute("virtual-host")); } - ManagedMap map = new ManagedMap(); + ManagedMap map = new ManagedMap<>(); map.setSource(source); if (brokerRelayElem.hasAttribute("user-destination-broadcast")) { String destination = brokerRelayElem.getAttribute("user-destination-broadcast"); @@ -453,7 +453,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { private RuntimeBeanReference registerMessageConverter(Element element, ParserContext context, Object source) { Element convertersElement = DomUtils.getChildElementByTagName(element, "message-converters"); - ManagedList converters = new ManagedList(); + ManagedList converters = new ManagedList<>(); if (convertersElement != null) { converters.setSource(source); for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, "bean", "ref")) { @@ -556,7 +556,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser { } private ManagedList extractBeanSubElements(Element parentElement, ParserContext parserContext) { - ManagedList list = new ManagedList(); + ManagedList list = new ManagedList<>(); list.setSource(parserContext.extractSource(parentElement)); for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) { Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java index bd0d27fcf56..4a07250fd90 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -171,7 +171,7 @@ class WebSocketNamespaceUtils { } public static ManagedList parseBeanSubElements(Element parentElement, ParserContext context) { - ManagedList beans = new ManagedList(); + ManagedList beans = new ManagedList<>(); if (parentElement != null) { beans.setSource(context.extractSource(parentElement)); for (Element beanElement : DomUtils.getChildElementsByTagName(parentElement, "bean", "ref")) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/AbstractWebSocketHandlerRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/AbstractWebSocketHandlerRegistration.java index 58c4ef1f495..20db2a831fa 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/AbstractWebSocketHandlerRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/AbstractWebSocketHandlerRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,13 +45,13 @@ public abstract class AbstractWebSocketHandlerRegistration implements WebSock private final TaskScheduler sockJsTaskScheduler; - private MultiValueMap handlerMap = new LinkedMultiValueMap(); + private MultiValueMap handlerMap = new LinkedMultiValueMap<>(); private HandshakeHandler handshakeHandler; - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); - private final List allowedOrigins = new ArrayList(); + private final List allowedOrigins = new ArrayList<>(); private SockJsServiceRegistration sockJsServiceRegistration; @@ -114,7 +114,7 @@ public abstract class AbstractWebSocketHandlerRegistration implements WebSock } protected HandshakeInterceptor[] getInterceptors() { - List interceptors = new ArrayList(); + List interceptors = new ArrayList<>(); interceptors.addAll(this.interceptors); interceptors.add(new OriginHandshakeInterceptor(this.allowedOrigins)); return interceptors.toArray(new HandshakeInterceptor[interceptors.size()]); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.java index a8c72ed7136..aaadbd64eb1 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.util.CollectionUtils; @Configuration public class DelegatingWebSocketConfiguration extends WebSocketConfigurationSupport { - private final List configurers = new ArrayList(); + private final List configurers = new ArrayList<>(); @Autowired(required = false) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java index d11637aad67..6bf342a5264 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import org.springframework.util.CollectionUtils; @Configuration public class DelegatingWebSocketMessageBrokerConfiguration extends WebSocketMessageBrokerConfigurationSupport { - private final List configurers = new ArrayList(); + private final List configurers = new ArrayList<>(); @Autowired(required = false) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistration.java index f806b45d0ea..1eac014c8e3 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class ServletWebSocketHandlerRegistration @Override protected MultiValueMap createMappings() { - return new LinkedMultiValueMap(); + return new LinkedMultiValueMap<>(); } @Override diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistry.java index b14341b2659..6f81252d706 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import org.springframework.web.util.UrlPathHelper; public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry { private final List registrations = - new ArrayList(); + new ArrayList<>(); private TaskScheduler sockJsTaskScheduler; @@ -93,7 +93,7 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry * Return a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s. */ public AbstractHandlerMapping getHandlerMapping() { - Map urlMap = new LinkedHashMap(); + Map urlMap = new LinkedHashMap<>(); for (ServletWebSocketHandlerRegistration registration : this.registrations) { MultiValueMap mappings = registration.getMappings(); for (HttpRequestHandler httpHandler : mappings.keySet()) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java index 101296b2a0b..c697a4249b8 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,13 +56,13 @@ public class SockJsServiceRegistration { private Boolean webSocketEnabled; - private final List transportHandlers = new ArrayList(); + private final List transportHandlers = new ArrayList<>(); - private final List transportHandlerOverrides = new ArrayList(); + private final List transportHandlerOverrides = new ArrayList<>(); - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); - private final List allowedOrigins = new ArrayList(); + private final List allowedOrigins = new ArrayList<>(); private Boolean suppressCors; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java index 9dd520e7422..e30ddfb9e0b 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java @@ -58,7 +58,7 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry { private final StompSubProtocolHandler stompHandler; private final List registrations = - new ArrayList(); + new ArrayList<>(); public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler, @@ -148,7 +148,7 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry { * in case of no registrations. */ public AbstractHandlerMapping getHandlerMapping() { - Map urlMap = new LinkedHashMap(); + Map urlMap = new LinkedHashMap<>(); for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) { MultiValueMap mappings = registration.getMappings(); for (HttpRequestHandler httpHandler : mappings.keySet()) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistration.java index 56582796b66..b156442888e 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,9 +51,9 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE private HandshakeHandler handshakeHandler; - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); - private final List allowedOrigins = new ArrayList(); + private final List allowedOrigins = new ArrayList<>(); private StompSockJsServiceRegistration registration; @@ -111,14 +111,14 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE } protected HandshakeInterceptor[] getInterceptors() { - List interceptors = new ArrayList(); + List interceptors = new ArrayList<>(); interceptors.addAll(this.interceptors); interceptors.add(new OriginHandshakeInterceptor(this.allowedOrigins)); return interceptors.toArray(new HandshakeInterceptor[interceptors.size()]); } public final MultiValueMap getMappings() { - MultiValueMap mappings = new LinkedMultiValueMap(); + MultiValueMap mappings = new LinkedMultiValueMap<>(); if (this.registration != null) { SockJsService sockJsService = this.registration.getSockJsService(); for (String path : this.paths) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java index 0e9c2ec2f37..9abcd75fe7d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketTransportRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class WebSocketTransportRegistration { private Integer sendBufferSizeLimit; private final List decoratorFactories = - new ArrayList(2); + new ArrayList<>(2); /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java index 15dd486a75f..12bf4c5f72e 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecorator.java @@ -53,7 +53,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat private final int bufferSizeLimit; - private final Queue> buffer = new LinkedBlockingQueue>(); + private final Queue> buffer = new LinkedBlockingQueue<>(); private final AtomicInteger bufferSize = new AtomicInteger(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandler.java index c6194649fdb..0647f92bf41 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public class PerConnectionWebSocketHandler implements WebSocketHandler, BeanFact private final BeanCreatingHandlerProvider provider; private final Map handlers = - new ConcurrentHashMap(); + new ConcurrentHashMap<>(); private final boolean supportsPartialMessages; @@ -63,7 +63,7 @@ public class PerConnectionWebSocketHandler implements WebSocketHandler, BeanFact } public PerConnectionWebSocketHandler(Class handlerType, boolean supportsPartialMessages) { - this.provider = new BeanCreatingHandlerProvider(handlerType); + this.provider = new BeanCreatingHandlerProvider<>(handlerType); this.supportsPartialMessages = supportsPartialMessages; } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistry.java index 9ea63ea25fc..753e053a0de 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistry.java @@ -47,10 +47,10 @@ import org.springframework.util.Assert; public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicationListener { /* Primary lookup that holds all users and their sessions */ - private final Map users = new ConcurrentHashMap(); + private final Map users = new ConcurrentHashMap<>(); /* Secondary lookup across all sessions by id */ - private final Map sessions = new ConcurrentHashMap(); + private final Map sessions = new ConcurrentHashMap<>(); private final Object sessionLock = new Object(); @@ -138,11 +138,11 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati @Override public Set getUsers() { - return new HashSet(this.users.values()); + return new HashSet<>(this.users.values()); } public Set findSubscriptions(SimpSubscriptionMatcher matcher) { - Set result = new HashSet(); + Set result = new HashSet<>(); for (LocalSimpSession session : this.sessions.values()) { for (SimpSubscription subscription : session.subscriptions.values()) { if (matcher.match(subscription)) { @@ -165,7 +165,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati private final String name; private final Map userSessions = - new ConcurrentHashMap(1); + new ConcurrentHashMap<>(1); public LocalSimpUser(String userName) { @@ -190,7 +190,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati @Override public Set getSessions() { - return new HashSet(this.userSessions.values()); + return new HashSet<>(this.userSessions.values()); } void addSession(SimpSession session) { @@ -229,7 +229,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati private final LocalSimpUser user; - private final Map subscriptions = new ConcurrentHashMap(4); + private final Map subscriptions = new ConcurrentHashMap<>(4); public LocalSimpSession(String id, LocalSimpUser user) { @@ -251,7 +251,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati @Override public Set getSubscriptions() { - return new HashSet(this.subscriptions.values()); + return new HashSet<>(this.subscriptions.values()); } void addSubscription(String id, String destination) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java index 2374bc60cec..edfe2a659af 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java @@ -98,7 +98,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE private final StompDecoder stompDecoder = new StompDecoder(); - private final Map decoders = new ConcurrentHashMap(); + private final Map decoders = new ConcurrentHashMap<>(); private MessageHeaderInitializer headerInitializer; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java index 11d81cc308e..abe4d194c51 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java @@ -84,13 +84,13 @@ public class SubProtocolWebSocketHandler private final SubscribableChannel clientOutboundChannel; private final Map protocolHandlerLookup = - new TreeMap(String.CASE_INSENSITIVE_ORDER); + new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - private final Set protocolHandlers = new LinkedHashSet(); + private final Set protocolHandlers = new LinkedHashSet<>(); private SubProtocolHandler defaultProtocolHandler; - private final Map sessions = new ConcurrentHashMap(); + private final Map sessions = new ConcurrentHashMap<>(); private int sendTimeLimit = 10 * 1000; @@ -134,7 +134,7 @@ public class SubProtocolWebSocketHandler } public List getProtocolHandlers() { - return new ArrayList(this.protocolHandlers); + return new ArrayList<>(this.protocolHandlers); } /** @@ -188,7 +188,7 @@ public class SubProtocolWebSocketHandler * Return all supported protocols. */ public List getSubProtocols() { - return new ArrayList(this.protocolHandlerLookup.keySet()); + return new ArrayList<>(this.protocolHandlerLookup.keySet()); } /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java index 9f1c4a69a83..f5419168906 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,7 +92,7 @@ public class WebSocketAnnotationMethodMessageHandler extends SimpAnnotationMetho } public static List createFromList(List beans) { - List result = new ArrayList(beans.size()); + List result = new ArrayList<>(beans.size()); for (ControllerAdviceBean bean : beans) { result.add(new MessagingControllerAdviceBean(bean)); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java index 36235082535..5dca8363391 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/WebSocketStompClient.java @@ -301,7 +301,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif private volatile long lastWriteTime = -1; - private final List> inactivityTasks = new ArrayList>(2); + private final List> inactivityTasks = new ArrayList<>(2); public WebSocketTcpConnectionHandlerAdapter(TcpConnectionHandler connectionHandler) { Assert.notNull(connectionHandler, "TcpConnectionHandler must not be null"); @@ -378,7 +378,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif @Override public ListenableFuture send(Message message) { updateLastWriteTime(); - SettableListenableFuture future = new SettableListenableFuture(); + SettableListenableFuture future = new SettableListenableFuture<>(); try { this.session.sendMessage(this.codec.encode(message, this.session.getClass())); future.set(null); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java index 5e1af044ffc..3b51465af00 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java @@ -66,7 +66,7 @@ import org.springframework.web.socket.server.RequestUpgradeStrategy; public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Lifecycle, ServletContextAware { private static final ThreadLocal wsContainerHolder = - new NamedThreadLocal("WebSocket Handler Container"); + new NamedThreadLocal<>("WebSocket Handler Container"); private final WebSocketServerFactory factory; @@ -126,7 +126,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life } private List getWebSocketExtensions() { - List result = new ArrayList(); + List result = new ArrayList<>(); for (String name : this.factory.getExtensionFactory().getExtensionNames()) { result.add(new WebSocketExtension(name)); } @@ -213,7 +213,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life this.extensionConfigs = null; } else { - this.extensionConfigs = new ArrayList(); + this.extensionConfigs = new ArrayList<>(); for (WebSocketExtension e : extensions) { this.extensionConfigs.add(new WebSocketToJettyExtensionConfigAdapter(e)); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java index 2dd7ff41acc..e7f2c841633 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractStandardUpgradeStrategy.java @@ -91,7 +91,7 @@ public abstract class AbstractStandardUpgradeStrategy implements RequestUpgradeS } protected List getInstalledExtensions(WebSocketContainer container) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (Extension ext : container.getInstalledExtensions()) { result.add(new StandardToWebSocketExtensionAdapter(ext)); } @@ -123,7 +123,7 @@ public abstract class AbstractStandardUpgradeStrategy implements RequestUpgradeS StandardWebSocketSession session = new StandardWebSocketSession(headers, attrs, localAddr, remoteAddr, user); StandardWebSocketHandlerAdapter endpoint = new StandardWebSocketHandlerAdapter(wsHandler, session); - List extensions = new ArrayList(); + List extensions = new ArrayList<>(); for (WebSocketExtension extension : selectedExtensions) { extensions.add(new WebSocketToStandardExtensionAdapter(extension)); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java index 7871e29c7c1..8ffbc5fbc3b 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java @@ -118,7 +118,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda return super.getInstalledExtensions(container); } catch (UnsupportedOperationException ex) { - return new ArrayList(0); + return new ArrayList<>(0); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java index 3e00c274174..37ac65a31ae 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ public class ServerEndpointExporter extends WebApplicationObjectSupport * Actually register the endpoints. Called by {@link #afterSingletonsInstantiated()}. */ protected void registerEndpoints() { - Set> endpointClasses = new LinkedHashSet>(); + Set> endpointClasses = new LinkedHashSet<>(); if (this.annotatedEndpointClasses != null) { endpointClasses.addAll(this.annotatedEndpointClasses); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java index 5e066de54e7..a2afa3a4386 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/ServerEndpointRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,15 +60,15 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato private final Endpoint endpoint; - private List> encoders = new ArrayList>(); + private List> encoders = new ArrayList<>(); - private List> decoders = new ArrayList>(); + private List> decoders = new ArrayList<>(); - private List protocols = new ArrayList(); + private List protocols = new ArrayList<>(); - private List extensions = new ArrayList(); + private List extensions = new ArrayList<>(); - private final Map userProperties = new HashMap(); + private final Map userProperties = new HashMap<>(); /** @@ -81,7 +81,7 @@ public class ServerEndpointRegistration extends ServerEndpointConfig.Configurato Assert.hasText(path, "path must not be empty"); Assert.notNull(endpointClass, "endpointClass must not be null"); this.path = path; - this.endpointProvider = new BeanCreatingHandlerProvider(endpointClass); + this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass); this.endpoint = null; } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java index 5f13d12a497..304459917fd 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/SpringConfigurator.java @@ -55,7 +55,7 @@ public class SpringConfigurator extends Configurator { private static final Log logger = LogFactory.getLog(SpringConfigurator.class); private static final Map, String>> cache = - new ConcurrentHashMap, String>>(); + new ConcurrentHashMap<>(); @SuppressWarnings("unchecked") @@ -102,7 +102,7 @@ public class SpringConfigurator extends Configurator { Map, String> beanNamesByType = cache.get(wacId); if (beanNamesByType == null) { - beanNamesByType = new ConcurrentHashMap, String>(); + beanNamesByType = new ConcurrentHashMap<>(); cache.put(wacId, beanNamesByType); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java index d76ed66d221..4847c115739 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/AbstractHandshakeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -97,7 +97,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life private final RequestUpgradeStrategy requestUpgradeStrategy; - private final List supportedProtocols = new ArrayList(); + private final List supportedProtocols = new ArrayList<>(); private volatile boolean running = false; @@ -386,7 +386,7 @@ public abstract class AbstractHandshakeHandler implements HandshakeHandler, Life protected List filterRequestedExtensions(ServerHttpRequest request, List requestedExtensions, List supportedExtensions) { - List result = new ArrayList(requestedExtensions.size()); + List result = new ArrayList<>(requestedExtensions.size()); for (WebSocketExtension extension : requestedExtensions) { if (supportedExtensions.contains(extension)) { result.add(extension); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptor.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptor.java index 0401a80c3b0..e184aa13302 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptor.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public class OriginHandshakeInterceptor implements HandshakeInterceptor { protected Log logger = LogFactory.getLog(getClass()); - private final Set allowedOrigins = new LinkedHashSet(); + private final Set allowedOrigins = new LinkedHashSet<>(); /** diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java index ae814653d9d..c8ed1d7bb43 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl private final HandshakeHandler handshakeHandler; - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); private volatile boolean running = false; @@ -159,7 +159,7 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler, Lifecycl if (logger.isDebugEnabled()) { logger.debug(servletRequest.getMethod() + " " + servletRequest.getRequestURI()); } - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); if (!chain.applyBeforeHandshake(request, response, attributes)) { return; } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java index c554b7d1662..0c79969b5cb 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractClientSockJsSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ public abstract class AbstractClientSockJsSession implements WebSocketSession { private final SettableListenableFuture connectFuture; - private final Map attributes = new ConcurrentHashMap(); + private final Map attributes = new ConcurrentHashMap<>(); private volatile State state = State.NEW; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java index 18bb0c0e2d0..53828b06f86 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/AbstractXhrTransport.java @@ -95,7 +95,7 @@ public abstract class AbstractXhrTransport implements XhrTransport { @Override public ListenableFuture connect(TransportRequest request, WebSocketHandler handler) { - SettableListenableFuture connectFuture = new SettableListenableFuture(); + SettableListenableFuture connectFuture = new SettableListenableFuture<>(); XhrClientSockJsSession session = new XhrClientSockJsSession(request, handler, this, connectFuture); request.addTimeoutTask(session.getTimeoutTask()); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequest.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequest.java index 99949da1c05..397ceee5865 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequest.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ class DefaultTransportRequest implements TransportRequest { private TaskScheduler timeoutScheduler; - private final List timeoutTasks = new ArrayList(); + private final List timeoutTasks = new ArrayList<>(); private DefaultTransportRequest fallbackRequest; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/JettyXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/JettyXhrTransport.java index e42b65d4ff8..d7fc630d35c 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/JettyXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/JettyXhrTransport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -150,8 +150,8 @@ public class JettyXhrTransport extends AbstractXhrTransport implements Lifecycle HttpStatus status = HttpStatus.valueOf(response.getStatus()); HttpHeaders responseHeaders = toHttpHeaders(response.getHeaders()); return (response.getContent() != null ? - new ResponseEntity(response.getContentAsString(), responseHeaders, status) : - new ResponseEntity(responseHeaders, status)); + new ResponseEntity<>(response.getContentAsString(), responseHeaders, status) : + new ResponseEntity<>(responseHeaders, status)); } private static void addHttpHeaders(Request request, HttpHeaders headers) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java index cab4e6cf48b..e52c2cae6f3 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,11 +153,11 @@ public class RestTemplateXhrTransport extends AbstractXhrTransport { @Override public ResponseEntity extractData(ClientHttpResponse response) throws IOException { if (response.getBody() == null) { - return new ResponseEntity(response.getHeaders(), response.getStatusCode()); + return new ResponseEntity<>(response.getHeaders(), response.getStatusCode()); } else { String body = StreamUtils.copyToString(response.getBody(), SockJsFrame.CHARSET); - return new ResponseEntity(body, response.getHeaders(), response.getStatusCode()); + return new ResponseEntity<>(body, response.getHeaders(), response.getStatusCode()); } } }; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java index 2d34c44b489..47cebcac3b2 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/SockJsClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle { private static final Log logger = LogFactory.getLog(SockJsClient.class); - private static final Set supportedProtocols = new HashSet(4); + private static final Set supportedProtocols = new HashSet<>(4); static { supportedProtocols.add("ws"); @@ -88,7 +88,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle { private volatile boolean running = false; - private final Map serverInfoCache = new ConcurrentHashMap(); + private final Map serverInfoCache = new ConcurrentHashMap<>(); /** @@ -101,7 +101,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle { */ public SockJsClient(List transports) { Assert.notEmpty(transports, "No transports provided"); - this.transports = new ArrayList(transports); + this.transports = new ArrayList<>(transports); this.infoReceiver = initInfoReceiver(transports); if (jackson2Present) { this.messageCodec = new Jackson2SockJsMessageCodec(); @@ -248,7 +248,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle { throw new IllegalArgumentException("Invalid scheme: '" + scheme + "'"); } - SettableListenableFuture connectFuture = new SettableListenableFuture(); + SettableListenableFuture connectFuture = new SettableListenableFuture<>(); try { SockJsUrlInfo sockJsUrlInfo = new SockJsUrlInfo(url); ServerInfo serverInfo = getServerInfo(sockJsUrlInfo, getHttpRequestHeaders(headers)); @@ -292,7 +292,7 @@ public class SockJsClient implements WebSocketClient, Lifecycle { } private DefaultTransportRequest createRequest(SockJsUrlInfo urlInfo, HttpHeaders headers, ServerInfo serverInfo) { - List requests = new ArrayList(this.transports.size()); + List requests = new ArrayList<>(this.transports.size()); for (Transport transport : this.transports) { for (TransportType type : transport.getTransportTypes()) { if (serverInfo.isWebSocketEnabled() || !TransportType.WEBSOCKET.equals(type)) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java index d6a7c5efd8a..e2b91295fdd 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/UndertowXhrTransport.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -264,7 +264,7 @@ public class UndertowXhrTransport extends AbstractXhrTransport { protected ResponseEntity executeRequest(URI url, HttpString method, HttpHeaders headers, String body) { CountDownLatch latch = new CountDownLatch(1); - List responses = new CopyOnWriteArrayList(); + List responses = new CopyOnWriteArrayList<>(); try { ClientConnection connection = @@ -285,8 +285,8 @@ public class UndertowXhrTransport extends AbstractXhrTransport { HttpHeaders responseHeaders = toHttpHeaders(response.getResponseHeaders()); String responseBody = response.getAttachment(RESPONSE_BODY); return (responseBody != null ? - new ResponseEntity(responseBody, responseHeaders, status) : - new ResponseEntity(responseHeaders, status)); + new ResponseEntity<>(responseBody, responseHeaders, status) : + new ResponseEntity<>(responseHeaders, status)); } finally { IoUtils.safeClose(connection); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/WebSocketTransport.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/WebSocketTransport.java index 1a7dc43f3c1..30fbd071c99 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/WebSocketTransport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/client/WebSocketTransport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,7 +74,7 @@ public class WebSocketTransport implements Transport, Lifecycle { @Override public ListenableFuture connect(TransportRequest request, WebSocketHandler handler) { - final SettableListenableFuture future = new SettableListenableFuture(); + final SettableListenableFuture future = new SettableListenableFuture<>(); WebSocketClientSockJsSession session = new WebSocketClientSockJsSession(request, handler, future); handler = new ClientSockJsWebSocketHandler(session); request.addTimeoutTask(session.getTimeoutTask()); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java index 761671febca..887b70df4b3 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,7 +98,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig private boolean suppressCors = false; - protected final Set allowedOrigins = new LinkedHashSet(); + protected final Set allowedOrigins = new LinkedHashSet<>(); public AbstractSockJsService(TaskScheduler scheduler) { @@ -514,7 +514,7 @@ public abstract class AbstractSockJsService implements SockJsService, CorsConfig protected void sendMethodNotAllowed(ServerHttpResponse response, HttpMethod... httpMethods) { logger.warn("Sending Method Not Allowed (405)"); response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED); - response.getHeaders().setAllow(new HashSet(Arrays.asList(httpMethods))); + response.getHeaders().setAllow(new HashSet<>(Arrays.asList(httpMethods))); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java index 79a33b87e1c..4e527e42585 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java @@ -66,13 +66,13 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem "com.fasterxml.jackson.databind.ObjectMapper", TransportHandlingSockJsService.class.getClassLoader()); - private final Map handlers = new HashMap(); + private final Map handlers = new HashMap<>(); private SockJsMessageCodec messageCodec; - private final List interceptors = new ArrayList(); + private final List interceptors = new ArrayList<>(); - private final Map sessions = new ConcurrentHashMap(); + private final Map sessions = new ConcurrentHashMap<>(); private ScheduledFuture sessionCleanupTask; @@ -199,7 +199,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem HandshakeFailureException failure = null; try { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); if (!chain.applyBeforeHandshake(request, response, attributes)) { return; } @@ -266,7 +266,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem SockJsSession session = this.sessions.get(sessionId); if (session == null) { if (transportHandler instanceof SockJsSessionFactory) { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); if (!chain.applyBeforeHandshake(request, response, attributes)) { return; } @@ -362,7 +362,7 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem this.sessionCleanupTask = getTaskScheduler().scheduleAtFixedRate(new Runnable() { @Override public void run() { - List removedIds = new ArrayList(); + List removedIds = new ArrayList<>(); for (SockJsSession session : sessions.values()) { try { if (session.getTimeSinceLastActive() > getDisconnectDelay()) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportType.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportType.java index 78b844240e2..283aa38fb63 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportType.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportType.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public enum TransportType { private static final Map TRANSPORT_TYPES; static { - Map transportTypes = new HashMap(); + Map transportTypes = new HashMap<>(); for (TransportType type : values()) { transportTypes.put(type.value, type); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsService.java index 5f2200e05a3..2b8f7f669f8 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsService.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,7 +79,7 @@ public class DefaultSockJsService extends TransportHandlingSockJsService impleme private static Set getDefaultTransportHandlers(Collection overrides) { - Set result = new LinkedHashSet(8); + Set result = new LinkedHashSet<>(8); result.add(new XhrPollingTransportHandler()); result.add(new XhrReceivingTransportHandler()); result.add(new XhrStreamingTransportHandler()); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandler.java index 41a90c2363a..d2c191812d1 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ public class SockJsWebSocketHandler extends TextWebSocketHandler implements SubP webSocketHandler = WebSocketHandlerDecorator.unwrap(webSocketHandler); this.subProtocols = ((webSocketHandler instanceof SubProtocolCapable) ? - new ArrayList(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : null); + new ArrayList<>(((SubProtocolCapable) webSocketHandler).getSubProtocols()) : null); } @Override diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractHttpSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractHttpSockJsSession.java index 4238cded46a..1623903d6a7 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractHttpSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractHttpSockJsSession.java @@ -84,7 +84,7 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession { WebSocketHandler wsHandler, Map attributes) { super(id, config, wsHandler, attributes); - this.messageCache = new LinkedBlockingQueue(config.getHttpMessageCacheSize()); + this.messageCache = new LinkedBlockingQueue<>(config.getHttpMessageCacheSize()); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java index f2fbadeef5f..1fd069d8116 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.java @@ -81,7 +81,7 @@ public abstract class AbstractSockJsSession implements SockJsSession { private static final Set disconnectedClientExceptions; static { - Set set = new HashSet(2); + Set set = new HashSet<>(2); set.add("ClientAbortException"); // Tomcat set.add("EOFException"); // Tomcat set.add("EofException"); // Jetty @@ -98,7 +98,7 @@ public abstract class AbstractSockJsSession implements SockJsSession { private final WebSocketHandler handler; - private final Map attributes = new ConcurrentHashMap(); + private final Map attributes = new ConcurrentHashMap<>(); private volatile State state = State.NEW; @@ -399,7 +399,7 @@ public abstract class AbstractSockJsSession implements SockJsSession { } public void delegateMessages(String... messages) throws SockJsMessageDeliveryException { - List undelivered = new ArrayList(Arrays.asList(messages)); + List undelivered = new ArrayList<>(Arrays.asList(messages)); for (String message : messages) { try { if (isClosed()) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java index 403b8609f1d..d57d4518ca9 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class WebSocketServerSockJsSession extends AbstractSockJsSession implemen private volatile boolean openFrameSent; - private final Queue initSessionCache = new LinkedBlockingDeque(); + private final Queue initSessionCache = new LinkedBlockingDeque<>(); private final Object initSessionLock = new Object(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java index 7067ef25db0..142e4fb73f8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public abstract class AbstractWebSocketIntegrationTests { protected Log logger = LogFactory.getLog(getClass()); - private static Map, Class> upgradeStrategyConfigTypes = new HashMap, Class>(); + private static Map, Class> upgradeStrategyConfigTypes = new HashMap<>(); static { upgradeStrategyConfigTypes.put(JettyWebSocketTestServer.class, JettyUpgradeStrategyConfig.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java index 824cba62e5c..0d9c93ac71a 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java @@ -198,7 +198,7 @@ public class MessageBrokerBeanDefinitionParserTests { SimpleBrokerMessageHandler brokerMessageHandler = this.appContext.getBean(SimpleBrokerMessageHandler.class); assertNotNull(brokerMessageHandler); Collection prefixes = brokerMessageHandler.getDestinationPrefixes(); - assertEquals(Arrays.asList("/topic", "/queue"), new ArrayList(prefixes)); + assertEquals(Arrays.asList("/topic", "/queue"), new ArrayList<>(prefixes)); assertNotNull(brokerMessageHandler.getTaskScheduler()); assertArrayEquals(new long[] {15000, 15000}, brokerMessageHandler.getHeartbeatValue()); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java index 553e191438f..7acd269b92f 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class BeanCreatingHandlerProviderTests { public void getHandlerSimpleInstantiation() { BeanCreatingHandlerProvider provider = - new BeanCreatingHandlerProvider(SimpleEchoHandler.class); + new BeanCreatingHandlerProvider<>(SimpleEchoHandler.class); assertNotNull(provider.getHandler()); } @@ -51,7 +51,7 @@ public class BeanCreatingHandlerProviderTests { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.class); BeanCreatingHandlerProvider provider = - new BeanCreatingHandlerProvider(EchoHandler.class); + new BeanCreatingHandlerProvider<>(EchoHandler.class); provider.setBeanFactory(context.getBeanFactory()); assertNotNull(provider.getHandler()); @@ -61,7 +61,7 @@ public class BeanCreatingHandlerProviderTests { public void getHandlerNoBeanFactory() { BeanCreatingHandlerProvider provider = - new BeanCreatingHandlerProvider(EchoHandler.class); + new BeanCreatingHandlerProvider<>(EchoHandler.class); provider.getHandler(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/TestWebSocketSession.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/TestWebSocketSession.java index cee12e85aae..729b9256549 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/TestWebSocketSession.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/TestWebSocketSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ public class TestWebSocketSession implements WebSocketSession { private URI uri; - private Map attributes = new HashMap(); + private Map attributes = new HashMap<>(); private Principal principal; @@ -52,7 +52,7 @@ public class TestWebSocketSession implements WebSocketSession { private String protocol; - private List extensions = new ArrayList(); + private List extensions = new ArrayList<>(); private boolean open; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java index e219072d63a..d65ba2f60a7 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public class WebSocketHttpHeadersTests { @Test public void parseWebSocketExtensions() { - List extensions = new ArrayList(); + List extensions = new ArrayList<>(); extensions.add("x-foo-extension, x-bar-extension"); extensions.add("x-test-extension"); this.headers.put(WebSocketHttpHeaders.SEC_WEBSOCKET_EXTENSIONS, extensions); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java index 22214eafab3..73e6f1d2847 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -468,7 +468,7 @@ public class StompSubProtocolHandlerTests { private static class TestPublisher implements ApplicationEventPublisher { - private final List events = new ArrayList(); + private final List events = new ArrayList<>(); @Override public void publishEvent(ApplicationEvent event) { @@ -477,7 +477,7 @@ public class StompSubProtocolHandlerTests { @Override public void publishEvent(Object event) { - publishEvent(new PayloadApplicationEvent(this, event)); + publishEvent(new PayloadApplicationEvent<>(this, event)); } } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompTextMessageBuilder.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompTextMessageBuilder.java index c65ba91df37..14a4868fc68 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompTextMessageBuilder.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompTextMessageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ public class StompTextMessageBuilder { private StompCommand command; - private final List headerLines = new ArrayList(); + private final List headerLines = new ArrayList<>(); private String body; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java index 157815dad34..21a0b87e43b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ public class HandshakeInterceptorChainTests extends AbstractHttpRequestTests { i3 = mock(HandshakeInterceptor.class); interceptors = Arrays.asList(i1, i2, i3); wsHandler = mock(WebSocketHandler.class); - attributes = new HashMap(); + attributes = new HashMap<>(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java index 3533d2fdd5c..d99d82675a4 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes @Test public void defaultConstructor() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.setSession(new MockHttpSession(null, "123")); @@ -58,7 +58,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes @Test public void constructorWithAttributeNames() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.setSession(new MockHttpSession(null, "123")); @@ -76,7 +76,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes @Test public void doNotCopyHttpSessionId() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.setSession(new MockHttpSession(null, "123")); @@ -93,7 +93,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes @Test public void doNotCopyAttributes() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.setSession(new MockHttpSession(null, "123")); @@ -109,7 +109,7 @@ public class HttpSessionHandshakeInterceptorTests extends AbstractHttpRequestTes @Test public void doNotCauseSessionCreation() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java index 03177e288fb..3f711738076 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void originValueMatch() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com"); List allowed = Collections.singletonList("http://mydomain1.com"); @@ -58,7 +58,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void originValueNoMatch() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com"); List allowed = Collections.singletonList("http://mydomain2.com"); @@ -69,7 +69,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void originListMatch() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com"); List allowed = Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"); @@ -80,7 +80,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void originListNoMatch() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain4.com"); List allowed = Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"); @@ -91,11 +91,11 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void originNoMatchWithNullHostileCollection() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain4.com"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(); - Set allowedOrigins = new ConcurrentSkipListSet(); + Set allowedOrigins = new ConcurrentSkipListSet<>(); allowedOrigins.add("http://mydomain1.com"); interceptor.setAllowedOrigins(allowedOrigins); assertFalse(interceptor.beforeHandshake(request, response, wsHandler, attributes)); @@ -104,7 +104,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void originMatchAll() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(); @@ -115,7 +115,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void sameOriginMatchWithEmptyAllowedOrigins() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com"); this.servletRequest.setServerName("mydomain2.com"); @@ -126,7 +126,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void sameOriginMatchWithAllowedOrigins() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com"); this.servletRequest.setServerName("mydomain2.com"); @@ -137,7 +137,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests { @Test public void sameOriginNoMatch() throws Exception { - Map attributes = new HashMap(); + Map attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain3.com"); this.servletRequest.setServerName("mydomain2.com"); diff --git a/src/test/java/com/foo/Component.java b/src/test/java/com/foo/Component.java index 759954c41db..e9670901c6f 100644 --- a/src/test/java/com/foo/Component.java +++ b/src/test/java/com/foo/Component.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import java.util.List; public class Component { private String name; - private List components = new ArrayList(); + private List components = new ArrayList<>(); // mmm, there is no setter method for the 'components' public void addComponent(Component component) { diff --git a/src/test/java/com/foo/ComponentBeanDefinitionParser.java b/src/test/java/com/foo/ComponentBeanDefinitionParser.java index 9fb2213c2bb..24b3149e044 100644 --- a/src/test/java/com/foo/ComponentBeanDefinitionParser.java +++ b/src/test/java/com/foo/ComponentBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class ComponentBeanDefinitionParser extends AbstractBeanDefinitionParser private static void parseChildComponents(List childElements, BeanDefinitionBuilder factory) { - ManagedList children = new ManagedList( + ManagedList children = new ManagedList<>( childElements.size()); for (Element element : childElements) { children.add(parseComponentElement(element)); diff --git a/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java b/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java index 5fe702c3bee..3d4ec22e61f 100644 --- a/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java +++ b/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,17 +36,17 @@ public class Spr7538Tests { StandardEvaluationContext context = new StandardEvaluationContext(); context.setTypeConverter(converter); - List arguments = new ArrayList(); + List arguments = new ArrayList<>(); // !!!! With the below line commented you'll get NPE. Uncomment and everything is OK! //arguments.add(new Foo()); - List paramDescriptors = new ArrayList(); + List paramDescriptors = new ArrayList<>(); Method method = AlwaysTrueReleaseStrategy.class.getMethod("checkCompleteness", List.class); paramDescriptors.add(new TypeDescriptor(new MethodParameter(method, 0))); - List argumentTypes = new ArrayList(); + List argumentTypes = new ArrayList<>(); argumentTypes.add(TypeDescriptor.forObject(arguments)); ReflectiveMethodResolver resolver = new ReflectiveMethodResolver(); MethodExecutor executor = resolver.resolve(context, target, "checkCompleteness", argumentTypes); diff --git a/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java b/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java index 765fffc2c2b..fde5359d9a4 100644 --- a/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java +++ b/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -186,7 +186,7 @@ public class EnableTransactionManagementIntegrationTests { @Bean public CacheManager cacheManager() { SimpleCacheManager mgr = new SimpleCacheManager(); - ArrayList caches = new ArrayList(); + ArrayList caches = new ArrayList<>(); caches.add(new ConcurrentMapCache("")); mgr.setCaches(caches); return mgr;