public class MoreCollections extends Object
Collections| Modifier and Type | Method and Description |
|---|---|
static NavigableSet<String> |
caseIgnoringSet()
Returns an empty case-ignoring
NavigableSet. |
static NavigableSet<String> |
caseIgnoringSet(Collection<String> strings)
Returns a case-ignoring
NavigableSet containing the given strings. |
static <T> Map<T,Integer> |
countFrequencies(Collection<T> collection)
Returns an immutable map containing the distinct values of the given collection as keys and their frequency as values.
|
static <E> Collection<E> |
emptyToNull(Collection<E> collection)
Returns the given collection if it is non-empty,
null otherwise. |
static <E> boolean |
isNullOrEmpty(Collection<E> collection)
Checks whether the given collection is
null or empty. |
static <E> List<E> |
nullToEmpty(List<E> set)
Returns the given list if it is non-empty, empty list otherwise.
|
static <E> NavigableSet<E> |
nullToEmpty(NavigableSet<E> navigableSet)
Returns the given navigable set if it is non-empty, empty navigable set otherwise.
|
static <E> Set<E> |
nullToEmpty(Set<E> set)
Returns the given set if it is non-empty, empty set otherwise.
|
static <K,V extends Comparable<V>> |
sortByValues(Map<K,V> map)
Returns an immutable map containing the mappings in the given map sorted by their values.
|
static <K,V> Map<K,V> |
sortByValues(Map<K,V> map,
Comparator<V> comparator)
Returns an immutable map containing the mappings in the given map sorted by their values.
|
public static <T> Map<T,Integer> countFrequencies(Collection<T> collection)
IllegalArgumentException - if collection is nullpublic static NavigableSet<String> caseIgnoringSet()
NavigableSet.public static NavigableSet<String> caseIgnoringSet(Collection<String> strings)
NavigableSet containing the given strings.IllegalArgumentException - if strings are nullpublic static <E> Collection<E> emptyToNull(Collection<E> collection)
null otherwise.public static <E> boolean isNullOrEmpty(Collection<E> collection)
null or empty.public static <E> List<E> nullToEmpty(List<E> set)
public static <E> NavigableSet<E> nullToEmpty(NavigableSet<E> navigableSet)
public static <E> Set<E> nullToEmpty(Set<E> set)
public static <K,V extends Comparable<V>> Map<K,V> sortByValues(Map<K,V> map)
IllegalArgumentException - if map is nullpublic static <K,V> Map<K,V> sortByValues(Map<K,V> map, Comparator<V> comparator)
IllegalArgumentException - if map is nullIllegalArgumentException - if comparator is null