Package groovy.util
Class ObjectGraphBuilder
java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Binding
groovy.util.FactoryBuilderSupport
groovy.util.ObjectGraphBuilder
- All Implemented Interfaces:
GroovyObject
A builder for creating object graphs.
Each node defines the class to be created and the property on its parent (if any) at the same time.
Each node defines the class to be created and the property on its parent (if any) at the same time.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceStrategy for setting a child node on its parent.
Useful for handling Lists/Arrays vs normal properties.static interfaceStrategy for resolving a classname.static classDefault impl that calls parent.propertyName = child
If parent.propertyName is a Collection it will try to add child to the collection.static classDefault impl that capitalizes the classname.static classDefault impl, always returns 'id'static classDefault impl that calls Class.newInstance()static classDefault impl, always returns 'refId'static classDefault impl that returns parentName and childName accordingly.static interfaceStrategy for picking the correct synthetic identifier.static interfaceStrategy for creating new instances of a class.
Useful for plug-in calls to non-default constructors.static interfaceStrategy for picking the correct synthetic reference identifier.classBuild objects using reflection to resolve class names.static interfaceStrategy for resolving a relationship property name. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class groovy.util.FactoryBuilderSupport
attributeDelegates, autoRegistrationComplete, autoRegistrationRunning, CHILD_BUILDER, CURRENT_BUILDER, CURRENT_FACTORY, CURRENT_NAME, CURRENT_NODE, explicitMethods, explicitProperties, methodMissingDelegate, OWNER, PARENT_BUILDER, PARENT_CONTEXT, PARENT_FACTORY, PARENT_NAME, PARENT_NODE, postInstantiateDelegates, postNodeCompletionDelegates, preInstantiateDelegates, propertyMissingDelegate, registrationGroup, registrationGroupName, SCRIPT_CLASS_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the current name of the 'bean' node.Returns the current ChildPropertySetter.Returns the classLoader used to load a node's class.Returns the current ClassNameResolver.Returns the current NewInstanceResolver.Returns the current RelationNameResolver.booleanReturns true if references can be resolved lazilyprotected voidpostInstantiate(Object name, Map attributes, Object node) A hook after the factory creates the node and before attributes are set.
It will call any registered postInstantiateDelegates, if you override this method be sure to call this impl somewhere in your code.protected voidpreInstantiate(Object name, Map attributes, Object value) A hook before the factory creates the node.
It will call any registered preInstantiateDelegates, if you override this method be sure to call this impl somewhere in your code.protected FactoryresolveFactory(Object name, Map attributes, Object value) This is a hook for subclasses to plug in a custom strategy for mapping names to factories.voidsetBeanFactoryName(String beanFactoryName) Sets the name for the 'bean' node.voidsetChildPropertySetter(Object childPropertySetter) Sets the current ChildPropertySetter.
It will assign DefaultChildPropertySetter if null.
It accepts a ChildPropertySetter instance or a Closure.voidsetClassLoader(ClassLoader classLoader) Sets the classLoader used to load a node's class.voidsetClassNameResolver(Object classNameResolver) Sets the current ClassNameResolver.
It will assign DefaultClassNameResolver if null.
It accepts a ClassNameResolver instance, a String, a Closure or a Map.voidsetIdentifierResolver(Object identifierResolver) Sets the current IdentifierResolver.
It will assign DefaultIdentifierResolver if null.
It accepts a IdentifierResolver instance, a String or a Closure.voidsetLazyReferencesAllowed(boolean lazyReferencesAllowed) Sets whether references can be resolved lazily or not.voidsetNewInstanceResolver(Object newInstanceResolver) Sets the current NewInstanceResolver.
It will assign DefaultNewInstanceResolver if null.
It accepts a NewInstanceResolver instance or a Closure.voidsetReferenceResolver(Object referenceResolver) Sets the current ReferenceResolver.
It will assign DefaultReferenceResolver if null.
It accepts a ReferenceResolver instance, a String or a Closure.voidsetRelationNameResolver(ObjectGraphBuilder.RelationNameResolver relationNameResolver) Sets the current RelationNameResolver.
It will assign DefaultRelationNameResolver if null.Methods inherited from class groovy.util.FactoryBuilderSupport
addAttributeDelegate, addDisposalClosure, addPostInstantiateDelegate, addPostNodeCompletionDelegate, addPreInstantiateDelegate, autoRegisterNodes, build, build, build, checkExplicitMethod, checkValueIsNull, checkValueIsType, checkValueIsTypeNotString, createNode, dispatchNodeCall, dispathNodeCall, dispose, getAttributeDelegates, getChildBuilder, getContext, getContextAttribute, getContexts, getContinuationData, getCurrent, getCurrentBuilder, getCurrentFactory, getCurrentName, getDisposalClosures, getExplicitMethods, getExplicitProperties, getFactories, getLocalExplicitMethods, getLocalExplicitProperties, getLocalFactories, getMethodMissingDelegate, getName, getNameMappingClosure, getParentContext, getParentFactory, getParentName, getParentNode, getPostInstantiateDelegates, getPostNodeCompletionDelegates, getPreInstantiateDelegates, getProperty, getPropertyMissingDelegate, getProxyBuilder, getRegistrationGroupItems, getRegistrationGroups, getVariable, getVariables, handleNodeAttributes, invokeMethod, invokeMethod, newContext, nodeCompleted, popContext, postNodeCompletion, registerBeanFactory, registerBeanFactory, registerExplicitMethod, registerExplicitMethod, registerExplicitProperty, registerExplicitProperty, registerFactory, registerFactory, removeAttributeDelegate, removePostInstantiateDelegate, removePostNodeCompletionDelegate, removePreInstantiateDelegate, reset, resolveExplicitMethod, resolveExplicitProperty, restoreFromContinuationData, setClosureDelegate, setMethodMissingDelegate, setNameMappingClosure, setNodeAttributes, setParent, setProperty, setPropertyMissingDelegate, setProxyBuilder, setVariable, withBuilder, withBuilder, withBuilderMethods inherited from class groovy.lang.Binding
hasVariable, removeVariableMethods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
-
Field Details
-
NODE_CLASS
- See Also:
-
NODE_NAME
- See Also:
-
OBJECT_ID
- See Also:
-
LAZY_REF
- See Also:
-
CLASSNAME_RESOLVER_KEY
- See Also:
-
CLASSNAME_RESOLVER_REFLECTION
- See Also:
-
CLASSNAME_RESOLVER_REFLECTION_ROOT
- See Also:
-
-
Constructor Details
-
ObjectGraphBuilder
public ObjectGraphBuilder()
-
-
Method Details
-
getBeanFactoryName
Returns the current name of the 'bean' node. -
getChildPropertySetter
Returns the current ChildPropertySetter. -
getClassLoader
Returns the classLoader used to load a node's class. -
getClassNameResolver
Returns the current ClassNameResolver. -
getNewInstanceResolver
Returns the current NewInstanceResolver. -
getRelationNameResolver
Returns the current RelationNameResolver. -
isLazyReferencesAllowed
public boolean isLazyReferencesAllowed()Returns true if references can be resolved lazily -
setBeanFactoryName
Sets the name for the 'bean' node. -
setChildPropertySetter
Sets the current ChildPropertySetter.
It will assign DefaultChildPropertySetter if null.
It accepts a ChildPropertySetter instance or a Closure. -
setClassLoader
Sets the classLoader used to load a node's class. -
setClassNameResolver
Sets the current ClassNameResolver.
It will assign DefaultClassNameResolver if null.
It accepts a ClassNameResolver instance, a String, a Closure or a Map. -
setIdentifierResolver
Sets the current IdentifierResolver.
It will assign DefaultIdentifierResolver if null.
It accepts a IdentifierResolver instance, a String or a Closure. -
setLazyReferencesAllowed
public void setLazyReferencesAllowed(boolean lazyReferencesAllowed) Sets whether references can be resolved lazily or not. -
setNewInstanceResolver
Sets the current NewInstanceResolver.
It will assign DefaultNewInstanceResolver if null.
It accepts a NewInstanceResolver instance or a Closure. -
setReferenceResolver
Sets the current ReferenceResolver.
It will assign DefaultReferenceResolver if null.
It accepts a ReferenceResolver instance, a String or a Closure. -
setRelationNameResolver
Sets the current RelationNameResolver.
It will assign DefaultRelationNameResolver if null. -
postInstantiate
Description copied from class:FactoryBuilderSupportA hook after the factory creates the node and before attributes are set.
It will call any registered postInstantiateDelegates, if you override this method be sure to call this impl somewhere in your code.- Overrides:
postInstantiatein classFactoryBuilderSupport- Parameters:
name- the name of the nodeattributes- the attributes for the nodenode- the object created by the node factory
-
preInstantiate
Description copied from class:FactoryBuilderSupportA hook before the factory creates the node.
It will call any registered preInstantiateDelegates, if you override this method be sure to call this impl somewhere in your code.- Overrides:
preInstantiatein classFactoryBuilderSupport- Parameters:
name- the name of the nodeattributes- the attributes of the nodevalue- the value argument(s) of the node
-
resolveFactory
Description copied from class:FactoryBuilderSupportThis is a hook for subclasses to plug in a custom strategy for mapping names to factories.- Overrides:
resolveFactoryin classFactoryBuilderSupport- Parameters:
name- the name of the factoryattributes- the attributes from the nodevalue- value arguments from te node- Returns:
- the Factory associated with name.
-