public static boolean areConvertibleClasses ( @ Nonnull final Class < ? > aSrcClass , @ Nonnull final Class < ? > aDstClass ) { ValueEnforcer . notNull ( aSrcClass , "SrcClass" ) ; ValueEnforcer . notNull ( aDstClass , "DstClass" ) ; // Same class? if ( aDstClass . equals ( aSrcClass ) ) return true ; // Default assignable if ( aDstClass . isAssignableFrom ( aSrcClass ) ) return true ; // Special handling for "int.class" == "Integer.class" etc. if ( aDstClass == getPrimitiveWrapperClass ( aSrcClass ) ) return true ; if ( aDstClass == getPrimitiveClass ( aSrcClass ) ) return true ; // Not convertible return false ; }
Check if the passed classes are convertible . Includes conversion checks between primitive types and primitive wrapper types .