diff --git a/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java b/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java index 4fec9a9aa21..5feb6ee8b0e 100644 --- a/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java +++ b/spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java @@ -35,13 +35,13 @@ import java.lang.annotation.Target; * A date or time may be omitted by specifying the style character '-'. * *

For ISO-based formatting, set the {@link #iso} attribute to be the desired {@link ISO} format, - * such as {@link ISO#DATE}. For custom formatting, set the {@link #pattern} attribute to be the + * such as {@link ISO#DATE}. For custom formatting, set the {@link #pattern()} attribute to be the * DateTime pattern, such as {@code yyyy/MM/dd hh:mm:ss a}. * *

Each attribute is mutually exclusive, so only set one attribute per annotation instance - * (the most convenient one for your formatting needs). + * (the one most convenient one for your formatting needs). * When the pattern attribute is specified, it takes precedence over both the style and ISO attribute. - * When the iso attribute is specified, it takes precedence over the style attribute. + * When the {@link #iso} attribute is specified, if takes precedence over the style attribute. * When no annotation attributes are specified, the default format applied is style-based * with a style code of 'SS' (short date, short time). * @@ -82,23 +82,23 @@ public @interface DateTimeFormat { /** * Common ISO date time format patterns. */ - public enum ISO { + enum ISO { /** * The most common ISO Date Format {@code yyyy-MM-dd}, - * e.g. 2000-10-31. + * e.g. "2000-10-31". */ DATE, /** * The most common ISO Time Format {@code HH:mm:ss.SSSZ}, - * e.g. 01:30:00.000-05:00. + * e.g. "01:30:00.000-05:00". */ TIME, /** * The most common ISO DateTime Format {@code yyyy-MM-dd'T'HH:mm:ss.SSSZ}, - * e.g. 2000-10-31 01:30:00.000-05:00. + * e.g. "2000-10-31 01:30:00.000-05:00". *

This is the default if no annotation value is specified. */ DATE_TIME, diff --git a/spring-context/src/main/java/org/springframework/format/annotation/NumberFormat.java b/spring-context/src/main/java/org/springframework/format/annotation/NumberFormat.java index 9dde8214918..1b8abe5d442 100644 --- a/spring-context/src/main/java/org/springframework/format/annotation/NumberFormat.java +++ b/spring-context/src/main/java/org/springframework/format/annotation/NumberFormat.java @@ -67,7 +67,7 @@ public @interface NumberFormat { /** * Common number format styles. */ - public enum Style { + enum Style { /** * The general-purpose number format for the current locale. 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 af2c20ef0ce..b1fe72d9620 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-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -352,9 +352,9 @@ public abstract class ClassUtils { */ public static Class getUserClass(Class clazz) { if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) { - Class superClass = clazz.getSuperclass(); - if (superClass != null && !Object.class.equals(superClass)) { - return superClass; + Class superclass = clazz.getSuperclass(); + if (superclass != null && !Object.class.equals(superclass)) { + return superclass; } } return clazz; @@ -821,8 +821,8 @@ public abstract class ClassUtils { /** * Return a public static method of a class. - * @param methodName the static method name * @param clazz the class which defines the method + * @param methodName the static method name * @param args the parameter types to the method * @return the static method, or {@code null} if no static method was found * @throws IllegalArgumentException if the method name is blank or the clazz is null 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 b5634a0fee6..9773ba6d72a 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 @@ -97,43 +97,40 @@ public class PropertyOrFieldReference extends SpelNodeImpl { if (result.getValue() == null && isAutoGrowNullReferences && nextChildIs(Indexer.class, PropertyOrFieldReference.class)) { TypeDescriptor resultDescriptor = result.getTypeDescriptor(); - // Creating lists and maps - if ((resultDescriptor.getType().equals(List.class) || resultDescriptor.getType().equals(Map.class))) { - // Create a new collection or map ready for the indexer - if (resultDescriptor.getType().equals(List.class)) { - try { - if (isWritableProperty(this.name, contextObject, evalContext)) { - List newList = ArrayList.class.newInstance(); - writeProperty(contextObject, evalContext, this.name, newList); - result = readProperty(contextObject, evalContext, this.name); - } - } - catch (InstantiationException ex) { - throw new SpelEvaluationException(getStartPosition(), ex, - SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); - } - catch (IllegalAccessException ex) { - throw new SpelEvaluationException(getStartPosition(), ex, - SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); + // Create a new collection or map ready for the indexer + if (List.class.equals(resultDescriptor.getType())) { + try { + if (isWritableProperty(this.name, contextObject, evalContext)) { + List newList = ArrayList.class.newInstance(); + writeProperty(contextObject, evalContext, this.name, newList); + result = readProperty(contextObject, evalContext, this.name); } } - else { - try { - if (isWritableProperty(this.name,contextObject, evalContext)) { - Map newMap = HashMap.class.newInstance(); - writeProperty(contextObject, evalContext, this.name, newMap); - result = readProperty(contextObject, evalContext, this.name); - } - } - catch (InstantiationException ex) { - throw new SpelEvaluationException(getStartPosition(), ex, - SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); - } - catch (IllegalAccessException ex) { - throw new SpelEvaluationException(getStartPosition(), ex, - SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); + catch (InstantiationException ex) { + throw new SpelEvaluationException(getStartPosition(), ex, + SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); + } + catch (IllegalAccessException ex) { + throw new SpelEvaluationException(getStartPosition(), ex, + SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); + } + } + else if (Map.class.equals(resultDescriptor.getType())) { + try { + if (isWritableProperty(this.name,contextObject, evalContext)) { + Map newMap = HashMap.class.newInstance(); + writeProperty(contextObject, evalContext, this.name, newMap); + result = readProperty(contextObject, evalContext, this.name); } } + catch (InstantiationException ex) { + throw new SpelEvaluationException(getStartPosition(), ex, + SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); + } + catch (IllegalAccessException ex) { + throw new SpelEvaluationException(getStartPosition(), ex, + SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); + } } else { // 'simple' object 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 e5c254e83b9..95470113e3e 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 @@ -78,7 +78,7 @@ import org.springframework.web.util.UriTemplate; * HTTP PATCH, HTTP PUT with response body, etc.). Note however that the underlying HTTP * library used must also support the desired combination. * - *

For each HTTP method there are 3 variants -- two accept a URI template string + *

For each HTTP method there are three variants: two accept a URI template string * and URI variables (array or map) while a third accepts a {@link URI}. * Note that for URI templates it is assumed encoding is necessary, e.g. * {@code restTemplate.getForObject("http://example.com/hotel list")} becomes diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java index 543aa9db6f7..a3284175514 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author 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,8 +53,8 @@ import org.springframework.web.util.WebUtils; * type {@link MultipartFile} in conjunction with Spring's {@link MultipartResolver} * abstraction, and arguments of type {@code javax.servlet.http.Part} in conjunction * with Servlet 3.0 multipart requests. This resolver can also be created in default - * resolution mode in which simple types (int, long, etc.) not annotated - * with @{@link RequestParam} are also treated as request parameters with the + * resolution mode in which simple types (int, long, etc.) not annotated with + * @{@link RequestParam} are also treated as request parameters with the * parameter name derived from the argument name. * *

If the method parameter type is {@link Map}, the name specified in the @@ -202,7 +202,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod if (arg == null) { String[] paramValues = webRequest.getParameterValues(name); if (paramValues != null) { - arg = paramValues.length == 1 ? paramValues[0] : paramValues; + arg = (paramValues.length == 1 ? paramValues[0] : paramValues); } } } @@ -218,23 +218,21 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod } private boolean isMultipartFileCollection(MethodParameter parameter) { - Class collectionType = getCollectionParameterType(parameter); - return ((collectionType != null) && collectionType.equals(MultipartFile.class)); + return MultipartFile.class.equals(getCollectionParameterType(parameter)); + } + + private boolean isMultipartFileArray(MethodParameter parameter) { + return MultipartFile.class.equals(parameter.getParameterType().getComponentType()); } private boolean isPartCollection(MethodParameter parameter) { Class collectionType = getCollectionParameterType(parameter); - return ((collectionType != null) && "javax.servlet.http.Part".equals(collectionType.getName())); + return (collectionType != null && "javax.servlet.http.Part".equals(collectionType.getName())); } private boolean isPartArray(MethodParameter parameter) { Class paramType = parameter.getParameterType().getComponentType(); - return ((paramType != null) && "javax.servlet.http.Part".equals(paramType.getName())); - } - - private boolean isMultipartFileArray(MethodParameter parameter) { - Class paramType = parameter.getParameterType().getComponentType(); - return ((paramType != null) && MultipartFile.class.equals(paramType)); + return (paramType != null && "javax.servlet.http.Part".equals(paramType.getName())); } private Class getCollectionParameterType(MethodParameter parameter) {