Interface ExtensiblePolymorphicDomainObjectContainer<T>

    • Method Detail

      • registerFactory

        <U extends T> void registerFactory​(java.lang.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:
        java.lang.IllegalArgumentException - if the specified type is not a subtype of the container element type
      • registerFactory

        <U extends T> void registerFactory​(java.lang.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:
        java.lang.IllegalArgumentException - if the specified type is not a subtype of the container element type
      • registerBinding

        <U extends T> void registerBinding​(java.lang.Class<U> type,
                                           java.lang.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.

        The implementation type may also be an interface that has a read-only name property of type String, and is otherwise empty or consists entirely of managed properties.

        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