Class OkkamSets


  • public class OkkamSets
    extends Object
    • Method Detail

      • addIfNotNull

        public static <T> Set<T> addIfNotNull​(Set<T> set,
                                              T element)
        Add if not empty.
        Type Parameters:
        T - The Set and element type
        Parameters:
        set - The input set
        element - The element to add
        Returns:
        The null set or the input one
      • createHashSetIfNull

        public static <T> Set<T> createHashSetIfNull​(Set<T> set)
        Create an HashSet if the Set is null.
        Type Parameters:
        T - The Set type
        Parameters:
        set - The input set
        Returns:
        The empty set or the input one.
      • addSafeToHashSet

        @SafeVarargs
        public static <T> Set<T> addSafeToHashSet​(Set<T> set,
                                                  T... elements)
        Add elements to the HashSet. Create a new HashSet if the Set is null (initialized with elements).
        Type Parameters:
        T - The Set type
        Parameters:
        set - The input set
        elements - The elements to add
        Returns:
        The set initialized with elements (if empty) or the input one adding elements.