# PolymorphicDomainObjectContainer

API Documentation: | `PolymorphicDomainObjectContainer`

Known Subtypes: |
`AuthenticationContainer`
`PlayDistributionContainer`

Note: This class is incubating and may change in a future version of Gradle.

A `NamedDomainObjectContainer` that allows to create domain objects with different types.

### Properties

No properties

### Methods

Method | Description
`containerWithType(type)` | Incubating Creates a regular container that wraps the polymorphic container presenting all elements of a specified type.
`create(name)` | Creates a new item with the given name, adding it to this container.
`create(name, configureClosure)` | Creates a new item with the given name, adding it to this container, then configuring it with the given closure.
`create(name, type)` | Incubating Creates a domain object with the specified name and type, and adds it to the container.
`create(name, type, configuration)` | Incubating Creates a domain object with the specified name and type, adds it to the container, and configures it with the specified action.
`create(name, configureAction)` | Creates a new item with the given name, adding it to this container, then configuring it with the given action.
`getAt(name)` | Locates an object by name, failing if there is no such task. This method is identical to `NamedDomainObjectCollection.getByName(java.lang.String)`. You can call this method in your build script by using the groovy `[]` operator.
`getByName(name)` | Locates an object by name, failing if there is no such object.
`getByName(name, configureClosure)` | Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.
`maybeCreate(name)` | Looks for an item with the given name, creating and adding it to this container if it does not exist.
`maybeCreate(name, type)` | Incubating Looks for an item with the given name and type, creating and adding it to this container if it does not exist.

### Script blocks

No script blocks

### Method details

#### ``NamedDomainObjectContainer`<`U`>` `containerWithType`(``Class`<`U`>` type)

Note: This method is incubating and may change in a future version of Gradle.

Creates a regular container that wraps the polymorphic container presenting all elements of a specified type.

#### `T` `create`(`String` name)

Creates a new item with the given name, adding it to this container.

#### `T` `create`(`String` name, `Closure` configureClosure)

Creates a new item with the given name, adding it to this container, then configuring it with the given closure.

#### `U` `create`(`String` name, ``Class`<`U`>` type)

Note: This method is incubating and may change in a future version of Gradle.

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

#### `U` `create`(`String` name, ``Class`<`U`>` type, ``Action`<? super `U`>` configuration)

Note: This method is incubating and may change in a future version of Gradle.

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

#### `T` `create`(`String` name, ``Action`<? super `T`>` configureAction)

Creates a new item with the given name, adding it to this container, then configuring it with the given action.

#### `T` `getAt`(`String` name)

Locates an object by name, failing if there is no such task. This method is identical to `NamedDomainObjectCollection.getByName(java.lang.String)`. You can call this method in your build script by using the groovy `[]` operator.

#### `T` `getByName`(`String` name)

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

#### `T` `getByName`(`String` name, `Closure` configureClosure)

Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.

#### `T` `maybeCreate`(`String` name)

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

#### `U` `maybeCreate`(`String` name, ``Class`<`U`>` type)

Note: This method is incubating and may change in a future version of Gradle.

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