* @param targetPrimitiveOrWrapperClass (the type we are verifying against)
* @param actualPrimitiveOrWrapperClass (the type that may be the autoboxed or primitive equal
* @return
*/
private boolean isAutoboxedType(Class targetPrimitiveOrWrapperClass, Class actualPrimitiveOrWrapperClass) {
BasicTypeHelperImpl typeHelper = BasicTypeHelperImpl.getInstance();
if ((targetPrimitiveOrWrapperClass == null) || (actualPrimitiveOrWrapperClass == null)) {
return false;
}
// Check for the same class in the same classloader or different classloaders
if (targetPrimitiveOrWrapperClass == actualPrimitiveOrWrapperClass ||
targetPrimitiveOrWrapperClass.getCanonicalName().equals(actualPrimitiveOrWrapperClass.getCanonicalName())) {
return false;
}
/**
* We return true for any of the following combinations.
* boolean:Boolean byte:Byte short:Short char:Character int:Integer long:Long float:Float double:Double
*/
// Are we dealing with autoboxed wrappers Boolean, Byte, Short, Character, Integer, Long, Float, Double
// Or are we dealing with the primitives boolean, byte, short, char, int, long, float, double
// Note BigDecimal, BigInteger, Calendar, Timestamp, Time and Date are not wrappers for pimitives
if(typeHelper.isWrapperClass(targetPrimitiveOrWrapperClass) ||
targetPrimitiveOrWrapperClass.isPrimitive()) {
// Check each type (primitive or Class) against each Class type - the target and actual can both be primitives or Objects
if(typeHelper.isBooleanType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isBooleanType(actualPrimitiveOrWrapperClass);
}
if(typeHelper.isByteType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isByteType(actualPrimitiveOrWrapperClass);
}
if(typeHelper.isShortType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isShortType(actualPrimitiveOrWrapperClass);
}
if(typeHelper.isCharacterType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isCharacterType(actualPrimitiveOrWrapperClass);
}
if(typeHelper.isIntType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isIntType(actualPrimitiveOrWrapperClass);
}
if(typeHelper.isLongType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isLongType(actualPrimitiveOrWrapperClass);
}
if(typeHelper.isFloatType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isFloatType(actualPrimitiveOrWrapperClass);
}
if(typeHelper.isDoubleType(targetPrimitiveOrWrapperClass)) {
return typeHelper.isDoubleType(actualPrimitiveOrWrapperClass);
}
}
return false;
}