List of utility methods to do Class Type Check
boolean | isAssignable(final Class> target, final Class> source) Checks if target class is assignable from source class in terms of auto(un)boxing. if (target == null || source == null) { throw new IllegalArgumentException("classes"); if (target.isArray() && source.isArray()) { return isAssignable(target.getComponentType(), source.getComponentType()); return tryFromPrimitive(target).isAssignableFrom(tryFromPrimitive(source)); |
boolean | isAssignableFrom(Class clazzA, Class clazzB) is Assignable From if (!(clazzA.isPrimitive() ^ clazzB.isPrimitive())) { return clazzA.isAssignableFrom(clazzB); } else if (clazzA.isPrimitive()) { final Class oClazzA = (Class) convertor.get(clazzA); return oClazzA.isAssignableFrom(clazzB); } else { final Class oClazzB = (Class) convertor.get(clazzB); return clazzA.isAssignableFrom(oClazzB); ... |
boolean | isBasicType(Class> clazz) is Basic Type return !Collection.class.isAssignableFrom(clazz) && (clazz.equals(Integer.class) || clazz.equals(Integer.TYPE) || clazz.equals(Long.class) || clazz.equals(Long.TYPE) || clazz.equals(Boolean.class) || clazz.equals(Boolean.TYPE) || clazz.equals(Float.class) || clazz.equals(Float.TYPE) || clazz.equals(Double.class) || clazz.equals(Double.TYPE) || clazz.equals(Byte.class) || clazz.equals(Byte.TYPE) || clazz.equals(String.class) || Date.class.isAssignableFrom(clazz)); |
boolean | isClassBelowPackage(Class> theClass, List> packageList) Returns whether the specified class is either within one of the specified packages or within a subpackage of one of the packages String classPackage = theClass.getPackage().getName(); for (Object packageName : packageList) { if (packageName != null) { if (classPackage.startsWith(packageName.toString())) { return true; return false; |
boolean | isCollection(Class> clazz) is Collection return isMap(clazz) || Collection.class.isAssignableFrom(clazz); |
boolean | isCollection(Class is Collection return Collection.class.isAssignableFrom(cls); |
boolean | isCollectionMapOrArray(Class> type) is Collection Map Or Array if (type.isArray()) return true; if (Collection.class.isAssignableFrom(type)) return true; if (Map.class.isAssignableFrom(type)) return true; return false; |
boolean | isComposite(Class> cls) is Composite return isArray(cls) || isCollection(cls);
|
boolean | isEmptyCollectionOrMap(Object content, Class> type) is Empty Collection Or Map if (Collection.class.isAssignableFrom(type)) { if (content == null) { return true; } else { if (((List) content).isEmpty()) { return true; } else if (Map.class.isAssignableFrom(type)) { if (content == null) { return true; } else { if (((List) content).isEmpty()) { return true; return false; |
boolean | isInPrimitiveWrapperType(Class> type) Return whether the Primitive Wrapper Type Map contain the given type. return primitiveWrapperTypeMap.containsValue(type);
|