Skip to content

Commit 09c7194

Browse files
committed
Polishing
(cherry picked from commit 232cfe5)
1 parent a63247b commit 09c7194

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -183,9 +183,10 @@ public <T> T convertIfNecessary(String propertyName, Object oldValue, Object new
183183

184184
// Value not of required type?
185185
if (editor != null || (requiredType != null && !ClassUtils.isAssignableValue(requiredType, convertedValue))) {
186-
if (requiredType != null && Collection.class.isAssignableFrom(requiredType) && convertedValue instanceof String) {
187-
TypeDescriptor elementType = typeDescriptor.getElementTypeDescriptor();
188-
if (elementType != null && Enum.class.isAssignableFrom(elementType.getType())) {
186+
if (typeDescriptor != null && requiredType != null && Collection.class.isAssignableFrom(requiredType) &&
187+
convertedValue instanceof String) {
188+
TypeDescriptor elementTypeDesc = typeDescriptor.getElementTypeDescriptor();
189+
if (elementTypeDesc != null && Enum.class.isAssignableFrom(elementTypeDesc.getType())) {
189190
convertedValue = StringUtils.commaDelimitedListToStringArray((String) convertedValue);
190191
}
191192
}

spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -145,10 +145,9 @@ public Class<?> getObjectType() {
145145
/**
146146
* The type of the backing class, method parameter, field, or property
147147
* described by this TypeDescriptor.
148-
* <p>Returns primitive types as-is.
149-
* <p>See {@link #getObjectType()} for a variation of this operation that
150-
* resolves primitive types to their corresponding Object types if necessary.
151-
* @return the type, or {@code null} if it cannot be determined
148+
* <p>Returns primitive types as-is. See {@link #getObjectType()} for a
149+
* variation of this operation that resolves primitive types to their
150+
* corresponding Object types if necessary.
152151
* @see #getObjectType()
153152
*/
154153
public Class<?> getType() {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -29,12 +29,12 @@
2929
*
3030
* <p>Allows for reading from any Reader and writing to any Writer, for example
3131
* to specify a charset for a properties file. This is a capability that standard
32-
* {@code java.util.Properties} unfortunately lacked up until JDK 1.5:
32+
* {@code java.util.Properties} unfortunately lacked up until JDK 5:
3333
* You were only able to load files using the ISO-8859-1 charset there.
3434
*
3535
* <p>Loading from and storing to a stream delegates to {@code Properties.load}
3636
* and {@code Properties.store}, respectively, to be fully compatible with
37-
* the Unicode conversion as implemented by the JDK Properties class. As of JDK 1.6,
37+
* the Unicode conversion as implemented by the JDK Properties class. As of JDK 6,
3838
* {@code Properties.load/store} will also be used for readers/writers,
3939
* effectively turning this class into a plain backwards compatibility adapter.
4040
*

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

Lines changed: 1 addition & 7 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-2016 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.
@@ -32,10 +32,6 @@
3232
* but allowing for reading from any Reader and writing to any Writer
3333
* (which allows to specify an encoding for a properties file).
3434
*
35-
* <p>As of Spring 1.2.2, this interface also supports properties XML files,
36-
* through the {@code loadFromXml} and {@code storeToXml} methods.
37-
* The default implementations delegate to JDK 1.5's corresponding methods.
38-
*
3935
* @author Juergen Hoeller
4036
* @since 10.03.2004
4137
* @see DefaultPropertiesPersister
@@ -62,7 +58,6 @@ public interface PropertiesPersister {
6258
*/
6359
void load(Properties props, Reader reader) throws IOException;
6460

65-
6661
/**
6762
* Write the contents of the given Properties object to the
6863
* given OutputStream.
@@ -84,7 +79,6 @@ public interface PropertiesPersister {
8479
*/
8580
void store(Properties props, Writer writer, String header) throws IOException;
8681

87-
8882
/**
8983
* Load properties from the given XML InputStream into the
9084
* given Properties object.

0 commit comments

Comments
 (0)