List of utility methods to do Class InstanceOf
boolean | instanceOf(Class clazz, Class superClass) instance Of return clazz != null && superClass != null && clazz.isAssignableFrom(superClass);
|
boolean | instanceOf(Class clazz, Class target) instance Of if (clazz == null) return false; if (clazz == target) return true; if (target.isInterface()) { for (Class aClass : clazz.getInterfaces()) { if (aClass == target) return true; ... |
boolean | instanceOf(Class left, Class right) Check if left type is same type or subtype of right type using same conventions as java instanceof expression but apply to type. return left.isAssignableFrom(right);
|
boolean | instanceOf(Class tester, Class instance) instance Of try { tester.asSubclass(instance); return true; } catch (Exception ignored) { return false; |
boolean | instanceOf(Class> beanClass, Object element) instance Of return element != null && beanClass.isAssignableFrom(element.getClass());
|
boolean | instanceOf(Class> objectClass, Class> typeClass) Tests if a class is the same class as, or sub-class of, or implements typeClass .
if (objectClass == typeClass) { return true; if (objectClass.isInterface()) { if (typeClass.isInterface()) { Class<?>[] ifaces = objectClass.getInterfaces(); for (Class<?> iface : ifaces) { if (iface == typeClass) { ... |
boolean | instanceOf(Class> parant, Class> chield) instance Of if (parant == null) throw new NullPointerException("parant is null"); if (chield == null) throw new NullPointerException("chield is null"); if (parant.equals(chield)) return true; return parant.isAssignableFrom(chield); |
boolean | instanceOf(Class> test, Class> clazz) Checks if a class is instance of an other class. if (test.equals(clazz)) return true; for (Class<?> i : test.getInterfaces()) { if (i.equals(clazz)) return true; return false; |
boolean | instanceOf(final Class> classVerifiable, final Class> classAssignable) The instanceof command is used to determine if a Java class is of a given type. return classAssignable.isAssignableFrom(classVerifiable);
|
boolean | instanceOf(final Object a, final Class> b) instance Of return b.isInstance(a);
|