Browse Source

removed generic warning

pull/23217/head
Keith Donald 15 years ago
parent
commit
bb93f5967f
  1. 10
      org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToStringConverter.java

10
org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToStringConverter.java

@ -37,18 +37,18 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter; @@ -37,18 +37,18 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter;
*/
final class ObjectToStringConverter implements ConditionalGenericConverter {
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(Object.class, String.class));
}
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
Class sourceClass = sourceType.getObjectType();
Class<?> sourceClass = sourceType.getObjectType();
return Number.class.isAssignableFrom(sourceClass) || Boolean.class.equals(sourceClass) ||
Character.class.equals(sourceClass) || CharSequence.class.isAssignableFrom(sourceClass) ||
StringWriter.class.isAssignableFrom(sourceClass) || sourceClass.isEnum() ||
ObjectToObjectConverter.hasValueOfMethodOrConstructor(sourceClass, String.class);
}
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(Object.class, String.class));
}
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
return (source != null ? source.toString() : null);
}

Loading…
Cancel
Save