|
|
|
@ -809,15 +809,29 @@ public abstract class ClassUtils { |
|
|
|
public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) { |
|
|
|
public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) { |
|
|
|
Assert.notNull(lhsType, "Left-hand side type must not be null"); |
|
|
|
Assert.notNull(lhsType, "Left-hand side type must not be null"); |
|
|
|
Assert.notNull(rhsType, "Right-hand side type must not be null"); |
|
|
|
Assert.notNull(rhsType, "Right-hand side type must not be null"); |
|
|
|
return (lhsType.isAssignableFrom(rhsType) || |
|
|
|
if (lhsType.isAssignableFrom(rhsType)) { |
|
|
|
lhsType.equals(primitiveWrapperTypeMap.get(rhsType))); |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (lhsType.isPrimitive()) { |
|
|
|
|
|
|
|
Class resolvedPrimitive = primitiveWrapperTypeMap.get(rhsType); |
|
|
|
|
|
|
|
if (resolvedPrimitive != null && lhsType.equals(resolvedPrimitive)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
Class resolvedWrapper = primitiveTypeToWrapperMap.get(rhsType); |
|
|
|
|
|
|
|
if (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Determine if the given type is assignable from the given value, |
|
|
|
* Determine if the given type is assignable from the given value, |
|
|
|
* assuming setting by reflection. Considers primitive wrapper classes |
|
|
|
* assuming setting by reflection. Considers primitive wrapper classes |
|
|
|
* as assignable to the corresponding primitive types. |
|
|
|
* as assignable to the corresponding primitive types. |
|
|
|
* @param type the target type |
|
|
|
* @param type the target type |
|
|
|
* @param value the value that should be assigned to the type |
|
|
|
* @param value the value that should be assigned to the type |
|
|
|
* @return if the type is assignable from the value |
|
|
|
* @return if the type is assignable from the value |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|