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

booleanisCollectionType(Object obj)
This method checks whether the JSON being parse is a container class.
if (obj instanceof List<?>) {
    return true;
} else if (obj instanceof Collection<?>) {
    return true;
return false;
booleanisCollectionType(Object propertyValue)
is Collection Type
return propertyValue.getClass().isAssignableFrom(Collection.class)
        || Collection.class.isInstance(propertyValue);
booleanisCollectionType(Object value)
is Collection Type
return value instanceof Collection;
booleanisCollectionTypeHomogenous(final Collection collection, final Class expectedType)
is Collection Type Homogenous
for (final Object object : collection) {
    if (object == null) {
        continue;
    } else if (!expectedType.isAssignableFrom(object.getClass())) {
        return false;
return true;
...
booleanisCompatibleTypes(Collection a, Collection b)
is Compatible Types
return isOrdered(a) == isOrdered(b);