CollectionUtils

abstract class CollectionUtils(source)

Deprecated

This class is only here to maintain binary compatibility with existing plugins.

Plugins should prefer external collection frameworks over this class. Internally, all code should use org.gradle.util.internal.CollectionUtils.

Deprecated

Will be removed in Gradle 9.0.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
open class InjectionStep<T, I>
Injection step.
Link copied to clipboard
open class SetDiff<T>
The result of diffing two sets.

Functions

Link copied to clipboard
open fun <T, C : Collection<in T>?> addAll(t1: C, t2: Array<T>): C
Utility for adding an array to a collection.
open fun <T, C : Collection<in T>?> addAll(t1: C, t2: Iterable<out T>): C
Utility for adding an iterable to a collection.
Link copied to clipboard
open fun <T> any(source: Array<T>, filter: Spec<in T>): Boolean
open fun <T> any(source: Iterable<out T>, filter: Spec<in T>): Boolean
Link copied to clipboard
open fun asCommandLine(arguments: Iterable<String>): String
Link copied to clipboard
open fun <T> checkedCast(type: Class<T>, input: Collection<out Any>): Collection<out T>
Link copied to clipboard
open fun <R, I> collect(list: Array<I>, transformer: Transformer<out R, in I>): List<R>
open fun <R, I> collect(source: Iterable<out I>, transformer: Transformer<out R, in I>): List<R>
open fun <R, I> collect(set: Set<out I>, transformer: Transformer<out R, in I>): Set<R>
open fun <R, I, C : Collection<R>?> collect(source: Iterable<out I>, destination: C, transformer: Transformer<out R, in I>): C
Link copied to clipboard
open fun <R, I> collectArray(list: Array<I>, destination: Array<R>, transformer: Transformer<out R, in I>): Array<R>
open fun <R, I> collectArray(list: Array<I>, newType: Class<R>, transformer: Transformer<out R, in I>): Array<R>
Link copied to clipboard
open fun <K, V> collectMap(items: Iterable<out V>, keyGenerator: Transformer<out K, in V>): Map<K, V>
Given a set of values, derive a set of keys and return a map
open fun <K, V> collectMap(destination: Map<K, V>, items: Iterable<out V>, keyGenerator: Transformer<out K, in V>)
Link copied to clipboard
open fun <K, V> collectMapValues(keys: Iterable<out K>, keyGenerator: Transformer<out V, in K>): Map<K, V>
Given a set of keys, derive a set of values and return a map
open fun <K, V> collectMapValues(destination: Map<K, V>, keys: Iterable<out K>, keyGenerator: Transformer<out V, in K>)
Link copied to clipboard
open fun <E> compact(list: List<E>): List<E>
Link copied to clipboard
open fun <T> diffSetsBy(left: Set<out T>, right: Set<out T>, compareBy: Transformer<out Any, T>): CollectionUtils.SetDiff<T>
Provides a “diff report” of how the two sets are similar and how they are different, comparing the entries by some aspect.
Link copied to clipboard
open fun <T> every(things: Iterable<out T>, predicate: Spec<in T>): Boolean
Link copied to clipboard
open fun <T> filter(array: Array<T>, filter: Spec<in T>): List<T>
open fun <T> filter(list: List<out T>, filter: Spec<in T>): List<T>
open fun <K, V> filter(map: Map<K, V>, filter: Spec<Map.Entry<K, V>>): Map<K, V>
open fun <T> filter(set: Set<out T>, filter: Spec<in T>): Set<T>
open fun <T, C : Collection<T>?> filter(source: Iterable<out T>, destination: C, filter: Spec<in T>): C
open fun <K, V> filter(map: Map<K, V>, destination: Map<K, V>, filter: Spec<Map.Entry<K, V>>): Map<K, V>
Link copied to clipboard
@Nullable
open fun <T> findFirst(source: Array<T>, filter: Spec<in T>): T
@Nullable
open fun <T> findFirst(source: Iterable<out T>, filter: Spec<in T>): T
Link copied to clipboard
@Nullable
open fun <T> findSingle(source: Iterable<T>): T
Returns null if the collection is empty otherwise expects a single element to be found.
Link copied to clipboard
open fun <T> first(source: Iterable<out T>): T
Link copied to clipboard
open fun flattenCollections(things: Array<Any>): List<out Any>
Recursively unpacks all the given things into a flat list.
open fun <T> flattenCollections(type: Class<T>, things: Array<Any>): List<T>
Recursively unpacks all the given things into a flat list, ensuring they are of a certain type.
Link copied to clipboard
open fun <K, V> groupBy(iterable: Iterable<out V>, grouper: Transformer<out K, V>): Map<K, Collection<V>>
Link copied to clipboard
open fun <T, I> inject(target: T, items: Iterable<out I>, action: Action<CollectionUtils.InjectionStep<T, I>>): T
Link copied to clipboard
open fun <T> intersection(availableValuesByDescriptor: Collection<out Collection<T>>): List<T>
Link copied to clipboard
open fun join(separator: String, objects: Iterable<out Any>): String
open fun join(separator: String, objects: Array<Any>): String
Creates a string with toString() of each object with the given separator.
Link copied to clipboard
@Nullable
open fun <T> nonEmptyOrNull(iterable: Iterable<T>): List<T>
Link copied to clipboard
open fun <T> partition(items: Iterable<T>, predicate: Spec<in T>): Pair<Collection<T>, Collection<T>>
Partition given Collection into a Pair of Collections.
Link copied to clipboard
open fun <E> replace(list: List<E>, filter: Spec<in E>, transformer: Transformer<out E, in E>): Boolean
Link copied to clipboard
open fun <T> single(source: Iterable<out T>): T
Returns the single element in the collection or throws.
Link copied to clipboard
open fun <T : Comparable<T>?> sort(things: Iterable<T>): List<T>
open fun <T> sort(things: Iterable<out T>, comparator: Comparator<in T>): List<T>
Returns a sorted copy of the provided collection of things.
Link copied to clipboard
open fun stringize(source: Collection<out Any>): List<String>
open fun <C : Collection<String>?> stringize(source: Iterable<out Any>, destination: C): C
Link copied to clipboard
open fun <T> toList(things: Array<T>): List<T>
open fun <T> toList(things: Iterable<out T>): List<T>
open fun <T> toList(things: Enumeration<out T>): List<T>
Link copied to clipboard
open fun <T> toSet(things: Iterable<out T>): Set<T>
Link copied to clipboard
open fun toStringList(iterable: Iterable<out Any>): List<String>
Link copied to clipboard
open fun <T> unpack(factories: Iterable<out Factory<out T>>): Iterable<out T>