polish
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1937 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
26ff01d23b
commit
03dab76899
|
|
@ -38,7 +38,7 @@ import org.springframework.util.ClassUtils;
|
|||
public class TypeDescriptor {
|
||||
|
||||
/**
|
||||
* Constant defining an 'empty' TypeDescriptor.
|
||||
* Constant defining an 'unknown' TypeDescriptor.
|
||||
*/
|
||||
public static final TypeDescriptor NULL = new TypeDescriptor();
|
||||
|
||||
|
|
@ -231,10 +231,16 @@ public class TypeDescriptor {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns map key type as a type descriptor.
|
||||
*/
|
||||
public TypeDescriptor getMapKeyTypeDescriptor() {
|
||||
return TypeDescriptor.valueOf(getMapKeyType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns map value type as a type descriptor.
|
||||
*/
|
||||
public TypeDescriptor getMapValueTypeDescriptor() {
|
||||
return TypeDescriptor.valueOf(getMapValueType());
|
||||
}
|
||||
|
|
@ -270,7 +276,7 @@ public class TypeDescriptor {
|
|||
*/
|
||||
public boolean isAssignableValue(Object obj) {
|
||||
Class<?> type = getType();
|
||||
return (type != null && ClassUtils.isAssignableValue(getType(), obj));
|
||||
return type != null && ClassUtils.isAssignableValue(getType(), obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -279,7 +285,11 @@ public class TypeDescriptor {
|
|||
* @return true if this type is assignable to the target
|
||||
*/
|
||||
public boolean isAssignableTo(TypeDescriptor targetType) {
|
||||
return ClassUtils.isAssignable(targetType.getType(), getType());
|
||||
if (targetType == TypeDescriptor.NULL) {
|
||||
return false;
|
||||
}
|
||||
Class<?> type = getType();
|
||||
return type != null && ClassUtils.isAssignable(targetType.getType(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class CollectionGenericConverter implements GenericConverter {
|
|||
return TypeDescriptor.valueOf(element.getClass());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return TypeDescriptor.NULL;
|
||||
}
|
||||
|
||||
private Collection compatibleCollectionWithoutElementConversion(Collection source, TypeDescriptor targetType) {
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ class MapGenericConverter implements GenericConverter {
|
|||
return compatibleMapWithoutEntryConversion(sourceMap, targetType);
|
||||
}
|
||||
boolean keysCompatible = false;
|
||||
if (sourceKeyType != null && targetKeyType != null && sourceKeyType.isAssignableTo(targetKeyType)) {
|
||||
if (sourceKeyType != TypeDescriptor.NULL && targetKeyType != TypeDescriptor.NULL && sourceKeyType.isAssignableTo(targetKeyType)) {
|
||||
keysCompatible = true;
|
||||
}
|
||||
boolean valuesCompatible = false;
|
||||
if (sourceValueType != null && targetValueType != null && sourceValueType.isAssignableTo(targetValueType)) {
|
||||
if (sourceValueType != TypeDescriptor.NULL && targetValueType != TypeDescriptor.NULL && sourceValueType.isAssignableTo(targetValueType)) {
|
||||
valuesCompatible = true;
|
||||
}
|
||||
if (keysCompatible && valuesCompatible) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue