Class InlinedASTCustomizerFactory
java.lang.Object
groovy.util.AbstractFactory
org.codehaus.groovy.control.customizers.builder.InlinedASTCustomizerFactory
- All Implemented Interfaces:
Factory,PostCompletionFactory
This factory lets a user define a compilation customizer without having to define
an anonymous inner class.
Here is an example, which only logs the class name during compilation:
inline(phase:'CONVERSION') { source, context, classNode ->
println "visiting $classNode"
}
- Since:
- 2.1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates that inline customizer nodes accept nested closure content.newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) Creates the backing map used to build a proxy customizer.booleanonNodeChildren(FactoryBuilderSupport builder, Object node, Closure childContent) Stores the inline customization closure on the backing node.postCompleteNode(FactoryBuilderSupport factory, Object parent, Object node) Builds the proxy-backed compilation customizer once the node is complete.Methods inherited from class groovy.util.AbstractFactory
isLeaf, onFactoryRegistration, onHandleNodeAttributes, onNodeCompleted, setChild, setParent
-
Constructor Details
-
InlinedASTCustomizerFactory
public InlinedASTCustomizerFactory()
-
-
Method Details
-
isHandlesNodeChildren
public boolean isHandlesNodeChildren()Indicates that inline customizer nodes accept nested closure content.- Specified by:
isHandlesNodeChildrenin interfaceFactory- Overrides:
isHandlesNodeChildrenin classAbstractFactory- Returns:
true
-
newInstance
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException Creates the backing map used to build a proxy customizer.- Specified by:
newInstancein interfaceFactory- Parameters:
builder- the active buildername- the node namevalue- the supplied node valueattributes- the node attributes- Returns:
- the backing attribute map
- Throws:
InstantiationException- if instantiation failsIllegalAccessException- if access fails
-
onNodeChildren
Stores the inline customization closure on the backing node.- Specified by:
onNodeChildrenin interfaceFactory- Overrides:
onNodeChildrenin classAbstractFactory- Parameters:
builder- the active buildernode- the current nodechildContent- the nested closure content- Returns:
falseto continue normal processing
-
postCompleteNode
Builds the proxy-backed compilation customizer once the node is complete.- Specified by:
postCompleteNodein interfacePostCompletionFactory- Parameters:
factory- the active builderparent- the parent nodenode- the completed node- Returns:
- the generated customizer or the original node
-