Class CollectionUtils


  • public class CollectionUtils
    extends Object
    Utility methods to work with collections.
    • Constructor Detail

      • CollectionUtils

        public CollectionUtils()
    • Method Detail

      • copyOfOrEmpty

        public static <T> com.google.common.collect.ImmutableList<T> copyOfOrEmpty​(@Nullable
                                                                                   List<T> input)
        Creates an immutable list with the elements of the given list. If the input list is null, it returns an empty list.
        Parameters:
        input - The list used to build the immutable one.
        Returns:
        An immutable list with the elements of the given list.
      • copyOfOrEmpty

        public static <T> com.google.common.collect.ImmutableSet<T> copyOfOrEmpty​(@Nullable
                                                                                  Set<T> input)
        Creates an immutable set with the elements of the given set. If the input set is null, it returns an empty set.
        Parameters:
        input - The set used to build the immutable one.
        Returns:
        An immutable set with the elements of the given set.
      • copyOfOrEmpty

        public static <K,​V> com.google.common.collect.ImmutableMap<K,​V> copyOfOrEmpty​(@Nullable
                                                                                                  Map<K,​V> input)
        Creates an immutable map with the elements of the given map. If the input map is null, it returns an empty map.
        Parameters:
        input - The map used to build the immutable one.
        Returns:
        An immutable map with the elements of the given map.