|
|
|
@ -302,78 +302,6 @@ public class ReflectionUtils {
@@ -302,78 +302,6 @@ public class ReflectionUtils {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isDouble(Class c) { |
|
|
|
|
return c == Double.class || c == Double.TYPE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isFloat(Class c) { |
|
|
|
|
return c == Float.class || c == Float.TYPE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isLong(Class c) { |
|
|
|
|
return c == Long.class || c == Long.TYPE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isInt(Class c) { |
|
|
|
|
return c == Integer.class || c == Integer.TYPE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isChar(Class c) { |
|
|
|
|
return c == Character.class || c == Character.TYPE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isShort(Class c) { |
|
|
|
|
return c == Short.class || c == Short.TYPE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static boolean isByte(Class c) { |
|
|
|
|
return c == Byte.class || c == Byte.TYPE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns true if the input-type can be 'widened' to the target-type, according to the following allowed widenings: |
|
|
|
|
* |
|
|
|
|
* byte to short, int, long, float, or double <BR> |
|
|
|
|
* short to int, long, float, or double <BR> |
|
|
|
|
* char to int, long, float, or double <BR> |
|
|
|
|
* int to long, float, or double <BR> |
|
|
|
|
* long to float or double <BR> |
|
|
|
|
* float to double |
|
|
|
|
*/ |
|
|
|
|
private static boolean isWidenableTo(Class targetType, Class inputType) { |
|
|
|
|
if (inputType.isPrimitive()) { |
|
|
|
|
if (inputType == Double.TYPE) { |
|
|
|
|
return (isDouble(targetType)); |
|
|
|
|
} else if (inputType == Long.TYPE) { |
|
|
|
|
return (isDouble(targetType) || isFloat(targetType)); |
|
|
|
|
} else if (inputType == Integer.TYPE) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType); |
|
|
|
|
} else if (inputType == Character.TYPE) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType) || isInt(targetType); |
|
|
|
|
} else if (inputType == Short.TYPE) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType) || isInt(targetType); |
|
|
|
|
} else if (inputType == Byte.TYPE) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType) || isInt(targetType) |
|
|
|
|
|| isShort(targetType); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (inputType == Double.class) { |
|
|
|
|
return (isDouble(targetType)); |
|
|
|
|
} else if (inputType == Long.class) { |
|
|
|
|
return (isDouble(targetType) || isFloat(targetType)); |
|
|
|
|
} else if (inputType == Integer.class) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType); |
|
|
|
|
} else if (inputType == Character.class) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType) || isInt(targetType); |
|
|
|
|
} else if (inputType == Short.class) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType) || isInt(targetType); |
|
|
|
|
} else if (inputType == Byte.class) { |
|
|
|
|
return isDouble(targetType) || isFloat(targetType) || isLong(targetType) || isInt(targetType) |
|
|
|
|
|| isShort(targetType); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO optimize impl
|
|
|
|
|
private static boolean areBoxingCompatible(Class class1, Class class2) { |
|
|
|
|