# NamedDomainObjectContainer

API Documentation: | `NamedDomainObjectContainer`

Known Subtypes: |
`DistributionContainer`
`ConfigurationContainer`
`PolymorphicDomainObjectContainer`

A named domain object container is a specialisation of `NamedDomainObjectSet` that adds the ability to create instances of the element type.

Implementations may use different strategies for creating new object instances.

Note that a container is an implementation of `SortedSet`, which means that the container is guaranteed to only contain elements with unique names within this container. Furthermore, items are ordered by their name.

### Properties

No properties

### Methods

Method | Description
`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, 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.
`getByName(name, configureAction)` | Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.
`maybeCreate(name)` | Looks for an item with the given name, creating and adding it to this container if it does not exist.

### Script blocks

No script blocks

### Method details

#### `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.

#### `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` `getByName`(`String` name, ``Action`<? super `T`>` configureAction)

Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.

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

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