Package org.okkam.awesome.utils
Class OkkamSets
- java.lang.Object
-
- org.okkam.awesome.utils.OkkamSets
-
public class OkkamSets extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Set<T>addIfNotNull(Set<T> set, T element)Add if not empty.static <T> Set<T>addSafeToHashSet(Set<T> set, T... elements)Add elements to the HashSet.static <T> Set<T>createHashSetIfNull(Set<T> set)Create an HashSet if the Set is null.
-
-
-
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 setelement- 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 setelements- The elements to add- Returns:
- The set initialized with elements (if empty) or the input one adding elements.
-
-