T
- the (base) type of domain objects in the containerCollection<T>
, org.gradle.util.Configurable<NamedDomainObjectContainer<T>>
, DomainObjectCollection<T>
, Iterable<T>
, NamedDomainObjectCollection<T>
, NamedDomainObjectContainer<T>
, NamedDomainObjectSet<T>
, Set<T>
AuthenticationContainer
, ExtensiblePolymorphicDomainObjectContainer<T>
, NativeToolChainRegistry
, PlatformContainer
, PlayDistributionContainer
, PublicationContainer
, Repositories
, TaskContainer
public interface PolymorphicDomainObjectContainer<T> extends NamedDomainObjectContainer<T>
NamedDomainObjectContainer
that allows to create domain objects with different types.Modifier and Type | Method | Description |
---|---|---|
<U extends T> |
containerWithType(Class<U> type) |
Creates a regular container that wraps the polymorphic container presenting all elements of a specified type.
|
<U extends T> |
create(String name,
Class<U> type) |
Creates a domain object with the specified name and type, and adds it to the container.
|
<U extends T> |
create(String name,
Class<U> type,
Action<? super U> configuration) |
Creates a domain object with the specified name and type, adds it to the container, and configures
it with the specified action.
|
<U extends T> |
maybeCreate(String name,
Class<U> type) |
Looks for an item with the given name and type, creating and adding it to this container if it does not exist.
|
<U extends T> |
register(String name,
Class<U> type) |
Defines a new object, which will be created when it is required.
|
<U extends T> |
register(String name,
Class<U> type,
Action<? super U> configurationAction) |
Defines a new object, which will be created and configured when it is required.
|
parallelStream, removeIf, stream, toArray
addAllLater, addLater, all, all, configureEach, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType
add, addAll, addRule, addRule, addRule, findByName, getAsMap, getAt, getByName, getByName, getByName, getCollectionSchema, getNamer, getNames, getRules, named, named, named, named
configure, create, create, create, maybeCreate, register, register
findAll, matching, matching, withType
<U extends T> U create(String name, Class<U> type) throws InvalidUserDataException
U
- the type of the domain object to be createdname
- the name of the domain object to be createdtype
- the type of the domain object to be createdInvalidUserDataException
- if a domain object with the specified name already exists
or the container does not support creating a domain object with the specified type<U extends T> U maybeCreate(String name, Class<U> type) throws InvalidUserDataException
U
- the type of the domain object to be createdname
- the name of the domain object to be createdtype
- the type of the domain object to be creatednull
.InvalidUserDataException
- if the container does not support creating a domain object with the specified typeClassCastException
- if a domain object with the specified name exists with a different type<U extends T> U create(String name, Class<U> type, Action<? super U> configuration) throws InvalidUserDataException
U
- the type of the domain object to be createdname
- the name of the domain object to be createdtype
- the type of the domain object to be createdconfiguration
- an action for configuring the domain objectInvalidUserDataException
- if a domain object with the specified name already exists
or the container does not support creating a domain object with the specified type<U extends T> NamedDomainObjectContainer<U> containerWithType(Class<U> type)
U
- the type of the container elementstype
- the type of the container elementsNamedDomainObjectContainer
providing access to elements of type U.<U extends T> NamedDomainObjectProvider<U> register(String name, Class<U> type, Action<? super U> configurationAction) throws InvalidUserDataException
NamedDomainObjectCollection.getByName(String)
or when Provider.get()
is called on the return value of this method.
It is generally more efficient to use this method instead of create(String, Class, Action)
or create(String, Class)
, as those methods will eagerly create and configure the object, regardless of whether that object is required for the current build or not. This method, on the other hand, will defer creation and configuration until required.
U
- The object typename
- The name of the object.type
- The object type.configurationAction
- The action to run to configure the object. This action runs when the object is required.Provider
that whose value will be the object, when queried.InvalidUserDataException
- If a object with the given name already exists in this project.<U extends T> NamedDomainObjectProvider<U> register(String name, Class<U> type) throws InvalidUserDataException
NamedDomainObjectCollection.getByName(String)
or when Provider.get()
is called on the return value of this method.
It is generally more efficient to use this method instead of create(String, Class, Action)
or create(String, Class)
, as those methods will eagerly create and configure the object, regardless of whether that object is required for the current build or not. This method, on the other hand, will defer creation until required.
U
- The object typename
- The name of the object.type
- The object type.Provider
that whose value will be the object, when queried.InvalidUserDataException
- If a object with the given name already exists in this project.