List of utility methods to do Reflection Primitive
void | addPrimitiveToWrapperRelation(Class primitiveClass, Class wrapperClass) add Primitive To Wrapper Relation PRIMITIVE_TO_WRAPPERS_MAP.put(primitiveClass, wrapperClass); WRAPPERS_TO_PRIMITIVE_MAP.put(wrapperClass, primitiveClass); |
float | calculateDistancePrimitive(Class> a, Class> b) calculate Distance Primitive if (b == Character.class || b == Boolean.class) return -1F; if (a == Character.class) a = Short.class; int indexA = PRIMITIVE_WIDENING.indexOf(a); int indexB = PRIMITIVE_WIDENING.indexOf(b); if (indexA < 0 || indexB < 0) return -1F; ... |
boolean | canCoerceLiteralNumberExpr(Class> type) can Coerce Literal Number Expr final List<? extends Class<?>> classes = Arrays.asList(int.class, long.class, double.class); return classes.contains(type); |
T | castToPrimitive(Object start, Class cast To Primitive try { if (start == null) { return (T) defaultPrimitiveValues.get(prim); if (start instanceof Boolean) { start = ((Boolean) start) ? 1 : 0; if (start instanceof Character) { ... |
Class> | convertPrimitiveToObjectClass(Class> clazz) The class equivalent of (manual) autoboxing. if (isPrimitiveClass(clazz)) { return primitiveToObjectClassMap.get(clazz); return clazz; |
Class | convertPrimitiveToWrapper(Class clazz) Gets the equivalent class to convert to if the given clazz is a primitive. if (clazz == null || !clazz.isPrimitive()) return clazz; return (Class) primativeToWrapperMap.get(clazz); |
Class> | convertPrimitiveToWrapper(Class> clazz) Checks whether a given class object is a primitive and returns its wrapper class (except for void where always the primitive class is used). Class<?> result = clazz; if (clazz.isPrimitive()) { return primitiveWrapperClasses.get(clazz.getName()); return result; |
Class | convertToPrimitive(Class type) convert To Primitive if (type == null || type.isPrimitive()) { throw new IllegalArgumentException( "Given class type is wrong. Either it is null or is a primitive. given-class[" + type + "]"); return wrapperToprimitives.get(type); |
Class> | convertWrapperToPrimitive(Class> clazz) convert Wrapper To Primitive Class<?> result = clazz; if (!clazz.isPrimitive()) { return wrapperPrimitiveClasses.get(clazz.getName()); return result; |
K | createDefaultPrimitive(Class Returns the default value (JLS 4.12.5) of a primitive type. return type.cast(PRIMITIVE_DEFAULTS.get(type));
|