Java Utililty Methods Class InstanceOf

List of utility methods to do Class InstanceOf

Description

The list of methods to do Class InstanceOf are organized into topic(s).

Method

booleaninstanceOf(final Object object, final Class... classes)
instance Of
if (classes != null) {
    for (final Class<?> c : classes) {
        if (c.isInstance(object))
            return true;
return false;
booleaninstanceOf(Object o, Class clazz)
instance Of
return clazz.isInstance(o);
booleaninstanceOf(Object o, Class c)
instance Of
if (o == null || c == null) {
    return false;
return c.isAssignableFrom(o.getClass());
booleaninstanceOf(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;
booleaninstanceOf(Object obj, String className)
instance Of
boolean check;
try {
    check = Class.forName(className).isInstance(obj);
} catch (ClassNotFoundException e) {
    check = false;
return check;
booleaninstanceOf(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;
booleaninstanceOf(Object obj, String name)
instance Of
return obj != null && Class.forName(name).isAssignableFrom(obj.getClass());
booleaninstanceOf(Object object, Class clazz)
A runtime version of the instanceof keyword.
return instanceOf(object.getClass(), clazz);
booleaninstanceOfAll(Object o, Class... clazzes)
instance Of All
for (Class<?> clazz : clazzes)
    if (!clazz.isInstance(o))
        return false;
return true;
booleaninstanceofByteArray(Object o)
This method allows working around issue 58
return o instanceof byte[];