Browse Source

polish

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1914 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Keith Donald 17 years ago
parent
commit
b1d65786d0
  1. 2
      org.springframework.core/src/main/java/org/springframework/core/convert/converter/ConverterInfo.java
  2. 4
      org.springframework.core/src/main/java/org/springframework/core/convert/support/StringToCharacterConverter.java
  3. 11
      org.springframework.core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java

2
org.springframework.core/src/main/java/org/springframework/core/convert/converter/ConverterInfo.java

@ -21,12 +21,10 @@ package org.springframework.core.convert.converter; @@ -21,12 +21,10 @@ package org.springframework.core.convert.converter;
*
* Implementing this interface is required when registering converters that do not declare their
* parameterized types S and T with a {@link org.springframework.core.convert.ConversionService}.
* Such Converters are often dynamically created by a {@link ConverterFactory}.
*
* @author Keith Donald
* @since 3.0
* @see Converter
* @see ConverterFactory
*/
public interface ConverterInfo {

4
org.springframework.core/src/main/java/org/springframework/core/convert/support/StringToCharacterConverter.java

@ -27,8 +27,8 @@ import org.springframework.core.convert.converter.Converter; @@ -27,8 +27,8 @@ import org.springframework.core.convert.converter.Converter;
class StringToCharacterConverter implements Converter<String, Character> {
public Character convert(String source) {
if (source.length() == 0) {
throw new IllegalArgumentException("Invalid value; to convert to a Character a String must have a length of 1 or greater");
if ("".equals(source)) {
return null;
}
return source.charAt(0);
}

11
org.springframework.core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java

@ -18,7 +18,6 @@ package org.springframework.core.convert.support; @@ -18,7 +18,6 @@ package org.springframework.core.convert.support;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.core.convert.converter.ConverterInfo;
/**
* A factory for String to enum converters.
@ -33,7 +32,7 @@ class StringToEnumConverterFactory implements ConverterFactory<String, Enum> { @@ -33,7 +32,7 @@ class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {
return new StringToEnum(targetType);
}
private class StringToEnum<T extends Enum> implements Converter<String, T>, ConverterInfo {
private class StringToEnum<T extends Enum> implements Converter<String, T> {
private final Class<T> enumType;
@ -41,14 +40,6 @@ class StringToEnumConverterFactory implements ConverterFactory<String, Enum> { @@ -41,14 +40,6 @@ class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {
this.enumType = enumType;
}
public Class<String> getSourceType() {
return String.class;
}
public Class<T> getTargetType() {
return this.enumType;
}
public T convert(String source) {
if ("".equals(source)) {
// It's an empty enum identifier: reset the enum value to null.

Loading…
Cancel
Save