-
- All Known Subinterfaces:
- Convention
public interface ExtensionContainerAllows adding 'namespaced' DSL extensions to a target object.
-
-
Method Summary
Methods Modifier and Type Method and Description voidadd(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
<T> voidconfigure(Class<T> type, Action<? super T> action)Looks for the extension of the specified type and configures it with the supplied action.
<T> Tcreate(String name, Class<T> type, Object... constructionArguments)Adds a new extension to this container, that itself is dynamically made
ExtensionAware.ObjectfindByName(String name)Looks for the extension of a given name.
<T> TfindByType(Class<T> type)Looks for the extension of a given type (useful to avoid casting).
ObjectgetByName(String name)Looks for the extension of a given name.
<T> TgetByType(Class<T> type)Looks for the extension of a given type (useful to avoid casting).
ExtraPropertiesExtensiongetExtraProperties()The extra properties extension in this extension container.
-
-
-
Method Detail
-
add
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
- 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
-
create
<T> 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 giventypewill be created using the givenconstructionArguments. The new instance will have been dynamically which means that you can cast the object toExtensionAware.- Parameters:
name- The name for the extensiontype- The type of the extensionconstructionArguments- The arguments to be used to construct the extension instance- Returns:
- The created instance
- See Also:
add(String, Object)
-
getByType
<T> T getByType(Class<T> type) throws UnknownDomainObjectException
Looks for the extension of a given type (useful to avoid casting). If none found it will throw an exception.
- Parameters:
type- extension type- Returns:
- extension, never null
- Throws:
UnknownDomainObjectException- When the given extension is not found.
-
findByType
<T> 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
-
getByName
Object getByName(String name) throws UnknownDomainObjectException
Looks for the extension of a given name. If none found it will throw an exception.
- Parameters:
name- extension name- Returns:
- extension, never null
- Throws:
UnknownDomainObjectException- When the given extension is not found.
-
findByName
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
-
configure
@Incubating <T> void configure(Class<T> type, Action<? super T> action)
Looks for the extension of the specified type and configures it with the supplied action.
- Parameters:
type- extension typeaction- the configure action- Throws:
UnknownDomainObjectException- if no exception is found.
-
getExtraProperties
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.
-
-