utility/src/main/java/io/tracee/contextlogger/utility/ListUtilities.java
public static <T> List<T> getListOfType(Object instance, Class<T> elementType) {

        if (instance == null || elementType == null || !isListOfType(instance, elementType)) {
            return null;
        }

        try {
            return (List<T>) instance;
        } catch (ClassCastException e) {
            return null;
        }

    }
public static <T> List<T> getListOfType(Object instance, Class<T> elementType) {

        if (instance == null || elementType == null || !isListOfType(instance, elementType)) {
            return null;
        }

        try {
            return (List<T>) instance;
        } catch (ClassCastException e) {
            return null;
        }

    }
Check if the passed instance is a {@link java.util.List} and contains only elements of the passed element types.
In that case it casts the passed instance to a List of the passed element type.

@param instance
@return The instance cast to a List of the passed element type if the passed instance is a list and only contains
element of the passed element type, otherwise it return null.