public class DefaultConvention extends Object implements Convention
| Constructor and Description |
|---|
DefaultConvention()
This method should be used in runtime code proper as means that the convention cannot create
dynamic extensions.
|
DefaultConvention(Instantiator instantiator) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(String name,
Class<?> type,
Object... constructionArguments)
Deprecated.
|
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
|
<T> 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> T |
findByType(Class<T> type)
Looks for the extension of a given type (useful to avoid casting).
|
<T> T |
findPlugin(Class<T> type)
Locates the plugin convention object with the given type.
|
Object |
getByName(String name)
Looks for the extension of a given name.
|
<T> T |
getByType(Class<T> type)
Looks for the extension of a given type (useful to avoid casting).
|
DynamicObject |
getExtensionsAsDynamicObject()
Returns a dynamic object which represents the properties and methods contributed by the extensions and convention objects contained in this
convention.
|
ExtraPropertiesExtension |
getExtraProperties()
The extra properties extension in this extension container.
|
<T> T |
getPlugin(Class<T> type)
Locates the plugin convention object with the given type.
|
Map<String,Object> |
getPlugins()
Returns the plugin convention objects contained in this convention.
|
Object |
propertyMissing(String name) |
void |
propertyMissing(String name,
Object value) |
public DefaultConvention()
public DefaultConvention(Instantiator instantiator)
public Map<String,Object> getPlugins()
ConventiongetPlugins in interface Conventionpublic DynamicObject getExtensionsAsDynamicObject()
ConventiongetExtensionsAsDynamicObject in interface Conventionpublic <T> T getPlugin(Class<T> type)
ConventiongetPlugin in interface Conventiontype - The convention object type.public <T> T findPlugin(Class<T> type) throws IllegalStateException
ConventionfindPlugin in interface Conventiontype - The convention object type.IllegalStateException - When there there are multiple matching objects.public void add(String name, Object extension)
ExtensionContaineradd in interface ExtensionContainername - Will be used as a sort of namespace of properties/methods.extension - Any object whose methods and properties will extend the target objectpublic void add(String name, Class<?> type, Object... constructionArguments)
ExtensionContainerExtensionContainer.create(java.lang.String, java.lang.Class<T>, java.lang.Object...)add in interface ExtensionContainername - The name for the extensiontype - The type of the extensionconstructionArguments - The arguments to be used to construct the extension instancepublic <T> T create(String name, Class<T> type, Object... constructionArguments)
ExtensionContainerExtensionAware.
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.create in interface ExtensionContainername - The name for the extensiontype - The type of the extensionconstructionArguments - The arguments to be used to construct the extension instanceExtensionContainer.add(String, Object)public ExtraPropertiesExtension getExtraProperties()
ExtensionContainergetExtraProperties in interface ExtensionContainerpublic <T> T getByType(Class<T> type)
ExtensionContainergetByType in interface ExtensionContainertype - extension typepublic <T> T findByType(Class<T> type)
ExtensionContainerfindByType in interface ExtensionContainertype - extension typepublic Object getByName(String name)
ExtensionContainergetByName in interface ExtensionContainername - extension namepublic Object findByName(String name)
ExtensionContainerfindByName in interface ExtensionContainername - extension nameCopyright © 2013. All rights reserved