Groovy Documentation

org.gradle.api
[Java] Interface NamedDomainObjectContainer

org.gradle.api.NamedDomainObjectSet
  org.gradle.api.DomainObjectCollection
      org.gradle.util.Configurable
          java.util.Collection
              org.gradle.api.NamedDomainObjectCollection
                  org.gradle.api.NamedDomainObjectContainer
                      java.lang.Iterable
All Superinterfaces:
NamedDomainObjectSet, DomainObjectCollection, Configurable, Collection, NamedDomainObjectCollection, Iterable

public interface NamedDomainObjectContainer
extends Configurable, NamedDomainObjectSet

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


Method Summary
NamedDomainObjectContainer configure(Closure configureClosure)

Object create(String name)

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

Object 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.

Object maybeCreate(String name)

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

 
Methods inherited from interface NamedDomainObjectSet
findAll, matching, matching, withType
 

Method Detail

configure

public NamedDomainObjectContainer configure(Closure configureClosure)

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

TODO: example usage

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


create

public Object 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.
Returns:
The created object. Never null.
Parameters:
name - The name to assign to the created object


create

public Object 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.
throws:
InvalidUserDataException if an object with the given name already exists in this container.
Returns:
The created object. Never null.
Parameters:
name - The name to assign to the created object
configureClosure - The closure to configure the created object with


maybeCreate

@Incubating
public Object maybeCreate(String name)
Looks for an item with the given name, creating and adding it to this container if it does not exist.
Returns:
The found or created object. Never null.
Parameters:
name - The name to find or assign to the created object


 

Gradle API 1.5