ExtensiblePolymorphicDomainObjectContainer (Gradle API 4.9)
Date: 2018-07-16

org.gradle.api

## Interface ExtensiblePolymorphicDomainObjectContainer<T>

- Type Parameters:
    `T` - the (base) container element type
  All Superinterfaces:
    Collection<T>, org.gradle.util.Configurable<NamedDomainObjectContainer<T>>, DomainObjectCollection<T>, Iterable<T>, NamedDomainObjectCollection<T>, NamedDomainObjectContainer<T>, org.gradle.api.internal.rules.NamedDomainObjectFactoryRegistry<T>, NamedDomainObjectSet<T>, PolymorphicDomainObjectContainer<T>, Set<T>
  All Known Subinterfaces:
    NativeToolChainRegistry, PlatformContainer, PublicationContainer

      @Incubating
      public interface ExtensiblePolymorphicDomainObjectContainer<T>
      extends PolymorphicDomainObjectContainer<T>, org.gradle.api.internal.rules.NamedDomainObjectFactoryRegistry<T>

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

- - ### Method Summary

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

    - ### Methods inherited from interface org.gradle.api.PolymorphicDomainObjectContainer

      `containerWithType, create, create, maybeCreate`

    - ### Methods inherited from interface org.gradle.api.NamedDomainObjectContainer

      `configure, create, create, create, maybeCreate`

    - ### Methods inherited from interface org.gradle.api.NamedDomainObjectSet

      `findAll, matching, matching, 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.DomainObjectCollection

      `addLater, all, all, configureEach, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType`

    - ### Methods inherited from interface java.util.Collection

      `clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

    - ### Methods inherited from interface java.util.Set

      `add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray`

- - ### Method Detail

    - #### registerFactory

          <U extends T> 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.
      Specified by:
        `registerFactory` in interface `org.gradle.api.internal.rules.NamedDomainObjectFactoryRegistry<T>`
      Type Parameters:
        `U` - the type of objects created by the factory
      Parameters:
        `type` - the type of objects created by the factory
        `factory` - the factory to register
      Throws:
        `IllegalArgumentException` - if the specified type is not a subtype of the container element type

    - #### registerFactory

          <U extends T> 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.
      Type Parameters:
        `U` - the type of objects created by the factory
      Parameters:
        `type` - the type of objects created by the factory
        `factory` - the factory to register
      Throws:
        `IllegalArgumentException` - if the specified type is not a subtype of the container element type

    - #### registerBinding

          <U extends T> 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 `Inject`, its arguments will be injected.

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

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