Class CollectionUtils


  • public final class CollectionUtils
    extends Object
    Utilities for working with collections.
    • Method Detail

      • copyOfOrEmpty

        public static <T> List<T> copyOfOrEmpty​(List<T> values)
        Create an unmodifiable copy of a list or return an empty list if the input is null. List elements may be null.
        Type Parameters:
        T - element type
        Parameters:
        values - source list
        Returns:
        unmodifiable list copy or empty list
      • copyOfOrEmpty

        public static <K,​V> Map<K,​V> copyOfOrEmpty​(Map<K,​V> values)
        Create an unmodifiable copy of a map or return an empty map if the input is null. Map keys and values may be null.

        Preserves the iteration order of the input map.

        Type Parameters:
        K - key type
        V - value type
        Parameters:
        values - source map
        Returns:
        unmodifiable map copy or empty map