List of usage examples for java.util Collections emptySet
@SuppressWarnings("unchecked") public static final <T> Set<T> emptySet()
From source file:Main.java
public static <T> Set<T> unmodifiableSet(Set<? extends T> set) { if (set == null) { return Collections.emptySet(); } else {// w w w . j a v a 2 s . c o m return Collections.unmodifiableSet(set); } }
From source file:Main.java
public static <K, V> Set<V> getValueSet(Map<K, Set<V>> map, K key) { Set<V> values = map.get(key); if (values == null) return Collections.emptySet(); return values; }
From source file:Main.java
/** * Disables the forward and backward focus traversal keys on the given * component./*w w w . j a v a 2 s. c o m*/ */ public static void disableFocusTraversal(Component c) { Set<AWTKeyStroke> emptySet = Collections.emptySet(); c.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, emptySet); c.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, emptySet); }
From source file:Main.java
public static <T> Set<T> copyToLinkedHashSet(Collection<? extends T> src) { if (src.isEmpty()) { return Collections.emptySet(); }//from www .j ava2 s . co m return Collections.unmodifiableSet(new LinkedHashSet<T>(src)); }
From source file:Main.java
public static <T> Collection<T> nonNullCollection(final Collection<T> collection) { if (collection == null) { return Collections.emptySet(); }/*from w ww . j ava2 s .c o m*/ return collection; }
From source file:Main.java
public static <T> Set<T> safe(Set<T> l) { if (l == null) { return Collections.emptySet(); }//from ww w.j a va2 s . co m return l; }
From source file:Main.java
/** * Convert to Set - this operation removes the duplicates in original list. * @param list//from www . ja v a 2 s .c o m * @return */ public static <T> Set<T> converToSet(List<T> list) { if (list == null || list.isEmpty()) { return Collections.emptySet(); } return new HashSet<T>(list); }
From source file:Main.java
/** * Build an set.// w w w. j ava 2s . co m * * @param values * Values to be added in a set. * @return A set containing all given values. */ @SafeVarargs public static <T> Set<T> asSet(T... values) { if (values == null || values.length == 0) { return Collections.emptySet(); } else { // A lit bit higher than load factor int size = (int) Math.floor(values.length * 1.4); Set<T> set = new HashSet<>(size); for (T value : values) { set.add(value); } return set; } }
From source file:Main.java
public static <T> Set<T> toImmutableSet(Set<T> set) { switch (set.size()) { case 0:/*from w w w.java2 s .com*/ return Collections.emptySet(); case 1: return Collections.singleton(set.iterator().next()); default: return Collections.unmodifiableSet(set); } }
From source file:Main.java
/** * Returns an non null value based on the giving {@link Set} * * @param set//from w ww .jav a 2 s . co m * value to evaluate * @return the original value or an empty {@link Set} * @since 4.2 */ public static <T> Set<T> nonNullSet(@Nullable final Set<T> set) { return set == null ? Collections.emptySet() : set; }