Browse Source

Polishing

(cherry picked from commit 232cfe5)
pull/1155/head
Juergen Hoeller 10 years ago
parent
commit
09c7194c78
  1. 9
      spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java
  2. 9
      spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
  3. 6
      spring-core/src/main/java/org/springframework/util/DefaultPropertiesPersister.java
  4. 8
      spring-core/src/main/java/org/springframework/util/PropertiesPersister.java

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

@ -1,5 +1,5 @@ @@ -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.
@ -183,9 +183,10 @@ class TypeConverterDelegate { @@ -183,9 +183,10 @@ class TypeConverterDelegate {
// Value not of required type?
if (editor != null || (requiredType != null && !ClassUtils.isAssignableValue(requiredType, convertedValue))) {
if (requiredType != null && Collection.class.isAssignableFrom(requiredType) && convertedValue instanceof String) {
TypeDescriptor elementType = typeDescriptor.getElementTypeDescriptor();
if (elementType != null && Enum.class.isAssignableFrom(elementType.getType())) {
if (typeDescriptor != null && requiredType != null && Collection.class.isAssignableFrom(requiredType) &&
convertedValue instanceof String) {
TypeDescriptor elementTypeDesc = typeDescriptor.getElementTypeDescriptor();
if (elementTypeDesc != null && Enum.class.isAssignableFrom(elementTypeDesc.getType())) {
convertedValue = StringUtils.commaDelimitedListToStringArray((String) convertedValue);
}
}

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

@ -1,5 +1,5 @@ @@ -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.
@ -145,10 +145,9 @@ public class TypeDescriptor implements Serializable { @@ -145,10 +145,9 @@ public class TypeDescriptor implements Serializable {
/**
* The type of the backing class, method parameter, field, or property
* described by this TypeDescriptor.
* <p>Returns primitive types as-is.
* <p>See {@link #getObjectType()} for a variation of this operation that
* resolves primitive types to their corresponding Object types if necessary.
* @return the type, or {@code null} if it cannot be determined
* <p>Returns primitive types as-is. See {@link #getObjectType()} for a
* variation of this operation that resolves primitive types to their
* corresponding Object types if necessary.
* @see #getObjectType()
*/
public Class<?> getType() {

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

@ -1,5 +1,5 @@ @@ -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.
@ -29,12 +29,12 @@ import java.util.Properties; @@ -29,12 +29,12 @@ import java.util.Properties;
*
* <p>Allows for reading from any Reader and writing to any Writer, for example
* to specify a charset for a properties file. This is a capability that standard
* {@code java.util.Properties} unfortunately lacked up until JDK 1.5:
* {@code java.util.Properties} unfortunately lacked up until JDK 5:
* You were only able to load files using the ISO-8859-1 charset there.
*
* <p>Loading from and storing to a stream delegates to {@code Properties.load}
* and {@code Properties.store}, respectively, to be fully compatible with
* the Unicode conversion as implemented by the JDK Properties class. As of JDK 1.6,
* the Unicode conversion as implemented by the JDK Properties class. As of JDK 6,
* {@code Properties.load/store} will also be used for readers/writers,
* effectively turning this class into a plain backwards compatibility adapter.
*

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

@ -1,5 +1,5 @@ @@ -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.
@ -32,10 +32,6 @@ import java.util.Properties; @@ -32,10 +32,6 @@ import java.util.Properties;
* but allowing for reading from any Reader and writing to any Writer
* (which allows to specify an encoding for a properties file).
*
* <p>As of Spring 1.2.2, this interface also supports properties XML files,
* through the {@code loadFromXml} and {@code storeToXml} methods.
* The default implementations delegate to JDK 1.5's corresponding methods.
*
* @author Juergen Hoeller
* @since 10.03.2004
* @see DefaultPropertiesPersister
@ -62,7 +58,6 @@ public interface PropertiesPersister { @@ -62,7 +58,6 @@ public interface PropertiesPersister {
*/
void load(Properties props, Reader reader) throws IOException;
/**
* Write the contents of the given Properties object to the
* given OutputStream.
@ -84,7 +79,6 @@ public interface PropertiesPersister { @@ -84,7 +79,6 @@ public interface PropertiesPersister {
*/
void store(Properties props, Writer writer, String header) throws IOException;
/**
* Load properties from the given XML InputStream into the
* given Properties object.

Loading…
Cancel
Save