Skip to content

Commit 3c6f1f8

Browse files
committed
Polishing
1 parent c111bd7 commit 3c6f1f8

File tree

6 files changed

+55
-60
lines changed

6 files changed

+55
-60
lines changed

spring-context/src/main/java/org/springframework/format/annotation/DateTimeFormat.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
* A date or time may be omitted by specifying the style character '-'.
3636
*
3737
* <p>For ISO-based formatting, set the {@link #iso} attribute to be the desired {@link ISO} format,
38-
* such as {@link ISO#DATE}. For custom formatting, set the {@link #pattern} attribute to be the
38+
* such as {@link ISO#DATE}. For custom formatting, set the {@link #pattern()} attribute to be the
3939
* DateTime pattern, such as {@code yyyy/MM/dd hh:mm:ss a}.
4040
*
4141
* <p>Each attribute is mutually exclusive, so only set one attribute per annotation instance
42-
* (the most convenient one for your formatting needs).
42+
* (the one most convenient one for your formatting needs).
4343
* When the pattern attribute is specified, it takes precedence over both the style and ISO attribute.
44-
* When the iso attribute is specified, it takes precedence over the style attribute.
44+
* When the {@link #iso} attribute is specified, if takes precedence over the style attribute.
4545
* When no annotation attributes are specified, the default format applied is style-based
4646
* with a style code of 'SS' (short date, short time).
4747
*
@@ -82,23 +82,23 @@
8282
/**
8383
* Common ISO date time format patterns.
8484
*/
85-
public enum ISO {
85+
enum ISO {
8686

8787
/**
8888
* The most common ISO Date Format {@code yyyy-MM-dd},
89-
* e.g. 2000-10-31.
89+
* e.g. "2000-10-31".
9090
*/
9191
DATE,
9292

9393
/**
9494
* The most common ISO Time Format {@code HH:mm:ss.SSSZ},
95-
* e.g. 01:30:00.000-05:00.
95+
* e.g. "01:30:00.000-05:00".
9696
*/
9797
TIME,
9898

9999
/**
100100
* The most common ISO DateTime Format {@code yyyy-MM-dd'T'HH:mm:ss.SSSZ},
101-
* e.g. 2000-10-31 01:30:00.000-05:00.
101+
* e.g. "2000-10-31 01:30:00.000-05:00".
102102
* <p>This is the default if no annotation value is specified.
103103
*/
104104
DATE_TIME,

spring-context/src/main/java/org/springframework/format/annotation/NumberFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
/**
6868
* Common number format styles.
6969
*/
70-
public enum Style {
70+
enum Style {
7171

7272
/**
7373
* The general-purpose number format for the current locale.

spring-core/src/main/java/org/springframework/util/ClassUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -352,9 +352,9 @@ public static Class<?> getUserClass(Object instance) {
352352
*/
353353
public static Class<?> getUserClass(Class<?> clazz) {
354354
if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
355-
Class<?> superClass = clazz.getSuperclass();
356-
if (superClass != null && !Object.class.equals(superClass)) {
357-
return superClass;
355+
Class<?> superclass = clazz.getSuperclass();
356+
if (superclass != null && !Object.class.equals(superclass)) {
357+
return superclass;
358358
}
359359
}
360360
return clazz;
@@ -821,8 +821,8 @@ private static boolean isOverridable(Method method, Class<?> targetClass) {
821821

822822
/**
823823
* Return a public static method of a class.
824-
* @param methodName the static method name
825824
* @param clazz the class which defines the method
825+
* @param methodName the static method name
826826
* @param args the parameter types to the method
827827
* @return the static method, or {@code null} if no static method was found
828828
* @throws IllegalArgumentException if the method name is blank or the clazz is null

spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,43 +97,40 @@ private TypedValue getValueInternal(TypedValue contextObject, EvaluationContext
9797
if (result.getValue() == null && isAutoGrowNullReferences &&
9898
nextChildIs(Indexer.class, PropertyOrFieldReference.class)) {
9999
TypeDescriptor resultDescriptor = result.getTypeDescriptor();
100-
// Creating lists and maps
101-
if ((resultDescriptor.getType().equals(List.class) || resultDescriptor.getType().equals(Map.class))) {
102-
// Create a new collection or map ready for the indexer
103-
if (resultDescriptor.getType().equals(List.class)) {
104-
try {
105-
if (isWritableProperty(this.name, contextObject, evalContext)) {
106-
List<?> newList = ArrayList.class.newInstance();
107-
writeProperty(contextObject, evalContext, this.name, newList);
108-
result = readProperty(contextObject, evalContext, this.name);
109-
}
110-
}
111-
catch (InstantiationException ex) {
112-
throw new SpelEvaluationException(getStartPosition(), ex,
113-
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
114-
}
115-
catch (IllegalAccessException ex) {
116-
throw new SpelEvaluationException(getStartPosition(), ex,
117-
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
100+
// Create a new collection or map ready for the indexer
101+
if (List.class.equals(resultDescriptor.getType())) {
102+
try {
103+
if (isWritableProperty(this.name, contextObject, evalContext)) {
104+
List<?> newList = ArrayList.class.newInstance();
105+
writeProperty(contextObject, evalContext, this.name, newList);
106+
result = readProperty(contextObject, evalContext, this.name);
118107
}
119108
}
120-
else {
121-
try {
122-
if (isWritableProperty(this.name,contextObject, evalContext)) {
123-
Map<?,?> newMap = HashMap.class.newInstance();
124-
writeProperty(contextObject, evalContext, this.name, newMap);
125-
result = readProperty(contextObject, evalContext, this.name);
126-
}
127-
}
128-
catch (InstantiationException ex) {
129-
throw new SpelEvaluationException(getStartPosition(), ex,
130-
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
131-
}
132-
catch (IllegalAccessException ex) {
133-
throw new SpelEvaluationException(getStartPosition(), ex,
134-
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
109+
catch (InstantiationException ex) {
110+
throw new SpelEvaluationException(getStartPosition(), ex,
111+
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
112+
}
113+
catch (IllegalAccessException ex) {
114+
throw new SpelEvaluationException(getStartPosition(), ex,
115+
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING);
116+
}
117+
}
118+
else if (Map.class.equals(resultDescriptor.getType())) {
119+
try {
120+
if (isWritableProperty(this.name,contextObject, evalContext)) {
121+
Map<?,?> newMap = HashMap.class.newInstance();
122+
writeProperty(contextObject, evalContext, this.name, newMap);
123+
result = readProperty(contextObject, evalContext, this.name);
135124
}
136125
}
126+
catch (InstantiationException ex) {
127+
throw new SpelEvaluationException(getStartPosition(), ex,
128+
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
129+
}
130+
catch (IllegalAccessException ex) {
131+
throw new SpelEvaluationException(getStartPosition(), ex,
132+
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING);
133+
}
137134
}
138135
else {
139136
// 'simple' object

spring-web/src/main/java/org/springframework/web/client/RestTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
* HTTP PATCH, HTTP PUT with response body, etc.). Note however that the underlying HTTP
7979
* library used must also support the desired combination.
8080
*
81-
* <p>For each HTTP method there are 3 variants -- two accept a URI template string
81+
* <p>For each HTTP method there are three variants: two accept a URI template string
8282
* and URI variables (array or map) while a third accepts a {@link URI}.
8383
* Note that for URI templates it is assumed encoding is necessary, e.g.
8484
* {@code restTemplate.getForObject("http://example.com/hotel list")} becomes

spring-web/src/main/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolver.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,8 +53,8 @@
5353
* type {@link MultipartFile} in conjunction with Spring's {@link MultipartResolver}
5454
* abstraction, and arguments of type {@code javax.servlet.http.Part} in conjunction
5555
* with Servlet 3.0 multipart requests. This resolver can also be created in default
56-
* resolution mode in which simple types (int, long, etc.) not annotated
57-
* with @{@link RequestParam} are also treated as request parameters with the
56+
* resolution mode in which simple types (int, long, etc.) not annotated with
57+
* @{@link RequestParam} are also treated as request parameters with the
5858
* parameter name derived from the argument name.
5959
*
6060
* <p>If the method parameter type is {@link Map}, the name specified in the
@@ -202,7 +202,7 @@ else if (isPartArray(parameter)) {
202202
if (arg == null) {
203203
String[] paramValues = webRequest.getParameterValues(name);
204204
if (paramValues != null) {
205-
arg = paramValues.length == 1 ? paramValues[0] : paramValues;
205+
arg = (paramValues.length == 1 ? paramValues[0] : paramValues);
206206
}
207207
}
208208
}
@@ -218,23 +218,21 @@ private void assertIsMultipartRequest(HttpServletRequest request) {
218218
}
219219

220220
private boolean isMultipartFileCollection(MethodParameter parameter) {
221-
Class<?> collectionType = getCollectionParameterType(parameter);
222-
return ((collectionType != null) && collectionType.equals(MultipartFile.class));
221+
return MultipartFile.class.equals(getCollectionParameterType(parameter));
222+
}
223+
224+
private boolean isMultipartFileArray(MethodParameter parameter) {
225+
return MultipartFile.class.equals(parameter.getParameterType().getComponentType());
223226
}
224227

225228
private boolean isPartCollection(MethodParameter parameter) {
226229
Class<?> collectionType = getCollectionParameterType(parameter);
227-
return ((collectionType != null) && "javax.servlet.http.Part".equals(collectionType.getName()));
230+
return (collectionType != null && "javax.servlet.http.Part".equals(collectionType.getName()));
228231
}
229232

230233
private boolean isPartArray(MethodParameter parameter) {
231234
Class<?> paramType = parameter.getParameterType().getComponentType();
232-
return ((paramType != null) && "javax.servlet.http.Part".equals(paramType.getName()));
233-
}
234-
235-
private boolean isMultipartFileArray(MethodParameter parameter) {
236-
Class<?> paramType = parameter.getParameterType().getComponentType();
237-
return ((paramType != null) && MultipartFile.class.equals(paramType));
235+
return (paramType != null && "javax.servlet.http.Part".equals(paramType.getName()));
238236
}
239237

240238
private Class<?> getCollectionParameterType(MethodParameter parameter) {

0 commit comments

Comments
 (0)