Java Class InstanceOf instanceOfs(Class[] classes, Object[] objs)

Here you can find the source of instanceOfs(Class[] classes, Object[] objs)

Description

instance Ofs

License

Apache License

Declaration

public static boolean instanceOfs(Class<?>[] classes, Object[] objs) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static boolean instanceOfs(Class<?>[] classes, Object[] objs) {
        if (objs.length != classes.length)
            return false;

        for (int i = 0; i < objs.length; i++) {
            if (objs[i] != null && !asBoxedClass(classes[i]).isInstance(objs[i]))
                return false;
        }/* www.ja  v a 2 s .co  m*/

        return true;
    }

    public static Class<?> asBoxedClass(Class<?> c) {
        if (!c.isPrimitive())
            return c;
        else if (c == Boolean.TYPE)
            return Boolean.class;
        else if (c == Byte.TYPE)
            return Byte.class;
        else if (c == Character.TYPE)
            return Character.class;
        else if (c == Short.TYPE)
            return Short.class;
        else if (c == Integer.TYPE)
            return Integer.class;
        else if (c == Long.TYPE)
            return Long.class;
        else if (c == Float.TYPE)
            return Float.class;
        else if (c == Double.TYPE)
            return Double.class;
        else
            throw new RuntimeException(new ClassNotFoundException());
    }
}

Related

  1. instanceOf(Object obj, String className)
  2. instanceOf(Object obj, String name)
  3. instanceOf(Object object, Class clazz)
  4. instanceOfAll(Object o, Class... clazzes)
  5. instanceofByteArray(Object o)