public static boolean isPrimitive(Object obj) {
        Class[] primitives = new Class[] { boolean.class, byte.class, char.class, short.class,
                                           int.class, long.class, float.class, double.class };

        for (Class<?> c : primitives)
            if (c.isAssignableFrom(obj.getClass()))
                return true;

        return false;
    }