public static boolean isAssignable ( Class < ? > lhsType , Class < ? > rhsType ) { Preconditions . checkNotNull ( lhsType , "Left-hand side type must not be null" ) ; Preconditions . checkNotNull ( rhsType , "Right-hand side type must not be null" ) ; if ( lhsType . isAssignableFrom ( 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 ; }
Check if the right - hand side type may be assigned to the left - hand side type assuming setting by reflection . Considers primitive wrapper classes as assignable to the corresponding primitive types .