Class MutableCollections


  • public class MutableCollections
    extends Object
    Convenience Methods for handling mutable Collections.
    Author:
    mbrooks
    • Constructor Detail

      • MutableCollections

        public MutableCollections()
    • Method Detail

      • copyListFromNullable

        public static <T> List<T> copyListFromNullable​(Collection<T> toCopy,
                                                       java.util.function.Supplier<List<T>> listSupplier)
        Copy a Collection to a List.
        Parameters:
        toCopy - the Collection to copy
        listSupplier - the supplier for the desired List type
        Returns:
        a new List containing the same elements as the given Collection
      • copyListFromNullable

        public static <T> List<T> copyListFromNullable​(Collection<T> toCopy)
      • copyMapFromNullable

        public static <T,​S> Map<T,​S> copyMapFromNullable​(Map<T,​S> toCopy,
                                                                     java.util.function.Supplier<Map<T,​S>> mapSupplier)
        Copy a Map.
        Parameters:
        toCopy - the Map to copy
        mapSupplier - the supplier for the desired Map type
        Returns:
        a new Map containing the same elements as the given Map
      • copyMapFromNullable

        public static <T,​S> Map<T,​S> copyMapFromNullable​(Map<T,​S> toCopy)