added support for null conversion point type

master
Keith Donald 16 years ago
parent 18be2ffadc
commit d13567bc8f
  1. 4
      org.springframework.core/src/main/java/org/springframework/core/convert/support/GenericTypeConverter.java
  2. 11
      org.springframework.core/src/test/java/org/springframework/core/convert/support/GenericTypeConverterTests.java

@ -158,6 +158,10 @@ public class GenericTypeConverter implements TypeConverter, ConverterRegistry {
throws ConverterNotFoundException {
Assert.notNull(sourceClass, "The sourceType to convert from is required");
Assert.notNull(targetType, "The targetType to convert to is required");
if (targetType.getType() == null) {
// TODO for Andy - is this correct way to handle the Null TypedValue?
return NoOpConversionExecutor.INSTANCE;
}
ConversionPoint sourceType = ConversionPoint.valueOf(sourceClass);
if (sourceType.isArray()) {
if (targetType.isArray()) {

@ -81,6 +81,17 @@ public class GenericTypeConverterTests {
assertNull(converter.convert(null, Integer.class));
}
@Test
public void convertNullTargetClass() {
assertEquals("3", converter.convert("3", (Class<?>)null));
}
@Test
public void convertNullConversionPointType() {
assertEquals("3", converter.convert("3", ConversionPoint.NULL));
}
@Test
public void convertWrongTypeArgument() {
converter.addConverter(new StringToInteger());

Loading…
Cancel
Save