Package org.gradle.api
Interface NamedDomainObjectContainer<T>
- Type Parameters:
T
- The type of domain objects in this container.
- All Superinterfaces:
Collection<T>
,org.gradle.util.Configurable<NamedDomainObjectContainer<T>>
,DomainObjectCollection<T>
,Iterable<T>
,NamedDomainObjectCollection<T>
,NamedDomainObjectSet<T>
,Set<T>
- All Known Subinterfaces:
ArtifactTypeContainer
,AuthenticationContainer
,BuildTypeContainer
,ConfigurationContainer
,DistributionContainer
,ExtensiblePolymorphicDomainObjectContainer<T>
,FlavorContainer
,IvyConfigurationContainer
,NativeToolChainRegistry
,PlatformContainer
,PlayDistributionContainer
,PolymorphicDomainObjectContainer<T>
,PublicationContainer
,Repositories
,SourceSetContainer
,TaskContainer
public interface NamedDomainObjectContainer<T>
extends NamedDomainObjectSet<T>, org.gradle.util.Configurable<NamedDomainObjectContainer<T>>
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.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAllows the container to be configured, creating missing objects as they are referenced.Creates a new item with the given name, adding it to this container.Creates a new item with the given name, adding it to this container, then configuring it with the given closure.Creates a new item with the given name, adding it to this container, then configuring it with the given action.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 java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface org.gradle.api.DomainObjectCollection
all, all, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType
Methods inherited from interface org.gradle.api.NamedDomainObjectCollection
add, addAll, addRule, addRule, addRule, findByName, getAsMap, getAt, getByName, getByName, getByName, getNamer, getNames, getRules
Methods inherited from interface org.gradle.api.NamedDomainObjectSet
findAll, matching, matching, withType
-
Method Details
-
create
Creates a new item with the given name, adding it to this container.- Parameters:
name
- The name to assign to the created object- Returns:
- The created object. Never null.
- Throws:
InvalidUserDataException
- if an object with the given name already exists in this container.
-
maybeCreate
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.
-
create
Creates a new item with the given name, adding it to this container, then configuring it with the given closure.- Parameters:
name
- The name to assign to the created objectconfigureClosure
- The closure to configure the created object with- Returns:
- The created object. Never null.
- Throws:
InvalidUserDataException
- if an object with the given name already exists in this container.
-
create
Creates a new item with the given name, adding it to this container, then configuring it with the given action.- Parameters:
name
- The name to assign to the created objectconfigureAction
- The action to configure the created object with- Returns:
- The created object. Never null.
- Throws:
InvalidUserDataException
- if an object with the given name already exists in this container.
-
configure
Allows the container to be configured, creating missing objects as they are referenced.
TODO: example usage
- Specified by:
configure
in interfaceorg.gradle.util.Configurable<T>
- Parameters:
configureClosure
- The closure to configure this container with- Returns:
- This.
-