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,
org.gradle.api.Transformer<? extends R,? super I> transformer) |
static <R,I> List<R> |
collect(Iterable<? extends I> source,
org.gradle.api.Transformer<? extends R,? super I> transformer) |
static <K,V> Map<K,V> |
collectMap(Iterable<? extends V> items,
org.gradle.api.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,
org.gradle.api.Transformer<? extends K,? super V> keyGenerator)
Given a set of values, derive a set of keys and populate a map.
|
static <T> CollectionUtils.SetDiff<T> |
diffSetsBy(Set<? extends T> left,
Set<? extends T> right,
org.gradle.api.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,
org.gradle.api.specs.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, org.gradle.api.specs.Spec<? super T> filter)
public static <R,I> List<R> collect(Iterable<? extends I> source, org.gradle.api.Transformer<? extends R,? super I> transformer)
public static <R,I,C extends Collection<R>> C collect(Iterable<? extends I> source, C destination, org.gradle.api.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 listtype - Class token for the target type <T> in the flattened listthings - The things to flattenpublic static <K,V> void collectMap(Map<K,V> destination, Iterable<? extends V> items, org.gradle.api.Transformer<? extends K,? super V> keyGenerator)
K - The type of the keysV - The type of the valuesdestination - The map to populateitems - The values to derive keys fromkeyGenerator - The function to derive keys from the valuespublic static <K,V> Map<K,V> collectMap(Iterable<? extends V> items, org.gradle.api.Transformer<? extends K,? super V> keyGenerator)
K - The type of the keysV - The type of the valuesitems - The values to derive keys fromkeyGenerator - The function to derive keys from the valuespublic static <T> CollectionUtils.SetDiff<T> diffSetsBy(Set<? extends T> left, Set<? extends T> right, org.gradle.api.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