Package: org.gradle.api

## [Java] Interface ExtensiblePolymorphicDomainObjectContainer<T>

- org.gradle.api.NamedDomainObjectCollection

- All Superinterfaces:
    NamedDomainObjectSet, PolymorphicDomainObjectContainer, Iterable, Configurable, DomainObjectCollection, NamedDomainObjectContainer, Collection, NamedDomainObjectCollection

  A PolymorphicDomainObjectContainer that can be extended at runtime to create elements of new types.

  Parameters:
    `` - the (base) container element type

- - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `registerBinding(Class<U> type, Class<? extends U> implementationType)` Registers a binding from the specified "public" domain object type to the specified implementation type.
    `void` | `registerFactory(Class<U> type, NamedDomainObjectFactory<? extends U> factory)` Registers a factory for creating elements of the specified type.
    `void` | `registerFactory(Class<U> type, Closure<? extends U> factory)` Registers a factory for creating elements of the specified type.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `interface PolymorphicDomainObjectContainer` | `containerWithType, create, create, maybeCreate`
    `interface NamedDomainObjectContainer` | `configure, create, create, create, maybeCreate`
    `interface NamedDomainObjectSet` | `findAll, matching, matching, withType`
    `interface NamedDomainObjectCollection` | `add, addAll, addRule, addRule, findByName, getAsMap, getAt, getByName, getByName, getNamer, getNames, getRules, matching, matching, withType`
    `interface Set` | `add, equals, hashCode, clear, contains, isEmpty, size, toArray, toArray, addAll, iterator, remove, containsAll, removeAll, retainAll`

- - ### Method Detail

    - #### public void registerBinding(Class<U> type, Class<? extends U> implementationType)

      Registers a binding from the specified "public" domain object type to the specified implementation type. Whenever the container is asked to create an element with the binding's public type, it will instantiate the binding's implementation type. If the implementation type has a constructor annotated with javax.inject.Inject, its arguments will be injected.

      In general, registering a binding is preferable over implementing and registering a factory.

      Parameters:
        `type` - a public domain object type
        `implementationType` - the corresponding implementation type
        `` - a public domain object type

    - #### public void registerFactory(Class<U> type, NamedDomainObjectFactory<? extends U> factory)

      Registers a factory for creating elements of the specified type. Typically, the specified type is an interface type.

      throws:
        IllegalArgumentException if the specified type is not a subtype of the container element type
      Parameters:
        `type` - the type of objects created by the factory
        `factory` - the factory to register
        `` - the type of objects created by the factory

    - #### public void registerFactory(Class<U> type, Closure<? extends U> factory)

      Registers a factory for creating elements of the specified type. Typically, the specified type is an interface type.

      throws:
        IllegalArgumentException if the specified type is not a subtype of the container element type
      Parameters:
        `type` - the type of objects created by the factory
        `factory` - the factory to register
        `` - the type of objects created by the factory