@Deprecated public abstract class CollectionUtils extends Object
Plugins should prefer external collection frameworks over this class.
Internally, all code should use CollectionUtils
.
Modifier and Type | Class | Description |
---|---|---|
static class |
CollectionUtils.InjectionStep<T,I> |
Deprecated.
|
static class |
CollectionUtils.SetDiff<T> |
Deprecated.
The result of diffing two sets.
|
Constructor | Description |
---|---|
CollectionUtils() |
Deprecated.
|
Modifier and Type | Method | Description |
---|---|---|
static <T,C extends Collection<? super T>> |
addAll(C t1,
Iterable<? extends T> t2) |
Deprecated.
Utility for adding an iterable to a collection.
|
static <T,C extends Collection<? super T>> |
addAll(C t1,
T... t2) |
Deprecated.
Utility for adding an array to a collection.
|
static <T> boolean |
any(Iterable<? extends T> source,
Spec<? super T> filter) |
Deprecated.
|
static <T> boolean |
any(T[] source,
Spec<? super T> filter) |
Deprecated.
|
static String |
asCommandLine(Iterable<String> arguments) |
Deprecated.
|
static <T> Collection<? extends T> |
checkedCast(Class<T> type,
Collection<?> input) |
Deprecated.
|
static <R,I> |
collect(I[] list,
Transformer<? extends R,? super I> transformer) |
Deprecated.
|
static <R,I,C extends Collection<R>> |
collect(Iterable<? extends I> source,
C destination,
Transformer<? extends R,? super I> transformer) |
Deprecated.
|
static <R,I> |
collect(Iterable<? extends I> source,
Transformer<? extends R,? super I> transformer) |
Deprecated.
|
static <R,I> |
collect(Set<? extends I> set,
Transformer<? extends R,? super I> transformer) |
Deprecated.
|
static <R,I> |
collectArray(I[] list,
Class<R> newType,
Transformer<? extends R,? super I> transformer) |
Deprecated.
|
static <R,I> |
collectArray(I[] list,
R[] destination,
Transformer<? extends R,? super I> transformer) |
Deprecated.
|
static <K,V> |
collectMap(Iterable<? extends V> items,
Transformer<? extends K,? super V> keyGenerator) |
Deprecated.
Given a set of values, derive a set of keys and return a map
|
static <K,V> |
collectMap(Map<K,V> destination,
Iterable<? extends V> items,
Transformer<? extends K,? super V> keyGenerator) |
Deprecated.
|
static <K,V> |
collectMapValues(Iterable<? extends K> keys,
Transformer<? extends V,? super K> keyGenerator) |
Deprecated.
Given a set of keys, derive a set of values and return a map
|
static <K,V> |
collectMapValues(Map<K,V> destination,
Iterable<? extends K> keys,
Transformer<? extends V,? super K> keyGenerator) |
Deprecated.
|
static <E> List<E> |
compact(List<E> list) |
Deprecated.
|
static <T> CollectionUtils.SetDiff<T> |
diffSetsBy(Set<? extends T> left,
Set<? extends T> right,
Transformer<?,T> compareBy) |
Deprecated.
Provides a “diff report” of how the two sets are similar and how they are different, comparing the entries by some aspect.
|
static <T> boolean |
every(Iterable<? extends T> things,
Spec<? super T> predicate) |
Deprecated.
|
static <T,C extends Collection<T>> |
filter(Iterable<? extends T> source,
C destination,
Spec<? super T> filter) |
Deprecated.
|
static <T> List<T> |
filter(List<? extends T> list,
Spec<? super T> filter) |
Deprecated.
|
static <K,V> |
filter(Map<K,V> map,
Map<K,V> destination,
Spec<Map.Entry<K,V>> filter) |
Deprecated.
|
static <K,V> |
filter(Map<K,V> map,
Spec<Map.Entry<K,V>> filter) |
Deprecated.
|
static <T> Set<T> |
filter(Set<? extends T> set,
Spec<? super T> filter) |
Deprecated.
|
static <T> List<T> |
filter(T[] array,
Spec<? super T> filter) |
Deprecated.
|
static <T> T |
findFirst(Iterable<? extends T> source,
Spec<? super T> filter) |
Deprecated.
|
static <T> T |
findFirst(T[] source,
Spec<? super T> filter) |
Deprecated.
|
static <T> T |
findSingle(Iterable<T> source) |
Deprecated.
Returns null if the collection is empty otherwise expects a
single(Iterable) element to be found. |
static <T> T |
first(Iterable<? extends T> source) |
Deprecated.
|
static <T> List<T> |
flattenCollections(Class<T> type,
Object... things) |
Deprecated.
Recursively unpacks all the given things into a flat list, ensuring they are of a certain type.
|
static List<?> |
flattenCollections(Object... things) |
Deprecated.
Recursively unpacks all the given things into a flat list.
|
static <K,V> |
groupBy(Iterable<? extends V> iterable,
Transformer<? extends K,V> grouper) |
Deprecated.
|
static <T,I> |
inject(T target,
Iterable<? extends I> items,
Action<CollectionUtils.InjectionStep<T,I>> action) |
Deprecated.
|
static <T> List<T> |
intersection(Collection<? extends Collection<T>> availableValuesByDescriptor) |
Deprecated.
|
static String |
join(String separator,
Iterable<?> objects) |
Deprecated.
Creates a string with
toString() of each object with the given separator. |
static String |
join(String separator,
Object[] objects) |
Deprecated.
Creates a string with
toString() of each object with the given separator. |
static <T> List<T> |
nonEmptyOrNull(Iterable<T> iterable) |
Deprecated.
|
static <T> org.gradle.internal.Pair<Collection<T>,Collection<T>> |
partition(Iterable<T> items,
Spec<? super T> predicate) |
Deprecated.
Partition given Collection into a Pair of Collections.
|
static <E> boolean |
replace(List<E> list,
Spec<? super E> filter,
Transformer<? extends E,? super E> transformer) |
Deprecated.
|
static <T> T |
single(Iterable<? extends T> source) |
Deprecated.
Returns the single element in the collection or throws.
|
static <T> List<T> |
sort(Iterable<? extends T> things,
Comparator<? super T> comparator) |
Deprecated.
Returns a sorted copy of the provided collection of things.
|
static <T extends Comparable<T>> |
sort(Iterable<T> things) |
Deprecated.
Returns a sorted copy of the provided collection of things.
|
static <C extends Collection<String>> |
stringize(Iterable<?> source,
C destination) |
Deprecated.
|
static List<String> |
stringize(Collection<?> source) |
Deprecated.
|
static <T> List<T> |
toList(Iterable<? extends T> things) |
Deprecated.
|
static <T> List<T> |
toList(Enumeration<? extends T> things) |
Deprecated.
|
static <T> List<T> |
toList(T[] things) |
Deprecated.
|
static <T> Set<T> |
toSet(Iterable<? extends T> things) |
Deprecated.
|
static List<String> |
toStringList(Iterable<?> iterable) |
Deprecated.
|
static <T> Iterable<? extends T> |
unpack(Iterable<? extends org.gradle.internal.Factory<? extends T>> factories) |
Deprecated.
|
@Nullable public static <T> T findSingle(Iterable<T> source)
single(Iterable)
element to be found.public static <T> T single(Iterable<? extends T> source)
public static <T> Collection<? extends T> checkedCast(Class<T> type, Collection<?> input)
@Nullable public static <T> T findFirst(Iterable<? extends T> source, Spec<? super T> filter)
public static <T> T first(Iterable<? extends T> source)
public static <T> boolean any(Iterable<? extends T> source, Spec<? super T> filter)
public static <T> boolean any(T[] source, Spec<? super T> filter)
public static <T> List<T> filter(List<? extends T> list, Spec<? super T> filter)
public static <T> List<T> sort(Iterable<? extends T> things, Comparator<? super T> comparator)
public static <T extends Comparable<T>> List<T> sort(Iterable<T> things)
public static <T,C extends Collection<T>> C filter(Iterable<? extends T> source, C destination, Spec<? super T> filter)
public static <K,V> Map<K,V> filter(Map<K,V> map, Spec<Map.Entry<K,V>> filter)
public static <K,V> Map<K,V> filter(Map<K,V> map, Map<K,V> destination, Spec<Map.Entry<K,V>> filter)
public static <R,I> R[] collectArray(I[] list, Class<R> newType, Transformer<? extends R,? super I> transformer)
public static <R,I> R[] collectArray(I[] list, R[] destination, Transformer<? extends R,? super I> transformer)
public static <R,I> List<R> collect(I[] list, Transformer<? extends R,? super I> transformer)
public static <R,I> Set<R> collect(Set<? extends I> set, Transformer<? extends R,? super I> transformer)
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 <T> List<T> toList(Enumeration<? extends T> things)
public static <T> List<T> intersection(Collection<? extends Collection<T>> availableValuesByDescriptor)
public static <T> List<T> toList(T[] things)
public static <C extends Collection<String>> C stringize(Iterable<?> source, C destination)
public static List<String> stringize(Collection<?> source)
public static <E> boolean replace(List<E> list, Spec<? super E> filter, Transformer<? extends E,? super E> transformer)
public 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 <K,V> void collectMapValues(Map<K,V> destination, Iterable<? extends K> keys, Transformer<? extends V,? super K> keyGenerator)
public static <K,V> Map<K,V> collectMapValues(Iterable<? extends K> keys, Transformer<? extends V,? super K> keyGenerator)
public static <T> boolean every(Iterable<? extends T> things, Spec<? super T> predicate)
public static <T,C extends Collection<? super T>> C addAll(C t1, Iterable<? extends T> t2)
T
- The element type of t1t1
- The collection to add tot2
- The iterable to add each item of to the collectionpublic static <T,C extends Collection<? super T>> C addAll(C t1, T... t2)
T
- The element type of t1t1
- The collection to add tot2
- The iterable to add each item of to the collectionpublic 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 bypublic static String join(String separator, Object[] objects)
toString()
of each object with the given separator.
expect: join(",", new Object[]{"a"}) == "a" join(",", new Object[]{"a", "b", "c"}) == "a,b,c" join(",", new Object[]{}) == ""The
separator
must not be null and objects
must not be null.separator
- The string by which to join each string representationobjects
- The objects to join the string representations ofpublic static String join(String separator, Iterable<?> objects)
toString()
of each object with the given separator.
expect: join(",", ["a"]) == "a" join(",", ["a", "b", "c"]) == "a,b,c" join(",", []) == ""The
separator
must not be null and objects
must not be null.separator
- The string by which to join each string representationobjects
- The objects to join the string representations ofpublic static <T> org.gradle.internal.Pair<Collection<T>,Collection<T>> partition(Iterable<T> items, Spec<? super T> predicate)
LeftCollection containing entries that satisfy the given predicate
RightCollection containing entries that do NOT satisfy the given predicate
public static <T,I> T inject(T target, Iterable<? extends I> items, Action<CollectionUtils.InjectionStep<T,I>> action)
public static <K,V> Map<K,Collection<V>> groupBy(Iterable<? extends V> iterable, Transformer<? extends K,V> grouper)
public static <T> Iterable<? extends T> unpack(Iterable<? extends org.gradle.internal.Factory<? extends T>> factories)
@Nullable public static <T> List<T> nonEmptyOrNull(Iterable<T> iterable)