Class ContainerUtils


  • public class ContainerUtils
    extends Object
    Utilities for containers
    • Constructor Detail

      • ContainerUtils

        public ContainerUtils()
    • Method Detail

      • wrapInUnmodifiableCollectionUnlessNull

        public static <T extends Collection<?>> T wrapInUnmodifiableCollectionUnlessNull​(T collection,
                                                                                         Function<T,​T> wrapInUnmodifiable)
        Given the colletion and mapping to unmodifiable version of the collection check if not null and then apply the wrapping
        Type Parameters:
        T - type of collection
        Parameters:
        collection - to wrap
        wrapInUnmodifiable - function to perform wrapping
        Returns:
        wrapped collection
      • wrapInUnmodifiableListUnlessNull

        public static <T> List<T> wrapInUnmodifiableListUnlessNull​(List<T> list)
        Wrap in an unmodifiable version unless it is null, then return null
        Type Parameters:
        T - type of entries
        Parameters:
        list - to wrap
        Returns:
        wrapped list, or null
      • wrapInUnmodifiableSetUnlessNull

        public static <T> Set<T> wrapInUnmodifiableSetUnlessNull​(Set<T> set)
        Wrap in an unmodifiable version unless it is null, then return null
        Type Parameters:
        T - type of entries
        Parameters:
        set - to wrap
        Returns:
        wrapped set, or null
      • wrapInUnmodifiableSortedSetUnlessNull

        public static <T> SortedSet<T> wrapInUnmodifiableSortedSetUnlessNull​(SortedSet<T> sortedSet)
        Wrap in an unmodifiable version unless it is null, then return null
        Type Parameters:
        T - type of entries
        Parameters:
        sortedSet - to wrap
        Returns:
        wrapped set, or null