NamedDomainObjectContainer (Gradle API 2.14.1)

Package: org.gradle.api

## [Java] Interface NamedDomainObjectContainer<T>

- java.util.Collection

- All Superinterfaces:
    NamedDomainObjectSet, Iterable, DomainObjectCollection, NamedDomainObjectCollection, Collection

  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.

  Parameters:
    `` - The type of domain objects in this container.
  See Also:
    NamedDomainObjectSet

- - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `NamedDomainObjectContainer<T>` | `configure(groovy.lang.Closure configureClosure)`
    `T` | `create(String name)` Creates a new item with the given name, adding it to this container.
    `T` | `create(String name, groovy.lang.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` | `maybeCreate(String name)` Looks for an item with the given name, creating and adding it to this container if it does not exist.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `interface NamedDomainObjectSet` | `findAll, matching, matching, withType`
    `interface org.gradle.util.Configurable` | `org.gradle.util.Configurable#configure(groovy.lang.Closure)`

- - ### Method Detail

    - #### public NamedDomainObjectContainer<T> configure(groovy.lang.Closure configureClosure)

      Allows the container to be configured, creating missing objects as they are referenced.

      TODO: example usage

      Parameters:
        `configureClosure` - The closure to configure this container with
      Returns:
        This.

    - #### public T create(String name)

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

      throws:
        InvalidUserDataException if an object with the given name already exists in this container.
      Parameters:
        `name` - The name to assign to the created object
      Returns:
        The created object. Never null.

    - #### public T create(String name, groovy.lang.Closure configureClosure)

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

      throws:
        InvalidUserDataException if an object with the given name already exists in this container.
      Parameters:
        `name` - The name to assign to the created object
        `configureClosure` - The closure to configure the created object with
      Returns:
        The created object. Never null.

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

      throws:
        InvalidUserDataException if an object with the given name already exists in this container.
      Parameters:
        `name` - The name to assign to the created object
        `configureAction` - The action to configure the created object with
      Returns:
        The created object. Never null.

    - #### public T maybeCreate(String name)

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

      Parameters:
        `name` - The name to find or assign to the created object
      Returns:
        The found or created object. Never null.