ExtensionContainer (Gradle API 2.14.1)

Package: org.gradle.api.plugins

## [Java] Interface ExtensionContainer

- Allows adding 'namespaced' DSL extensions to a target object.

- - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---

    `void`

    `add(String name, Object extension)`
    Adding an extension of name 'foo' will:
    - add 'foo' dynamic property
    - add 'foo' dynamic method that accepts a closure that is a configuration script block

    `void` | `configure(Class<T> type, Action<? super T> action)` Looks for the extension of the specified type and configures it with the supplied action.
    `T` | `create(String name, Class<T> type, Object... constructionArguments)` Adds a new extension to this container, that itself is dynamically made ExtensionAware.
    `Object` | `findByName(String name)` Looks for the extension of a given name.
    `T` | `findByType(Class<T> type)` Looks for the extension of a given type (useful to avoid casting).
    `Object` | `getByName(String name)` Looks for the extension of a given name.
    `T` | `getByType(Class<T> type)` Looks for the extension of a given type (useful to avoid casting).
    `ExtraPropertiesExtension` | `getExtraProperties()` The extra properties extension in this extension container.

- - ### Method Detail

    - #### public void add(String name, Object extension)

      Adding an extension of name 'foo' will:

    - add 'foo' dynamic property
    - add 'foo' dynamic method that accepts a closure that is a configuration script block
      throws:
        IllegalArgumentException When an extension with the given name already exists.
      Parameters:
        `name` - Will be used as a sort of namespace of properties/methods.
        `extension` - Any object whose methods and properties will extend the target object

    - #### @Incubating public void configure(Class<T> type, Action<? super T> action)

      Looks for the extension of the specified type and configures it with the supplied action.

      throws:
        UnknownDomainObjectException if no extension is found.
      Parameters:
        `type` - extension type
        `action` - the configure action

    - #### public T create(String name, Class<T> type, Object... constructionArguments)

      Adds a new extension to this container, that itself is dynamically made ExtensionAware. A new instance of the given `type` will be created using the given `constructionArguments`. The new instance will have been dynamically which means that you can cast the object to ExtensionAware.

      throws:
        IllegalArgumentException When an extension with the given name already exists.
      Parameters:
        `name` - The name for the extension
        `type` - The type of the extension
        `constructionArguments` - The arguments to be used to construct the extension instance
      Returns:
        The created instance
      See Also:
        add(String, Object)

    - #### public Object findByName(String name)

      Looks for the extension of a given name. If none found null is returned.

      Parameters:
        `name` - extension name
      Returns:
        extension or null

    - #### public T findByType(Class<T> type)

      Looks for the extension of a given type (useful to avoid casting). If none found null is returned.

      Parameters:
        `type` - extension type
      Returns:
        extension or null

    - #### public Object getByName(String name)

      Looks for the extension of a given name. If none found it will throw an exception.

      throws:
        UnknownDomainObjectException When the given extension is not found.
      Parameters:
        `name` - extension name
      Returns:
        extension, never null

    - #### public T getByType(Class<T> type)

      Looks for the extension of a given type (useful to avoid casting). If none found it will throw an exception.

      throws:
        UnknownDomainObjectException When the given extension is not found.
      Parameters:
        `type` - extension type
      Returns:
        extension, never null

    - #### public ExtraPropertiesExtension getExtraProperties()

      The extra properties extension in this extension container. This extension is always present in the container, with the name “ext”.

      Returns:
        The extra properties extension in this extension container.