List of utility methods to do Reflection Assignable
boolean | isAssignable(Class clazz, Class toClass) is Assignable if (clazz == null || toClass == null) { return false; if (clazz.equals(toClass)) { return true; Class newClazz = clazz; Class newToClass = toClass; ... |
boolean | isAssignable(Class lhsType, Class rhsType) Check if the right-hand side type may be assigned to the left-hand side type, assuming setting by reflection. return (lhsType.isAssignableFrom(rhsType) || lhsType.equals(wrapperPrimitives.get(rhsType)));
|
boolean | isAssignable(Class> cls, final Class> toClass) is Assignable if (toClass == null) { return false; if (cls == null) { return !toClass.isPrimitive(); if (cls.isPrimitive() && !toClass.isPrimitive()) { cls = primitiveToWrapper(cls); ... |
boolean | isAssignable(Class> lhsType, Class> rhsType) is Assignable return (lhsType.isAssignableFrom(rhsType) || lhsType.equals(primitiveWrapperTypeMap.get(rhsType)));
|
boolean | isAssignable(Class> lhsType, Class> rhsType) Check if the right-hand side type may be assigned to the left-hand side type, assuming setting by reflection. if (lhsType.isAssignableFrom(rhsType)) { return true; if (lhsType.isPrimitive()) { Class<?> resolvedPrimitive = primitiveWrapperTypeMap.get(rhsType); if (lhsType == resolvedPrimitive) { return true; } else { Class<?> resolvedWrapper = primitiveTypeToWrapperMap.get(rhsType); if (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)) { return true; return false; |
boolean | isAssignable(Class> lhsType, Class> rhsType) Check if the right-hand side type may be assigned to the left-hand side type, assuming setting by reflection. if (rhsType == null) { if (!lhsType.isPrimitive()) return true; } else { if (lhsType.isAssignableFrom(rhsType)) return true; if (rhsType.isPrimitive() && lhsType.equals(getPrimitiveWrapper(rhsType))) return true; ... |
boolean | isAssignable(final Class> from, final Class> to) Determines if the type from is assignable to the type to. assert from != null; assert to != null; if (to.isAssignableFrom(from)) { return true; } else { final Class<?> clazz = assignable.get(from); return clazz.equals(to); |
boolean | isAssignableFrom(Class> class1, Class> class2) is Assignable From if (class1.isAssignableFrom(class2)) return true; if (!class1.isPrimitive()) return false; Class<?> wrapper = primitiveToWrapperClass.get(class1.getName()); return wrapper.isAssignableFrom(class2); |
boolean | isAssignableFrom(Class> to, Class> from) Improves java5's Class.isAssignableFrom method. if (PRIMITIVE_TO_WRAPPER.get(to) == from || PRIMITIVE_TO_WRAPPER.get(from) == to) { return true; return to.isAssignableFrom(from); |
boolean | isAssignableFrom(Class> to, Class> from) Just like Class.isAssignableFrom(), but does the right thing when considering autoboxing. Class<?> notPrimitiveTo = to.isPrimitive() ? PRIMITIVE_TO_WRAPPER.get(to) : to;
Class<?> notPrimitiveFrom = from.isPrimitive() ? PRIMITIVE_TO_WRAPPER.get(from) : from;
return notPrimitiveTo.isAssignableFrom(notPrimitiveFrom);
|