public final class CollectionUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CollectionUtils.SetDiff<T>
The result of diffing two sets.
|
Modifier and Type | Method and Description |
---|---|
static <R,I,C extends Collection<R>> |
collect(Iterable<? extends I> source,
C destination,
Transformer<? extends R,? super I> transformer) |
static <R,I> List<R> |
collect(Iterable<? extends I> source,
Transformer<? extends R,? super I> transformer) |
static <K,V> Map<K,V> |
collectMap(Iterable<? extends V> items,
Transformer<? extends K,? super V> keyGenerator)
Given a set of values, derive a set of keys and return a map
|
static <K,V> void |
collectMap(Map<K,V> destination,
Iterable<? extends V> items,
Transformer<? extends K,? super V> keyGenerator) |
static <T> CollectionUtils.SetDiff<T> |
diffSetsBy(Set<? extends T> left,
Set<? extends T> right,
Transformer<?,T> compareBy)
Provides a “diff report” of how the two sets are similar and how they are different, comparing the entries by some aspect.
|
static <T> T |
findFirst(Iterable<? extends T> source,
Spec<? super T> filter) |
static <T> List<T> |
flattenCollections(Class<T> type,
Object... things)
Recursively unpacks all the given things into a flat list, ensuring they are of a certain type.
|
static List<?> |
flattenCollections(Object... things)
Recursively unpacks all the given things into a flat list.
|
static <T> Set<T> |
toSet(Iterable<? extends T> things) |
@Nullable public static <T> T findFirst(Iterable<? extends T> source, Spec<? super T> filter)
public static <R,I> List<R> collect(Iterable<? extends I> source, Transformer<? extends R,? super I> transformer)
public static <R,I,C extends Collection<R>> C collect(Iterable<? extends I> source, C destination, Transformer<? extends R,? super I> transformer)
public static List<?> flattenCollections(Object... things)
things
- The things to flattenpublic static <T> List<T> flattenCollections(Class<T> type, Object... things)
T
- The target type in the flattened listthings
- The things to flattenpublic static <K,V> void collectMap(Map<K,V> destination, Iterable<? extends V> items, Transformer<? extends K,? super V> keyGenerator)
public static <K,V> Map<K,V> collectMap(Iterable<? extends V> items, Transformer<? extends K,? super V> keyGenerator)
public static <T> CollectionUtils.SetDiff<T> diffSetsBy(Set<? extends T> left, Set<? extends T> right, Transformer<?,T> compareBy)
T
- The type of the entry objectsleft
- The set on the “left” side of the comparison.right
- The set on the “right” side of the comparison.compareBy
- Provides the value to compare entries from either side by