api / org.gradle.api / DomainObjectCollection / withType

withType

abstract fun <S : T> withType(type: Class<S>): DomainObjectCollection<S>

Returns a collection containing the objects in this collection of the given type. The returned collection is live, so that when matching objects are later added to this collection, they are also visible in the filtered collection.

Parameters

type - The type of objects to find.

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

abstract fun <S : T> withType(type: Class<S>, configureAction: Action<in S>): DomainObjectCollection<S>

Returns a collection containing the objects in this collection of the given type. Equivalent to calling withType(type).all(configureAction)

Parameters

type - The type of objects to find.

configureAction - The action to execute for each object in the resulting collection.

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

abstract fun <S : T> withType(type: Class<S>, configureClosure: Closure<Any>): DomainObjectCollection<S>

Returns a collection containing the objects in this collection of the given type. Equivalent to calling withType(type).all(configureClosure).

Parameters

type - The type of objects to find.

configureClosure - The closure to execute for each object in the resulting collection.

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