List of utility methods to do Class InstanceOf
boolean | instanceOf(final Object object, final Class>... classes) instance Of if (classes != null) { for (final Class<?> c : classes) { if (c.isInstance(object)) return true; return false; |
boolean | instanceOf(Object o, Class clazz) instance Of return clazz.isInstance(o);
|
boolean | instanceOf(Object o, Class> c) instance Of if (o == null || c == null) { return false; return c.isAssignableFrom(o.getClass()); |
boolean | instanceOf(Object o, Class>... classes) Check whether object o is one of instance in class list classes
for (Class<?> cls : classes) { if (cls.isInstance(o)) { return true; return false; |
boolean | instanceOf(Object obj, String className) instance Of boolean check; try { check = Class.forName(className).isInstance(obj); } catch (ClassNotFoundException e) { check = false; return check; |
boolean | instanceOf(Object obj, String className) instance Of final ClassLoader cl = obj.getClass().getClassLoader(); final Class<?> clazz = Class.forName(className, true, cl); final boolean isInstanceOf = obj.getClass().isAssignableFrom(clazz); return isInstanceOf; |
boolean | instanceOf(Object obj, String name) instance Of return obj != null && Class.forName(name).isAssignableFrom(obj.getClass());
|
boolean | instanceOf(Object object, Class> clazz) A runtime version of the instanceof keyword. return instanceOf(object.getClass(), clazz);
|
boolean | instanceOfAll(Object o, Class>... clazzes) instance Of All for (Class<?> clazz : clazzes) if (!clazz.isInstance(o)) return false; return true; |
boolean | instanceofByteArray(Object o) This method allows working around issue 58 return o instanceof byte[]; |