public class CollectionUtil extends Object
Modifier and Type | Class | Description |
---|---|---|
static class |
CollectionUtil.DefaultingMap<K,V> |
A defaulting map, which returns a default value when a value that does not exist in the map is looked up.
|
static class |
CollectionUtil.MultiMap<K,V> |
Simple multi-map for convenience of storing collections in map values.
|
static class |
CollectionUtil.Partitioner<V,K> |
Deprecated.
use Collectors.groupingBy instead
|
Modifier and Type | Field | Description |
---|---|---|
static Comparator<Object> |
OBJECT_TOSTRING_COMPARATOR |
Simple case-insensitive lexical comparator of objects using their
Object.toString() value. |
Constructor | Description |
---|---|
CollectionUtil() |
Modifier and Type | Method | Description |
---|---|---|
static <T> T |
getSoleElement(Collection<T> items) |
|
static String |
join(Collection<?> items,
String inBetween) |
Construct a string by toString()ing each item in the collection with inBetween between each item.
|
static <T> Collection<T> |
makeCollection(Iterator<T> i) |
|
static <T> List<T> |
makeList(T... list) |
|
static <T> Set<T> |
makeSet(T... list) |
|
static <K,V> Map<K,Collection<V>> |
partition(Collection<V> collection,
CollectionUtil.Partitioner<V,K> p) |
Deprecated.
use java8 .stream().collect(Collectors.groupingBy(()-> function)) instead
|
static <K,V> Map<K,Collection<V>> |
partition(Collection<V> collection,
Function<? super V,? extends K> keyer) |
Partitions a collection into groups based on a characteristics of that group.
|
public static final Comparator<Object> OBJECT_TOSTRING_COMPARATOR
Object.toString()
value.public static <T> List<T> makeList(T... list)
public static <T> Set<T> makeSet(T... list)
public static <T> Collection<T> makeCollection(Iterator<T> i)
public static String join(Collection<?> items, String inBetween)
public static <T> T getSoleElement(Collection<T> items)
@Deprecated public static <K,V> Map<K,Collection<V>> partition(Collection<V> collection, CollectionUtil.Partitioner<V,K> p)
public static <K,V> Map<K,Collection<V>> partition(Collection<V> collection, Function<? super V,? extends K> keyer)