added support for null conversion point type
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1206 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
e8dc69f11c
commit
c5ca7c441d
|
|
@ -158,6 +158,10 @@ public class GenericTypeConverter implements TypeConverter, ConverterRegistry {
|
||||||
throws ConverterNotFoundException {
|
throws ConverterNotFoundException {
|
||||||
Assert.notNull(sourceClass, "The sourceType to convert from is required");
|
Assert.notNull(sourceClass, "The sourceType to convert from is required");
|
||||||
Assert.notNull(targetType, "The targetType to convert to 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);
|
ConversionPoint sourceType = ConversionPoint.valueOf(sourceClass);
|
||||||
if (sourceType.isArray()) {
|
if (sourceType.isArray()) {
|
||||||
if (targetType.isArray()) {
|
if (targetType.isArray()) {
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,17 @@ public class GenericTypeConverterTests {
|
||||||
assertNull(converter.convert(null, Integer.class));
|
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
|
@Test
|
||||||
public void convertWrongTypeArgument() {
|
public void convertWrongTypeArgument() {
|
||||||
converter.addConverter(new StringToInteger());
|
converter.addConverter(new StringToInteger());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue