gradle
8.2

# maybeCreate

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

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