Java Utililty Methods Collection Check

List of utility methods to do Collection Check

Description

The list of methods to do Collection Check are organized into topic(s).

Method

booleanisCollectionOrArray(final Class cls)
Returns true if the supplied class is a collection or an array.
return (cls.isArray() && byte[].class != cls) || Collection.class.isAssignableFrom(cls);
booleanisCollectionOrArray(final Object obj)
Return true for objects that are collections or arrays (i.e.
final Class<? extends Object> cls = obj.getClass();
return Collection.class.isAssignableFrom(cls) || cls.isArray();
booleanisCollectionOrArrayType(Class typeToCheck)
is Collection Or Array Type
return typeToCheck != null && (typeToCheck.isArray() || Collection.class.isAssignableFrom(typeToCheck));
booleanisCollectionType(Class aClass)
Determines if the given class is a Collection type.
return Collection.class.isAssignableFrom(aClass);
booleanisCollectionType(Class type)
Returns true if type is a collection type.
return List.class.isAssignableFrom(type) || Set.class.isAssignableFrom(type);
booleanisCollectionType(Class cls)
is Collection Type
if (cls.isArray()) {
    return true;
} else if (List.class.isAssignableFrom(cls)) {
    return true;
} else if (Set.class.isAssignableFrom(cls)) {
    return true;
} else if (Map.class.isAssignableFrom(cls)) {
    return true;
...
booleanisCollectionType(Class cls)
Checks if provided class represents an array class or is implementation of java.util.Collection .
return cls != null && (cls.isArray() || Collection.class.isAssignableFrom(cls));
booleanisCollectionType(Class type)
is Collection Type
return Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type);
booleanisCollectionType(final Class cls)
is Collection Type
return java.util.Collection.class.isAssignableFrom(cls);
booleanisCollectionType(Object obj)
is Collection Type
return (obj.getClass().isArray() || (obj instanceof Collection) || (obj instanceof Hashtable)
        || (obj instanceof HashMap) || (obj instanceof HashSet) || (obj instanceof List)
        || (obj instanceof AbstractMap));