/** * Checks whether or not given class should be excluded from marshalling. * * @param cls Class to check. * @return {@code true} if class should be excluded, {@code false} otherwise. */ public static boolean isExcluded(Class<?> cls) { assert cls != null; for (Class<?> c : INCL_CLASSES) { if (c.isAssignableFrom(cls)) { return false; } } for (Class<?> c : EXCL_CLASSES) { if (c.isAssignableFrom(cls)) { return true; } } return false; }
/** Check if the given collection is a uniform collection of the given type. */ public static boolean isUniformCollection(Collection<?> c, Class<?> e) { if (e == null) { throw new IllegalArgumentException("Null reference type"); } if (c == null) { throw new IllegalArgumentException("Null collection"); } if (c.isEmpty()) { return false; } for (Object o : c) { if (o == null || !e.isAssignableFrom(o.getClass())) { return false; } } return true; }