Skip to content

Commit ae35e84

Browse files
committed
Polishing
(cherry picked from commit 0711d6d)
1 parent 391f72d commit ae35e84

File tree

6 files changed

+24
-26
lines changed

6 files changed

+24
-26
lines changed

spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java

Lines changed: 2 additions & 3 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.
@@ -204,7 +204,7 @@ public <T> T convertIfNecessary(String propertyName, Object oldValue, Object new
204204
if (Object.class.equals(requiredType)) {
205205
return (T) convertedValue;
206206
}
207-
if (requiredType.isArray()) {
207+
else if (requiredType.isArray()) {
208208
// Array required -> apply appropriate conversion of elements.
209209
if (convertedValue instanceof String && Enum.class.isAssignableFrom(requiredType.getComponentType())) {
210210
convertedValue = StringUtils.commaDelimitedListToStringArray((String) convertedValue);
@@ -339,7 +339,6 @@ private Object attemptToConvertStringToEnum(Class<?> requiredType, String trimme
339339
catch (Throwable ex) {
340340
if (logger.isTraceEnabled()) {
341341
logger.trace("Field [" + convertedValue + "] isn't an enum value", ex);
342-
343342
}
344343
}
345344
}

spring-context/src/main/java/org/springframework/format/support/FormattingConversionService.java

Lines changed: 9 additions & 9 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.
@@ -88,8 +88,8 @@ public void addFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Par
8888
}
8989

9090
@Override
91-
@SuppressWarnings({ "unchecked", "rawtypes" })
92-
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory annotationFormatterFactory) {
91+
@SuppressWarnings("unchecked")
92+
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory) {
9393
Class<? extends Annotation> annotationType = (Class<? extends Annotation>)
9494
GenericTypeResolver.resolveTypeArgument(annotationFormatterFactory.getClass(), AnnotationFormatterFactory.class);
9595
if (annotationType == null) {
@@ -148,7 +148,7 @@ private Class<?> resolvePrinterObjectType(Printer<?> printer) {
148148

149149
@Override
150150
public String toString() {
151-
return this.fieldType.getName() + " -> " + String.class.getName() + " : " + this.printer;
151+
return (this.fieldType.getName() + " -> " + String.class.getName() + " : " + this.printer);
152152
}
153153
}
154154

@@ -197,7 +197,7 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
197197

198198
@Override
199199
public String toString() {
200-
return String.class.getName() + " -> " + this.fieldType.getName() + ": " + this.parser;
200+
return (String.class.getName() + " -> " + this.fieldType.getName() + ": " + this.parser);
201201
}
202202
}
203203

@@ -249,8 +249,8 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
249249

250250
@Override
251251
public String toString() {
252-
return "@" + this.annotationType.getName() + " " + this.fieldType.getName() + " -> " +
253-
String.class.getName() + ": " + this.annotationFormatterFactory;
252+
return ("@" + this.annotationType.getName() + " " + this.fieldType.getName() + " -> " +
253+
String.class.getName() + ": " + this.annotationFormatterFactory);
254254
}
255255
}
256256

@@ -302,8 +302,8 @@ public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor t
302302

303303
@Override
304304
public String toString() {
305-
return String.class.getName() + " -> @" + this.annotationType.getName() + " " +
306-
this.fieldType.getName() + ": " + this.annotationFormatterFactory;
305+
return (String.class.getName() + " -> @" + this.annotationType.getName() + " " +
306+
this.fieldType.getName() + ": " + this.annotationFormatterFactory);
307307
}
308308
}
309309

spring-context/src/main/java/org/springframework/validation/DataBinder.java

Lines changed: 2 additions & 1 deletion
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.
@@ -553,6 +553,7 @@ public List<Validator> getValidators() {
553553
return Collections.unmodifiableList(this.validators);
554554
}
555555

556+
556557
//---------------------------------------------------------------------
557558
// Implementation of PropertyEditorRegistry/TypeConverter interface
558559
//---------------------------------------------------------------------

spring-core/src/main/java/org/springframework/core/convert/support/StringToLocaleConverter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -22,10 +22,11 @@
2222
import org.springframework.util.StringUtils;
2323

2424
/**
25-
* Converts a String to a Locale.
25+
* Converts from a String to a {@link java.util.Locale}.
2626
*
2727
* @author Keith Donald
2828
* @since 3.0
29+
* @see StringUtils#parseLocaleString
2930
*/
3031
final class StringToLocaleConverter implements Converter<String, Locale> {
3132

spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 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.
@@ -22,19 +22,17 @@
2222
import org.springframework.util.StringUtils;
2323

2424
/**
25-
* Converts from a String to a java.util.UUID by calling {@link UUID#fromString(String)}.
25+
* Converts from a String to a {@link java.util.UUID}.
2626
*
2727
* @author Phillip Webb
2828
* @since 3.2
29+
* @see UUID#fromString
2930
*/
3031
final class StringToUUIDConverter implements Converter<String, UUID> {
3132

3233
@Override
3334
public UUID convert(String source) {
34-
if (StringUtils.hasLength(source)) {
35-
return UUID.fromString(source.trim());
36-
}
37-
return null;
35+
return (StringUtils.hasLength(source) ? UUID.fromString(source.trim()) : null);
3836
}
3937

4038
}

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilter.java

Lines changed: 4 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.
@@ -59,8 +59,7 @@ private static class ResourceUrlEncodingResponseWrapper extends HttpServletRespo
5959
/* Cache the index of the path within the DispatcherServlet mapping. */
6060
private Integer indexLookupPath;
6161

62-
63-
private ResourceUrlEncodingResponseWrapper(HttpServletRequest request, HttpServletResponse wrapped) {
62+
public ResourceUrlEncodingResponseWrapper(HttpServletRequest request, HttpServletResponse wrapped) {
6463
super(wrapped);
6564
this.request = request;
6665
}
@@ -69,11 +68,11 @@ private ResourceUrlEncodingResponseWrapper(HttpServletRequest request, HttpServl
6968
public String encodeURL(String url) {
7069
ResourceUrlProvider resourceUrlProvider = getResourceUrlProvider();
7170
if (resourceUrlProvider == null) {
72-
logger.debug("Request attribute exposing ResourceUrlProvider not found.");
71+
logger.debug("Request attribute exposing ResourceUrlProvider not found");
7372
return super.encodeURL(url);
7473
}
7574
initIndexLookupPath(resourceUrlProvider);
76-
if(url.length() >= this.indexLookupPath) {
75+
if (url.length() >= this.indexLookupPath) {
7776
String prefix = url.substring(0, this.indexLookupPath);
7877
String lookupPath = url.substring(this.indexLookupPath);
7978
lookupPath = resourceUrlProvider.getForLookupPath(lookupPath);

0 commit comments

Comments
 (0)