# maybeCreate

inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.maybeCreate(name: String, type: KClass<U>): U(source)
inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.maybeCreate(name: String, type: KClass<U>): U(source)

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.PolymorphicDomainObjectContainer.maybeCreate.

#### See also

org.gradle.api.PolymorphicDomainObjectContainer.maybeCreate

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

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

#### Return

the created domain object

#### Parameters

name

the name of the domain object to be created

the type of the domain object to be created

#### Throws

InvalidUserDataException

if a domain object with the specified name already exists or the container does not support creating a domain object with the specified type

ClassCastException

if a domain object with the specified name exists with a different type