api / org.gradle.kotlin.dsl / NamedDomainObjectContainerScope

NamedDomainObjectContainerScope

class NamedDomainObjectContainerScope<T : Any> : NamedDomainObjectContainer<T>, PolymorphicDomainObjectContainer<T>

Receiver for NamedDomainObjectContainer configuration blocks.

Constructors

<init>

NamedDomainObjectContainerScope(container: NamedDomainObjectContainer<T>)

Receiver for NamedDomainObjectContainer configuration blocks.

Functions

containerWithType

fun <U : T> containerWithType(type: Class<U>): NamedDomainObjectContainer<U>

create

fun <U : T> create(name: String, type: Class<U>): U
fun <U : T> create(name: String, type: Class<U>, configuration: Action<in U>): U

invoke

operator fun String.invoke(configuration: T.() -> Unit): T
operator fun String.invoke(): T
operator fun <U : T> String.invoke(type: KClass<U>, configuration: U.() -> Unit): U
operator fun <U : T> String.invoke(type: KClass<U>): U

maybeCreate

fun <U : T> maybeCreate(name: String, type: Class<U>): U

Extension Properties

creating

val <T : Any> NamedDomainObjectContainer<T>.creating: NamedDomainObjectContainerDelegateProvider<T>

Provides a property delegate that creates elements of the default collection type.

Extension Functions

closureOf

fun <T> Any.closureOf(action: T.() -> Unit): Closure<Any?>

Adapts a Kotlin function to a single argument Groovy Closure.

create

fun <U : Any> PolymorphicDomainObjectContainer<in U>.create(name: String, configuration: U.() -> Unit): U

Creates a domain object with the specified name and type, adds it to the container, and configures it with the specified action.

fun <U : Any> PolymorphicDomainObjectContainer<in U>.create(name: String): U

Creates a domain object with the specified name and type, and adds it to the container.

creating

fun <T : Any> NamedDomainObjectContainer<T>.creating(configuration: T.() -> Unit): NamedDomainObjectContainerDelegateProvider<T>

Provides a property delegate that creates elements of the default collection type with the given configuration.

creating

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: KClass<U>): PolymorphicDomainObjectContainerDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type.

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: KClass<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type with the given configuration.

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: Class<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type expressed as a java.lang.Class with the given configuration.

delegateClosureOf

fun <T> Any.delegateClosureOf(action: T.() -> Unit): Closure<Unit>

Adapts a Kotlin function to a Groovy Closure that operates on the configured Closure delegate.

get

operator fun <T : Any> NamedDomainObjectCollection<T>.get(name: String): T

Locates an object by name, failing if there is no such object.

getByName

fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String): T

Locates an object by name and casts it to the expected type T.

fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, type: KClass<T>): T

Locates an object by name and casts it to the expected type.

fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, configure: T.() -> Unit): T

Locates an object by name and casts it to the expected type T then configures it.

getValue

operator fun <T : Any, U : T> NamedDomainObjectCollection<T>.getValue(thisRef: Any?, property: KProperty<*>): U

Allows a NamedDomainObjectCollection to be used as a property delegate.

getting

fun <T : Any, U : T> NamedDomainObjectContainer<T>.getting(type: KClass<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerGettingDelegateProvider<T, U>

Provides a property delegate that gets elements of the given type and applies the given configuration.

fun <T : Any, U : T> NamedDomainObjectContainer<T>.getting(type: KClass<U>): PolymorphicDomainObjectContainerGettingDelegate<T, U>

Provides a property delegate that gets elements of the given type.

maybeCreate

fun <U : Any> PolymorphicDomainObjectContainer<in U>.maybeCreate(name: String): U

Creates a domain object with the specified name and type if it does not exists, and adds it to the container.

withConvention

fun <ConventionType : Any, ReturnType> Any.withConvention(conventionType: KClass<ConventionType>, function: ConventionType.() -> ReturnType): ReturnType

Evaluates the given function against the convention plugin of the given conventionType.

withGroovyBuilder

fun <T> Any.withGroovyBuilder(builder: GroovyBuilderScope.() -> T): T

Executes the given builder against this object's GroovyBuilderScope.

withType

fun <S : Any> DomainObjectCollection<in S>.withType(configuration: S.() -> Unit): DomainObjectCollection<S>

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

fun <S : Any> DomainObjectCollection<in S>.withType(): 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.