Groovy Documentation

org.gradle.api.plugins
[Java] Interface ExtensionContainer


public interface ExtensionContainer

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


Method Summary
void add(java.lang.String name, java.lang.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

  • java.lang.Object findByName(java.lang.String name)

    Looks for the extension of a given name.

    java.lang.Object findByType(java.lang.Class type)

    Looks for the extension of a given type (useful to avoid casting).

    java.lang.Object getByName(java.lang.String name)

    Looks for the extension of a given name.

    java.lang.Object getByType(java.lang.Class type)

    Looks for the extension of a given type (useful to avoid casting).

     

    Method Detail

    add

    public void add(java.lang.String name, java.lang.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
    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

  • findByName

    public java.lang.Object findByName(java.lang.String name)
    Looks for the extension of a given name. If none found null is returned.
    Parameters:
    name - extension name
    Returns:
    extension or null


    findByType

    public java.lang.Object findByType(java.lang.Class 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


    getByName

    public java.lang.Object getByName(java.lang.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


    getByType

    public java.lang.Object getByType(java.lang.Class 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


     

    Groovy Documentation