ExtensiblePolymorphicDomainObjectContainer (Gradle API 2.11)
Date: 2016-02-08

Package: org.gradle.api

## [Java] Interface ExtensiblePolymorphicDomainObjectContainer<T>

- org.gradle.api.PolymorphicDomainObjectContainer

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

  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, groovy.lang.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 org.gradle.api.internal.rules.NamedDomainObjectFactoryRegistry` | `org.gradle.api.internal.rules.NamedDomainObjectFactoryRegistry#registerFactory(java.lang.Class, org.gradle.api.NamedDomainObjectFactory)`
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### 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, groovy.lang.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