api / org.gradle.api / DomainObjectCollection / matching

matching

abstract fun matching(spec: Spec<in T>): DomainObjectCollection<T>

Returns a collection which contains the objects in this collection which meet the given specification. The returned collection is live, so that when matching objects are added to this collection, they are also visible in the filtered collection.

Parameters

spec - The specification to use.

Return
The collection of matching objects. Returns an empty collection if there are no such objects in this collection.

abstract fun matching(spec: Closure<Any>): DomainObjectCollection<T>

Returns a collection which contains the objects in this collection which meet the given closure specification. The returned collection is live, so that when matching objects are added to this collection, they are also visible in the filtered collection.

Parameters

spec - The specification to use. The closure gets a collection element as an argument.

Return
The collection of matching objects. Returns an empty collection if there are no such objects in this collection.