Explicit type can be replaced by <>

Issue: SPR-13188
This commit is contained in:
Stephane Nicoll
2016-07-05 17:00:26 +02:00
parent 3096888c7d
commit 00d2606b00
1044 changed files with 3972 additions and 3893 deletions

View File

@@ -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<Expression> expressions = new LinkedList<Expression>();
List<Expression> 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<Bracket> stack = new Stack<Bracket>();
Stack<Bracket> stack = new Stack<>();
while (pos < maxlen) {
if (isSuffixHere(expressionString, pos, suffix) && stack.isEmpty()) {
break;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<ArrayList<String>>();
this.compilationScopes.add(new ArrayList<String>());
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<String>());
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<FieldAdder>();
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<ClinitAdder>();
clinitAdders = new ArrayList<>();
}
clinitAdders.add(clinitAdder);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<VariableScope>();
this.variableScopes = new Stack<>();
// top level empty variable scope
this.variableScopes.add(new VariableScope());
}
if (this.scopeRootObjects == null) {
this.scopeRootObjects = new Stack<TypedValue>();
this.scopeRootObjects = new Stack<>();
}
}
@@ -113,14 +113,14 @@ public class ExpressionState {
public void pushActiveContextObject(TypedValue obj) {
if (this.contextObjects == null) {
this.contextObjects = new Stack<TypedValue>();
this.contextObjects = new Stack<>();
}
this.contextObjects.push(obj);
}
public void popActiveContextObject() {
if (this.contextObjects == null) {
this.contextObjects = new Stack<TypedValue>();
this.contextObjects = new Stack<>();
}
this.contextObjects.pop();
}
@@ -250,7 +250,7 @@ public class ExpressionState {
*/
private static class VariableScope {
private final Map<String, Object> vars = new HashMap<String, Object>();
private final Map<String, Object> vars = new HashMap<>();
public VariableScope() {
}

View File

@@ -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<PropertyAccessor> getPropertyAccessorsToTry(
Class<?> targetType, List<PropertyAccessor> propertyAccessors) {
List<PropertyAccessor> specificAccessors = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> generalAccessors = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> specificAccessors = new ArrayList<>();
List<PropertyAccessor> 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<PropertyAccessor> resolvers = new LinkedList<PropertyAccessor>();
List<PropertyAccessor> resolvers = new LinkedList<>();
resolvers.addAll(specificAccessors);
resolvers.addAll(generalAccessors);
return resolvers;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<TypeDescriptor> argumentTypes = new ArrayList<TypeDescriptor>(getChildCount() - 1);
List<TypeDescriptor> 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();

View File

@@ -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<Object> constantList = new ArrayList<Object>();
List<Object> 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<Object> returnValue = new ArrayList<Object>();
List<Object> returnValue = new ArrayList<>();
int childCount = getChildCount();
for (int c = 0; c < childCount; c++) {
returnValue.add(getChild(c).getValue(expressionState));

View File

@@ -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<Object,Object> constantMap = new LinkedHashMap<Object,Object>();
Map<Object,Object> 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<Object, Object> returnValue = new LinkedHashMap<Object, Object>();
Map<Object, Object> returnValue = new LinkedHashMap<>();
int childcount = getChildCount();
for (int c = 0; c < childcount; c++) {
// TODO allow for key being PropertyOrFieldReference like Indexer on maps

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<TypeDescriptor> getArgumentTypes(Object... arguments) {
List<TypeDescriptor> descriptors = new ArrayList<TypeDescriptor>(arguments.length);
List<TypeDescriptor> descriptors = new ArrayList<>(arguments.length);
for (Object argument : arguments) {
descriptors.add(TypeDescriptor.forObject(argument));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<String, Pattern> patternCache = new ConcurrentHashMap<String, Pattern>();
private final ConcurrentMap<String, Pattern> patternCache = new ConcurrentHashMap<>();
public OperatorMatches(int pos, SpelNodeImpl... operands) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<Object> result = new ArrayList<Object>();
List<Object> 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<Object> result = new ArrayList<Object>();
List<Object> result = new ArrayList<>();
int idx = 0;
Class<?> arrayElementType = null;
for (Object element : data) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<PropertyAccessor> getPropertyAccessorsToTry(Object contextObject, List<PropertyAccessor> propertyAccessors) {
Class<?> targetType = (contextObject != null ? contextObject.getClass() : null);
List<PropertyAccessor> specificAccessors = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> generalAccessors = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> specificAccessors = new ArrayList<>();
List<PropertyAccessor> generalAccessors = new ArrayList<>();
for (PropertyAccessor resolver : propertyAccessors) {
Class<?>[] targets = resolver.getSpecificTargetClasses();
if (targets == null) {
@@ -326,7 +326,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
}
}
}
List<PropertyAccessor> resolvers = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> resolvers = new ArrayList<>();
resolvers.addAll(specificAccessors);
generalAccessors.removeAll(specificAccessors);
resolvers.addAll(generalAccessors);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<Object, Object> result = new HashMap<Object, Object>();
Map<Object, Object> 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<Object, Object> resultMap = new HashMap<Object, Object>();
Map<Object, Object> 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<Object> result = new ArrayList<Object>();
List<Object> result = new ArrayList<>();
int index = 0;
for (Object element : data) {
try {

View File

@@ -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<SpelNodeImpl> constructedNodes = new Stack<SpelNodeImpl>();
private final Stack<SpelNodeImpl> 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<SpelNodeImpl> nodes = new ArrayList<SpelNodeImpl>();
List<SpelNodeImpl> 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<SpelNodeImpl> args = new ArrayList<SpelNodeImpl>();
List<SpelNodeImpl> 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<SpelNodeImpl> listElements = new ArrayList<SpelNodeImpl>();
List<SpelNodeImpl> 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<SpelNodeImpl> listElements = new ArrayList<SpelNodeImpl>();
List<SpelNodeImpl> 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<SpelNodeImpl> mapElements = new ArrayList<SpelNodeImpl>();
List<SpelNodeImpl> 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<SpelNodeImpl> qualifiedIdPieces = new LinkedList<SpelNodeImpl>();
LinkedList<SpelNodeImpl> qualifiedIdPieces = new LinkedList<>();
Token node = peekToken();
while (isValidQualifiedId(node)) {
nextToken();
@@ -774,11 +774,11 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
return true;
}
SpelNodeImpl possiblyQualifiedConstructorName = eatPossiblyQualifiedId();
List<SpelNodeImpl> nodes = new ArrayList<SpelNodeImpl>();
List<SpelNodeImpl> nodes = new ArrayList<>();
nodes.add(possiblyQualifiedConstructorName);
if (peekToken(TokenKind.LSQUARE)) {
// array initializer
List<SpelNodeImpl> dimensions = new ArrayList<SpelNodeImpl>();
List<SpelNodeImpl> dimensions = new ArrayList<>();
while (peekToken(TokenKind.LSQUARE,true)) {
if (!peekToken(TokenKind.RSQUARE)) {
dimensions.add(eatExpression());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<ClassLoader, SpelCompiler> compilers =
new ConcurrentReferenceHashMap<ClassLoader, SpelCompiler>();
new ConcurrentReferenceHashMap<>();
// The child ClassLoader used to load the compiled expression classes

View File

@@ -73,7 +73,7 @@ class Tokenizer {
int max;
List<Token> tokens = new ArrayList<Token>();
List<Token> tokens = new ArrayList<>();
public Tokenizer(String inputData) {

View File

@@ -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<TypeDescriptor> paramDescriptors = new ArrayList<TypeDescriptor>(paramTypes.length);
List<TypeDescriptor> paramDescriptors = new ArrayList<>(paramTypes.length);
for (int i = 0; i < paramTypes.length; i++) {
paramDescriptors.add(new TypeDescriptor(new MethodParameter(ctor, i)));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<Class<?>, 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<Method> methods = new ArrayList<Method>(getMethods(type, targetObject));
List<Method> 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<Method> filtered = filter.filter(methods);
methods = (filtered instanceof ArrayList ? filtered : new ArrayList<Method>(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<Method> methodsToIterate = new LinkedHashSet<Method>(methods);
Set<Method> 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<TypeDescriptor> paramDescriptors = new ArrayList<TypeDescriptor>(paramTypes.length);
List<TypeDescriptor> 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<Method> getMethods(Class<?> type, Object targetObject) {
if (targetObject instanceof Class) {
Set<Method> result = new LinkedHashSet<Method>();
Set<Method> 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) {

View File

@@ -62,7 +62,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
private static final Set<Class<?>> BOOLEAN_TYPES;
static {
Set<Class<?>> booleanTypes = new HashSet<Class<?>>();
Set<Class<?>> 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<PropertyCacheKey, InvokerPair> readerCache =
new ConcurrentHashMap<PropertyCacheKey, InvokerPair>(64);
new ConcurrentHashMap<>(64);
private final Map<PropertyCacheKey, Member> writerCache =
new ConcurrentHashMap<PropertyCacheKey, Member>(64);
new ConcurrentHashMap<>(64);
private final Map<PropertyCacheKey, TypeDescriptor> typeDescriptorCache =
new ConcurrentHashMap<PropertyCacheKey, TypeDescriptor>(64);
new ConcurrentHashMap<>(64);
private InvokerPair lastReadInvokerPair;

View File

@@ -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<String, Object> variables = new HashMap<String, Object>();
private final Map<String, Object> variables = new HashMap<>();
public StandardEvaluationContext() {
@@ -252,7 +252,7 @@ public class StandardEvaluationContext implements EvaluationContext {
private synchronized void initializePropertyAccessors() {
if (this.propertyAccessors == null) {
List<PropertyAccessor> defaultAccessors = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> 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<MethodResolver> defaultResolvers = new ArrayList<MethodResolver>();
List<MethodResolver> 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<ConstructorResolver> defaultResolvers = new ArrayList<ConstructorResolver>();
List<ConstructorResolver> defaultResolvers = new ArrayList<>();
defaultResolvers.add(new ReflectiveConstructorResolver());
this.constructorResolvers = defaultResolvers;
}

View File

@@ -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<String> knownPackagePrefixes = new LinkedList<String>();
private final List<String> knownPackagePrefixes = new LinkedList<>();
/**

View File

@@ -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<ConstructorResolver> copy = new ArrayList<ConstructorResolver>();
List<ConstructorResolver> copy = new ArrayList<>();
copy.addAll(ctx.getConstructorResolvers());
assertTrue(ctx.removeConstructorResolver(dummy));
assertFalse(ctx.removeConstructorResolver(dummy));

View File

@@ -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<MethodResolver> customResolvers = new ArrayList<MethodResolver>();
List<MethodResolver> 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<String>();
listOfStrings = new ArrayList<>();
listOfStrings.add("abc");
}

View File

@@ -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<Integer> primes = new ArrayList<Integer>();
List<Integer> 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<String,Color> propertyMap = new HashMap<String,Color>();
private static Map<String,Color> 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<String,Color> propertyMap = new HashMap<String,Color>();
private static Map<String,Color> propertyMap = new HashMap<>();
static {
propertyMap.put("carrot",Color.orange);

View File

@@ -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<String,Object> m = new HashMap<String,Object>();
Map<String,Object> m = new HashMap<>();
m.put("foo",34);
m.put("goo","abc");

View File

@@ -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<String> listOfString = new ArrayList<String>();
private static List<String> listOfString = new ArrayList<>();
private static TypeDescriptor typeDescriptorForListOfString = null;
private static List<Integer> listOfInteger = new ArrayList<Integer>();
private static List<Integer> listOfInteger = new ArrayList<>();
private static TypeDescriptor typeDescriptorForListOfInteger = null;
static {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<String, String> property = new HashMap<String, String>();
Map<String, String> 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<String, Map<String, String>> property = new HashMap<String, Map<String, String>>();
Map<String, String> map = new HashMap<String, String>();
Map<String, Map<String, String>> property = new HashMap<>();
Map<String, String> 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<String, String> property = new HashMap<String, String>();
Map<String, String> 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<Integer, Integer> property = new HashMap<Integer, Integer>();
Map<Integer, Integer> 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<String> property = new ArrayList<String>();
List<String> 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<Integer> property = new ArrayList<Integer>();
List<Integer> 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<Integer> property = new ArrayList<Integer>();
List<Integer> 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<Integer> property = new ArrayList<Integer>();
List<Integer> 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<List<Integer>> property = new ArrayList<List<Integer>>();
List<List<Integer>> 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<Integer> property = new ArrayList<Integer>();
List<Integer> 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<String> property = new ArrayList<String>();
List<String> 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<String> property2 = new ArrayList<String>();
List<String> property2 = new ArrayList<>();
this.property2 = property2;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);

View File

@@ -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<Object>()).getClass();
Class<?> unmodifiableClass = Collections.unmodifiableList(new ArrayList<>()).getClass();
@Test

View File

@@ -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<String,String> props1 = new HashMap<String,String>();
Map<String,String> 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<String, String> map = new HashMap<String, String>();
Map<String, String> 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<String, String> map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("key", "value");
EvaluationContext context = new StandardEvaluationContext(map);

View File

@@ -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<Object,Object>()).getClass();
Class<?> unmodifiableClass = Collections.unmodifiableMap(new LinkedHashMap<>()).getClass();
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<MethodResolver> copy = new ArrayList<MethodResolver>();
List<MethodResolver> 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<Method> filter(List<Method> methods) {
filterCalled = true;
List<Method> forRemoval = new ArrayList<Method>();
List<Method> forRemoval = new ArrayList<>();
for (Method method: methods) {
if (removeIfNotAnnotated && !isAnnotated(method)) {
forRemoval.add(method);

View File

@@ -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<PropertyAccessor> copy = new ArrayList<PropertyAccessor>();
List<PropertyAccessor> copy = new ArrayList<>();
copy.addAll(ctx.getPropertyAccessors());
assertTrue(ctx.removePropertyAccessor(spa));
assertFalse(ctx.removePropertyAccessor(spa));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<Integer> integers = new ArrayList<Integer>();
private final List<Integer> integers = new ArrayList<>();
ListTestBean() {
for (int i = 0; i < 10; i++) {
@@ -308,7 +308,7 @@ public class SelectionAndProjectionTests {
static class SetTestBean {
private final Set<Integer> integers = new LinkedHashSet<Integer>();
private final Set<Integer> integers = new LinkedHashSet<>();
SetTestBean() {
for (int i = 0; i < 10; i++) {
@@ -324,7 +324,7 @@ public class SelectionAndProjectionTests {
static class IterableTestBean {
private final Set<Integer> integers = new LinkedHashSet<Integer>();
private final Set<Integer> integers = new LinkedHashSet<>();
IterableTestBean() {
for (int i = 0; i < 10; i++) {
@@ -368,7 +368,7 @@ public class SelectionAndProjectionTests {
static class MapTestBean {
private final Map<String, String> colors = new TreeMap<String, String>();
private final Map<String, String> colors = new TreeMap<>();
MapTestBean() {
// colors.put("black", "schwarz");
@@ -398,7 +398,7 @@ public class SelectionAndProjectionTests {
}
static List<IntegerTestBean> createList() {
List<IntegerTestBean> list = new ArrayList<IntegerTestBean>();
List<IntegerTestBean> 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<IntegerTestBean> createSet() {
Set<IntegerTestBean> set = new LinkedHashSet<IntegerTestBean>();
Set<IntegerTestBean> set = new LinkedHashSet<>();
for (int i = 0; i < 3; i++) {
set.add(new IntegerTestBean(i + 5));
}

View File

@@ -198,7 +198,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
assertCanCompile(expression);
assertEquals(false,expression.getValue());
List<String> list = new ArrayList<String>();
List<String> 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<Integer>(4),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper<Integer>(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<Integer>(4),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper<Integer>(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<String, String> m = new HashMap<String,String>();
Map<String, String> 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<String> strings = new ArrayList<String>();
List<String> 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<Integer> ints = new ArrayList<Integer>();
List<Integer> 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<String,Integer> map1 = new HashMap<String,Integer>();
Map<String,Integer> 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<String[]> listOfStringArrays = new ArrayList<String[]>();
List<String[]> 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<Integer[]> listOfIntegerArrays = new ArrayList<Integer[]>();
List<Integer[]> 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<String>[] stringArrayOfLists = new ArrayList[2];
stringArrayOfLists[0] = new ArrayList<String>();
stringArrayOfLists[0] = new ArrayList<>();
stringArrayOfLists[0].add("a");
stringArrayOfLists[0].add("b");
stringArrayOfLists[0].add("c");
stringArrayOfLists[1] = new ArrayList<String>();
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<List<String>> listOfListOfStrings = new ArrayList<List<String>>();
List<String> list = new ArrayList<String>();
List<List<String>> listOfListOfStrings = new ArrayList<>();
List<String> list = new ArrayList<>();
list.add("a");
list.add("b");
list.add("c");
listOfListOfStrings.add(list);
list = new ArrayList<String>();
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<String,List<String>> mapToLists = new HashMap<String,List<String>>();
list = new ArrayList<String>();
Map<String,List<String>> 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<String,int[]> mapToIntArray = new HashMap<String,int[]>();
Map<String,int[]> 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<String,String>[] mapArray = new Map[1];
mapArray[0] = new HashMap<String,String>();
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<Integer>(4),Boolean.class));
assertTrue(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class));
assertCanCompile(expression);
assertFalse(expression.getValue(new GenericMessageTestHelper<Integer>(2),Boolean.class));
assertFalse(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class));
expression = parser.parseExpression("2!=payload");
assertTrue(expression.getValue(new GenericMessageTestHelper<Integer>(4),Boolean.class));
assertTrue(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class));
assertCanCompile(expression);
assertFalse(expression.getValue(new GenericMessageTestHelper<Integer>(2),Boolean.class));
assertFalse(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class));
expression = parser.parseExpression("payload!=6L");
assertTrue(expression.getValue(new GenericMessageTestHelper<Long>(4L),Boolean.class));
assertTrue(expression.getValue(new GenericMessageTestHelper<>(4L),Boolean.class));
assertCanCompile(expression);
assertFalse(expression.getValue(new GenericMessageTestHelper<Long>(6L),Boolean.class));
assertFalse(expression.getValue(new GenericMessageTestHelper<>(6L),Boolean.class));
expression = parser.parseExpression("payload==2");
assertFalse(expression.getValue(new GenericMessageTestHelper<Integer>(4),Boolean.class));
assertFalse(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper<Integer>(2),Boolean.class));
assertTrue(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class));
expression = parser.parseExpression("2==payload");
assertFalse(expression.getValue(new GenericMessageTestHelper<Integer>(4),Boolean.class));
assertFalse(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper<Integer>(2),Boolean.class));
assertTrue(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class));
expression = parser.parseExpression("payload==6L");
assertFalse(expression.getValue(new GenericMessageTestHelper<Long>(4L),Boolean.class));
assertFalse(expression.getValue(new GenericMessageTestHelper<>(4L),Boolean.class));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper<Long>(6L),Boolean.class));
assertTrue(expression.getValue(new GenericMessageTestHelper<>(6L),Boolean.class));
expression = parser.parseExpression("2==payload");
assertFalse(expression.getValue(new GenericMessageTestHelper<Integer>(4),Boolean.class));
assertFalse(expression.getValue(new GenericMessageTestHelper<>(4),Boolean.class));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper<Integer>(2),Boolean.class));
assertTrue(expression.getValue(new GenericMessageTestHelper<>(2),Boolean.class));
expression = parser.parseExpression("payload/2");
assertEquals(2,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(2,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(3,expression.getValue(new GenericMessageTestHelper<Integer>(6)));
assertEquals(3,expression.getValue(new GenericMessageTestHelper<>(6)));
expression = parser.parseExpression("100/payload");
assertEquals(25,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(25,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(10,expression.getValue(new GenericMessageTestHelper<Integer>(10)));
assertEquals(10,expression.getValue(new GenericMessageTestHelper<>(10)));
expression = parser.parseExpression("payload+2");
assertEquals(6,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(6,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(8,expression.getValue(new GenericMessageTestHelper<Integer>(6)));
assertEquals(8,expression.getValue(new GenericMessageTestHelper<>(6)));
expression = parser.parseExpression("100+payload");
assertEquals(104,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(104,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(110,expression.getValue(new GenericMessageTestHelper<Integer>(10)));
assertEquals(110,expression.getValue(new GenericMessageTestHelper<>(10)));
expression = parser.parseExpression("payload-2");
assertEquals(2,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(2,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(4,expression.getValue(new GenericMessageTestHelper<Integer>(6)));
assertEquals(4,expression.getValue(new GenericMessageTestHelper<>(6)));
expression = parser.parseExpression("100-payload");
assertEquals(96,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(96,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(90,expression.getValue(new GenericMessageTestHelper<Integer>(10)));
assertEquals(90,expression.getValue(new GenericMessageTestHelper<>(10)));
expression = parser.parseExpression("payload*2");
assertEquals(8,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(8,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(12,expression.getValue(new GenericMessageTestHelper<Integer>(6)));
assertEquals(12,expression.getValue(new GenericMessageTestHelper<>(6)));
expression = parser.parseExpression("100*payload");
assertEquals(400,expression.getValue(new GenericMessageTestHelper<Integer>(4)));
assertEquals(400,expression.getValue(new GenericMessageTestHelper<>(4)));
assertCanCompile(expression);
assertEquals(1000,expression.getValue(new GenericMessageTestHelper<Integer>(10)));
assertEquals(1000,expression.getValue(new GenericMessageTestHelper<>(10)));
expression = parser.parseExpression("payload/2L");
assertEquals(2L,expression.getValue(new GenericMessageTestHelper<Long>(4L)));
assertEquals(2L,expression.getValue(new GenericMessageTestHelper<>(4L)));
assertCanCompile(expression);
assertEquals(3L,expression.getValue(new GenericMessageTestHelper<Long>(6L)));
assertEquals(3L,expression.getValue(new GenericMessageTestHelper<>(6L)));
expression = parser.parseExpression("100L/payload");
assertEquals(25L,expression.getValue(new GenericMessageTestHelper<Long>(4L)));
assertEquals(25L,expression.getValue(new GenericMessageTestHelper<>(4L)));
assertCanCompile(expression);
assertEquals(10L,expression.getValue(new GenericMessageTestHelper<Long>(10L)));
assertEquals(10L,expression.getValue(new GenericMessageTestHelper<>(10L)));
expression = parser.parseExpression("payload/2f");
assertEquals(2f,expression.getValue(new GenericMessageTestHelper<Float>(4f)));
assertEquals(2f,expression.getValue(new GenericMessageTestHelper<>(4f)));
assertCanCompile(expression);
assertEquals(3f,expression.getValue(new GenericMessageTestHelper<Float>(6f)));
assertEquals(3f,expression.getValue(new GenericMessageTestHelper<>(6f)));
expression = parser.parseExpression("100f/payload");
assertEquals(25f,expression.getValue(new GenericMessageTestHelper<Float>(4f)));
assertEquals(25f,expression.getValue(new GenericMessageTestHelper<>(4f)));
assertCanCompile(expression);
assertEquals(10f,expression.getValue(new GenericMessageTestHelper<Float>(10f)));
assertEquals(10f,expression.getValue(new GenericMessageTestHelper<>(10f)));
expression = parser.parseExpression("payload/2d");
assertEquals(2d,expression.getValue(new GenericMessageTestHelper<Double>(4d)));
assertEquals(2d,expression.getValue(new GenericMessageTestHelper<>(4d)));
assertCanCompile(expression);
assertEquals(3d,expression.getValue(new GenericMessageTestHelper<Double>(6d)));
assertEquals(3d,expression.getValue(new GenericMessageTestHelper<>(6d)));
expression = parser.parseExpression("100d/payload");
assertEquals(25d,expression.getValue(new GenericMessageTestHelper<Double>(4d)));
assertEquals(25d,expression.getValue(new GenericMessageTestHelper<>(4d)));
assertCanCompile(expression);
assertEquals(10d,expression.getValue(new GenericMessageTestHelper<Double>(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<Integer>(4)));
assertEquals(2,expression.getValue(new GenericMessageTestHelper2<>(4)));
assertCanCompile(expression);
assertEquals(3,expression.getValue(new GenericMessageTestHelper2<Integer>(6)));
assertEquals(3,expression.getValue(new GenericMessageTestHelper2<>(6)));
expression = parser.parseExpression("9/payload");
assertEquals(1,expression.getValue(new GenericMessageTestHelper2<Integer>(9)));
assertEquals(1,expression.getValue(new GenericMessageTestHelper2<>(9)));
assertCanCompile(expression);
assertEquals(3,expression.getValue(new GenericMessageTestHelper2<Integer>(3)));
assertEquals(3,expression.getValue(new GenericMessageTestHelper2<>(3)));
expression = parser.parseExpression("payload+2");
assertEquals(6,expression.getValue(new GenericMessageTestHelper2<Integer>(4)));
assertEquals(6,expression.getValue(new GenericMessageTestHelper2<>(4)));
assertCanCompile(expression);
assertEquals(8,expression.getValue(new GenericMessageTestHelper2<Integer>(6)));
assertEquals(8,expression.getValue(new GenericMessageTestHelper2<>(6)));
expression = parser.parseExpression("100+payload");
assertEquals(104,expression.getValue(new GenericMessageTestHelper2<Integer>(4)));
assertEquals(104,expression.getValue(new GenericMessageTestHelper2<>(4)));
assertCanCompile(expression);
assertEquals(110,expression.getValue(new GenericMessageTestHelper2<Integer>(10)));
assertEquals(110,expression.getValue(new GenericMessageTestHelper2<>(10)));
expression = parser.parseExpression("payload-2");
assertEquals(2,expression.getValue(new GenericMessageTestHelper2<Integer>(4)));
assertEquals(2,expression.getValue(new GenericMessageTestHelper2<>(4)));
assertCanCompile(expression);
assertEquals(4,expression.getValue(new GenericMessageTestHelper2<Integer>(6)));
assertEquals(4,expression.getValue(new GenericMessageTestHelper2<>(6)));
expression = parser.parseExpression("100-payload");
assertEquals(96,expression.getValue(new GenericMessageTestHelper2<Integer>(4)));
assertEquals(96,expression.getValue(new GenericMessageTestHelper2<>(4)));
assertCanCompile(expression);
assertEquals(90,expression.getValue(new GenericMessageTestHelper2<Integer>(10)));
assertEquals(90,expression.getValue(new GenericMessageTestHelper2<>(10)));
expression = parser.parseExpression("payload*2");
assertEquals(8,expression.getValue(new GenericMessageTestHelper2<Integer>(4)));
assertEquals(8,expression.getValue(new GenericMessageTestHelper2<>(4)));
assertCanCompile(expression);
assertEquals(12,expression.getValue(new GenericMessageTestHelper2<Integer>(6)));
assertEquals(12,expression.getValue(new GenericMessageTestHelper2<>(6)));
expression = parser.parseExpression("100*payload");
assertEquals(400,expression.getValue(new GenericMessageTestHelper2<Integer>(4)));
assertEquals(400,expression.getValue(new GenericMessageTestHelper2<>(4)));
assertCanCompile(expression);
assertEquals(1000,expression.getValue(new GenericMessageTestHelper2<Integer>(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<Integer>(4),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(4),Boolean.TYPE));
assertCanCompile(expression);
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
expression = parser.parseExpression("2 >= payload");
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(5),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(5),Boolean.TYPE));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
expression = parser.parseExpression("payload > 2");
assertTrue(expression.getValue(new GenericMessageTestHelper2<Integer>(4),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(4),Boolean.TYPE));
assertCanCompile(expression);
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
expression = parser.parseExpression("2 > payload");
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(5),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(5),Boolean.TYPE));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
expression = parser.parseExpression("payload <=2");
assertTrue(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
assertCanCompile(expression);
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(6),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE));
expression = parser.parseExpression("2 <= payload");
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper2<Integer>(6),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE));
expression = parser.parseExpression("payload < 2");
assertTrue(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
assertCanCompile(expression);
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(6),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE));
expression = parser.parseExpression("2 < payload");
assertFalse(expression.getValue(new GenericMessageTestHelper2<Integer>(1),Boolean.TYPE));
assertFalse(expression.getValue(new GenericMessageTestHelper2<>(1),Boolean.TYPE));
assertCanCompile(expression);
assertTrue(expression.getValue(new GenericMessageTestHelper2<Integer>(6),Boolean.TYPE));
assertTrue(expression.getValue(new GenericMessageTestHelper2<>(6),Boolean.TYPE));
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author 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<String,Object> officers = new HashMap<String,Object>();
public Map<String,Object> officers = new HashMap<>();
public List<Map<String, Object>> reverse = new ArrayList<Map<String, Object>>();
public List<Map<String, Object>> 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<Integer> primes = new ArrayList<Integer>();
List<Integer> 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

View File

@@ -228,7 +228,7 @@ public class SpelReproTests extends AbstractExpressionTests {
@Test
public void SPR5804() throws Exception {
Map<String, String> m = new HashMap<String, String>();
Map<String, String> 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<String, String>();
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<String, String> map = new HashMap<String, String>();
public Map<String, String> map = new HashMap<>();
}
@@ -783,9 +783,9 @@ public class SpelReproTests extends AbstractExpressionTests {
@Test
public void mapOfMap_SPR7244() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
Map<String, Object> map = new LinkedHashMap<>();
map.put("uri", "http:");
Map<String, String> nameMap = new LinkedHashMap<String, String>();
Map<String, String> nameMap = new LinkedHashMap<>();
nameMap.put("givenName", "Arthur");
map.put("value", nameMap);
@@ -849,11 +849,11 @@ public class SpelReproTests extends AbstractExpressionTests {
public Map<String, String> ms;
C() {
ls = new ArrayList<String>();
ls = new ArrayList<>();
ls.add("abc");
ls.add("def");
as = new String[] { "abc", "def" };
ms = new HashMap<String, String>();
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<D> list = new ArrayList<D>();
List<D> 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<TypeDescriptor> args = new ArrayList<TypeDescriptor>();
List<TypeDescriptor> 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<TypeDescriptor> args = new ArrayList<TypeDescriptor>();
List<TypeDescriptor> 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<TypeDescriptor> args = new ArrayList<TypeDescriptor>();
List<TypeDescriptor> args = new ArrayList<>();
args.add(TypeDescriptor.forObject(34L));
ReflectionUtil<Integer> ru = new ReflectionUtil<Integer>();
ReflectionUtil<Integer> 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<String, String> m = new HashMap<String, String>();
public Map<String, String> m = new HashMap<>();
Reserver() {
m.put("NE", "xyz");
@@ -1229,10 +1229,10 @@ public class SpelReproTests extends AbstractExpressionTests {
class ContextObject {
public Map<String, String> firstContext = new HashMap<String, String>();
public Map<String, String> secondContext = new HashMap<String, String>();
public Map<String, String> thirdContext = new HashMap<String, String>();
public Map<String, String> fourthContext = new HashMap<String, String>();
public Map<String, String> firstContext = new HashMap<>();
public Map<String, String> secondContext = new HashMap<>();
public Map<String, String> thirdContext = new HashMap<>();
public Map<String, String> 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<MethodResolver> methodResolvers = new ArrayList<MethodResolver>();
List<MethodResolver> 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<String, TestClass2> map = new HashMap<String, TestClass2>();
Map<String, TestClass2> 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<String> coll = new LinkedHashSet<String>();
Collection<String> 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<Map<String, Object>> myPayload = new ArrayList<Map<String, Object>>();
List<Map<String, Object>> myPayload = new ArrayList<>();
Map<String, Object> v1 = new HashMap<String, Object>();
Map<String, Object> v2 = new HashMap<String, Object>();
Map<String, Object> v1 = new HashMap<>();
Map<String, Object> 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<Item> children = new ArrayList<Item>();
private List<Item> 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 <T> List<T> newArrayList(Iterable<T> iterable) {
return new ArrayList<T>();
return new ArrayList<>();
}
public static <T> List<T> newArrayList(Object... elements) {

View File

@@ -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<String, Object> map = new HashMap<String, Object>();
Map<String, Object> 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<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("x", "1");
map.put("y", 2);
map.put("z", "3");

View File

@@ -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<TypeDescriptor> getTypeDescriptors(Class<?>... types) {
List<TypeDescriptor> typeDescriptors = new ArrayList<TypeDescriptor>(types.length);
List<TypeDescriptor> typeDescriptors = new ArrayList<>(types.length);
for (Class<?> type : types) {
typeDescriptors.add(TypeDescriptor.valueOf(type));
}

View File

@@ -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<String,String> testMap;
private boolean wonNobelPrize;
private PlaceOfBirth[] placesLived;
private List<PlaceOfBirth> placesLivedList = new ArrayList<PlaceOfBirth>();
private List<PlaceOfBirth> placesLivedList = new ArrayList<>();
public ArrayContainer arrayContainer;
public boolean publicBoolean;
private boolean accessedThroughGetSet;
public List<Integer> listOfInteger = new ArrayList<Integer>();
public List<Boolean> booleanList = new ArrayList<Boolean>();
public Map<String,Boolean> mapOfStringToBoolean = new LinkedHashMap<String,Boolean>();
public Map<Integer,String> mapOfNumbersUpToTen = new LinkedHashMap<Integer,String>();
public List<Integer> listOfNumbersUpToTen = new ArrayList<Integer>();
public List<Integer> listOneFive = new ArrayList<Integer>();
public List<Integer> listOfInteger = new ArrayList<>();
public List<Boolean> booleanList = new ArrayList<>();
public Map<String,Boolean> mapOfStringToBoolean = new LinkedHashMap<>();
public Map<Integer,String> mapOfNumbersUpToTen = new LinkedHashMap<>();
public List<Integer> listOfNumbersUpToTen = new ArrayList<>();
public List<Integer> 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<String,String>();
testMap = new HashMap<>();
testMap.put("monday", "montag");
testMap.put("tuesday", "dienstag");
testMap.put("wednesday", "mittwoch");
@@ -164,7 +180,7 @@ public class Inventor {
}
public List<String> getDoublesAsStringList() {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
result.add("14.35");
result.add("15.45");
return result;