gradle
8.6

# maybeCreate

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

Looks for an item with the given name and type, creating and adding it to this container if it does not exist.

#### Return

the found or created domain object, never `null`.

#### Parameters

name

the name of the domain object to be created

type

the type of the domain object to be created

<U>

the type of the domain object to be created

#### Throws

InvalidUserDataException

if 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