Package groovy.util
Class ObjectGraphBuilder
- java.lang.Object
- 
- groovy.lang.GroovyObjectSupport
- 
- groovy.lang.Binding
- 
- groovy.util.FactoryBuilderSupport
- 
- groovy.util.ObjectGraphBuilder
 
 
 
 
- 
- All Implemented Interfaces:
- GroovyObject
 
 public class ObjectGraphBuilder extends FactoryBuilderSupport 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.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static interfaceObjectGraphBuilder.ChildPropertySetterStrategy for setting a child node on its parent.
 Useful for handling Lists/Arrays vs normal properties.static interfaceObjectGraphBuilder.ClassNameResolverStrategy for resolving a classname.static classObjectGraphBuilder.DefaultChildPropertySetterDefault impl that calls parent.propertyName = child
 If parent.propertyName is a Collection it will try to add child to the collection.static classObjectGraphBuilder.DefaultClassNameResolverDefault impl that capitalizes the classname.static classObjectGraphBuilder.DefaultIdentifierResolverDefault impl, always returns 'id'static classObjectGraphBuilder.DefaultNewInstanceResolverDefault impl that calls Class.newInstance()static classObjectGraphBuilder.DefaultReferenceResolverDefault impl, always returns 'refId'static classObjectGraphBuilder.DefaultRelationNameResolverDefault impl that returns parentName and childName accordingly.static interfaceObjectGraphBuilder.IdentifierResolverStrategy for picking the correct synthetic identifier.static interfaceObjectGraphBuilder.NewInstanceResolverStrategy for creating new instances of a class.
 Useful for plug-in calls to non-default constructors.static interfaceObjectGraphBuilder.ReferenceResolverStrategy for picking the correct synthetic reference identifier.classObjectGraphBuilder.ReflectionClassNameResolverBuild objects using reflection to resolve class names.static interfaceObjectGraphBuilder.RelationNameResolverStrategy for resolving a relationship property name.
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringCLASSNAME_RESOLVER_KEYstatic java.lang.StringCLASSNAME_RESOLVER_REFLECTIONstatic java.lang.StringCLASSNAME_RESOLVER_REFLECTION_ROOTstatic java.lang.StringLAZY_REFstatic java.lang.StringNODE_CLASSstatic java.lang.StringNODE_NAMEstatic java.lang.StringOBJECT_ID- 
Fields inherited from class groovy.util.FactoryBuilderSupportattributeDelegates, 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 SummaryConstructors Constructor Description ObjectGraphBuilder()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetBeanFactoryName()Returns the current name of the 'bean' node.ObjectGraphBuilder.ChildPropertySettergetChildPropertySetter()Returns the current ChildPropertySetter.java.lang.ClassLoadergetClassLoader()Returns the classLoader used to load a node's class.ObjectGraphBuilder.ClassNameResolvergetClassNameResolver()Returns the current ClassNameResolver.ObjectGraphBuilder.NewInstanceResolvergetNewInstanceResolver()Returns the current NewInstanceResolver.ObjectGraphBuilder.RelationNameResolvergetRelationNameResolver()Returns the current RelationNameResolver.booleanisLazyReferencesAllowed()Returns true if references can be resolved lazilyprotected voidpostInstantiate(java.lang.Object name, java.util.Map attributes, java.lang.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(java.lang.Object name, java.util.Map attributes, java.lang.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(java.lang.Object name, java.util.Map attributes, java.lang.Object value)This is a hook for subclasses to plugin a custom strategy for mapping names to factories.voidsetBeanFactoryName(java.lang.String beanFactoryName)Sets the name for the 'bean' node.voidsetChildPropertySetter(java.lang.Object childPropertySetter)Sets the current ChildPropertySetter.
 It will assign DefaultChildPropertySetter if null.
 It accepts a ChildPropertySetter instance or a Closure.voidsetClassLoader(java.lang.ClassLoader classLoader)Sets the classLoader used to load a node's class.voidsetClassNameResolver(java.lang.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(java.lang.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(java.lang.Object newInstanceResolver)Sets the current NewInstanceResolver.
 It will assign DefaultNewInstanceResolver if null.
 It accepts a NewInstanceResolver instance or a Closure.voidsetReferenceResolver(java.lang.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.FactoryBuilderSupportaddAttributeDelegate, 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, withBuilder
 - 
Methods inherited from class groovy.lang.BindinghasVariable
 - 
Methods inherited from class groovy.lang.GroovyObjectSupportgetMetaClass, setMetaClass
 
- 
 
- 
- 
- 
Field Detail- 
NODE_CLASSpublic static final java.lang.String NODE_CLASS - See Also:
- Constant Field Values
 
 - 
NODE_NAMEpublic static final java.lang.String NODE_NAME - See Also:
- Constant Field Values
 
 - 
OBJECT_IDpublic static final java.lang.String OBJECT_ID - See Also:
- Constant Field Values
 
 - 
LAZY_REFpublic static final java.lang.String LAZY_REF - See Also:
- Constant Field Values
 
 - 
CLASSNAME_RESOLVER_KEYpublic static final java.lang.String CLASSNAME_RESOLVER_KEY - See Also:
- Constant Field Values
 
 - 
CLASSNAME_RESOLVER_REFLECTIONpublic static final java.lang.String CLASSNAME_RESOLVER_REFLECTION - See Also:
- Constant Field Values
 
 - 
CLASSNAME_RESOLVER_REFLECTION_ROOTpublic static final java.lang.String CLASSNAME_RESOLVER_REFLECTION_ROOT - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getBeanFactoryNamepublic java.lang.String getBeanFactoryName() Returns the current name of the 'bean' node.
 - 
getChildPropertySetterpublic ObjectGraphBuilder.ChildPropertySetter getChildPropertySetter() Returns the current ChildPropertySetter.
 - 
getClassLoaderpublic java.lang.ClassLoader getClassLoader() Returns the classLoader used to load a node's class.
 - 
getClassNameResolverpublic ObjectGraphBuilder.ClassNameResolver getClassNameResolver() Returns the current ClassNameResolver.
 - 
getNewInstanceResolverpublic ObjectGraphBuilder.NewInstanceResolver getNewInstanceResolver() Returns the current NewInstanceResolver.
 - 
getRelationNameResolverpublic ObjectGraphBuilder.RelationNameResolver getRelationNameResolver() Returns the current RelationNameResolver.
 - 
isLazyReferencesAllowedpublic boolean isLazyReferencesAllowed() Returns true if references can be resolved lazily
 - 
setBeanFactoryNamepublic void setBeanFactoryName(java.lang.String beanFactoryName) Sets the name for the 'bean' node.
 - 
setChildPropertySetterpublic void setChildPropertySetter(java.lang.Object childPropertySetter) Sets the current ChildPropertySetter.
 It will assign DefaultChildPropertySetter if null.
 It accepts a ChildPropertySetter instance or a Closure.
 - 
setClassLoaderpublic void setClassLoader(java.lang.ClassLoader classLoader) Sets the classLoader used to load a node's class.
 - 
setClassNameResolverpublic void setClassNameResolver(java.lang.Object classNameResolver) Sets the current ClassNameResolver.
 It will assign DefaultClassNameResolver if null.
 It accepts a ClassNameResolver instance, a String, a Closure or a Map.
 - 
setIdentifierResolverpublic void setIdentifierResolver(java.lang.Object identifierResolver) Sets the current IdentifierResolver.
 It will assign DefaultIdentifierResolver if null.
 It accepts a IdentifierResolver instance, a String or a Closure.
 - 
setLazyReferencesAllowedpublic void setLazyReferencesAllowed(boolean lazyReferencesAllowed) Sets whether references can be resolved lazily or not.
 - 
setNewInstanceResolverpublic void setNewInstanceResolver(java.lang.Object newInstanceResolver) Sets the current NewInstanceResolver.
 It will assign DefaultNewInstanceResolver if null.
 It accepts a NewInstanceResolver instance or a Closure.
 - 
setReferenceResolverpublic void setReferenceResolver(java.lang.Object referenceResolver) Sets the current ReferenceResolver.
 It will assign DefaultReferenceResolver if null.
 It accepts a ReferenceResolver instance, a String or a Closure.
 - 
setRelationNameResolverpublic void setRelationNameResolver(ObjectGraphBuilder.RelationNameResolver relationNameResolver) Sets the current RelationNameResolver.
 It will assign DefaultRelationNameResolver if null.
 - 
postInstantiateprotected void postInstantiate(java.lang.Object name, java.util.Map attributes, java.lang.Object node)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 class- FactoryBuilderSupport
- Parameters:
- name- the name of the node
- attributes- the attributes for the node
- node- the object created by the node factory
 
 - 
preInstantiateprotected void preInstantiate(java.lang.Object name, java.util.Map attributes, java.lang.Object value)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 class- FactoryBuilderSupport
- Parameters:
- name- the name of the node
- attributes- the attributes of the node
- value- the value argument(s) of the node
 
 - 
resolveFactoryprotected Factory resolveFactory(java.lang.Object name, java.util.Map attributes, java.lang.Object value) Description copied from class:FactoryBuilderSupportThis is a hook for subclasses to plugin a custom strategy for mapping names to factories.- Overrides:
- resolveFactoryin class- FactoryBuilderSupport
- Parameters:
- name- the name of the factory
- attributes- the attributes from the node
- value- value arguments from te node
- Returns:
- the Factory associated with name.
 
 
- 
 
-