List of utility methods to do Set Create
Set | toSet(Object[] someElements) to Set Set asSet = new HashSet(someElements.length); for (int i = 0; i < someElements.length; i++) asSet.add(someElements[i]); return asSet; |
Set | toSet(Set> set) to Set Set<T> setOfType = new HashSet<T>(set.size()); Iterator<?> iter = set.iterator(); while (iter.hasNext()) { T element = (T) iter.next(); setOfType.add(element); return setOfType; |
Set | toSet(String[] aStringArray) Converts a string array to a set of strings. Set<String> set = new LinkedHashSet<>(); if (aStringArray != null) { Collections.addAll(set, aStringArray); return set; |
Set | toSet(T... objects) Create an Object Set from the supplied objects. Set<T> theSet = new HashSet<T>(); addToCollection(theSet, objects); return theSet; |
Set | unmodifiableSet(final Set extends T> s, final boolean newSet, final boolean emptyAsNull) unmodifiable Set if (s == null) { return null; if (emptyAsNull && s.isEmpty()) { return null; return Collections.unmodifiableSet(newSet ? new HashSet<>(s) : s); |