Top Description Inners Fields Constructors Methods
groovy.util

public Class ObjectGraphBuilder

extends FactoryBuilderSupport
Class Inheritance
Imports
groovy.lang.Closure, .GString, .MetaProperty, .MissingPropertyException, org.codehaus.groovy.runtime.InvokerHelper, java.lang.reflect.ParameterizedType, .Type, java.util.ArrayList, .Collection, .HashMap, .List, .Map, java.util.regex.Pattern

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 and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ObjectGraphBuilder.ChildPropertySetter

Strategy for setting a child node on its parent.

public static interface
ObjectGraphBuilder.ClassNameResolver

Strategy for resolving a classname.

public static class
ObjectGraphBuilder.DefaultChildPropertySetter

Default impl that calls parent.propertyName = child If parent.propertyName is a Collection it will try to add child to the collection.

public static class
ObjectGraphBuilder.DefaultClassNameResolver

Default impl that capitalizes the classname.

public static class
ObjectGraphBuilder.DefaultIdentifierResolver

Default impl, always returns 'id'

public static class
ObjectGraphBuilder.DefaultNewInstanceResolver

Default impl that calls Class.newInstance()

public static class
ObjectGraphBuilder.DefaultReferenceResolver

Default impl, always returns 'refId'

public static class
ObjectGraphBuilder.DefaultRelationNameResolver

Default impl that returns parentName and childName accordingly.

public static interface
ObjectGraphBuilder.IdentifierResolver

Strategy for picking the correct synthetic identifier.

public static interface
ObjectGraphBuilder.NewInstanceResolver

Strategy for creating new instances of a class.

private static class
private static class
private static class
private static class
public static interface
ObjectGraphBuilder.ReferenceResolver

Strategy for picking the correct synthetic reference identifier.

public class
ObjectGraphBuilder.ReflectionClassNameResolver

Build objects using reflection to resolve class names.

public static interface
ObjectGraphBuilder.RelationNameResolver

Strategy for resolving a relationship property name.

Field Summary

Modifier and TypeField and Description
private String
private ObjectGraphBuilder.ChildPropertySetter
private ClassLoader
public static final String
public static final String
public static final String
private ObjectGraphBuilder.ClassNameResolver
private ObjectGraphBuilder.IdentifierResolver
public static final String
private final List<ObjectGraphBuilder.NodeReference>
private boolean
private ObjectGraphBuilder.NewInstanceResolver
public static final String
public static final String
public static final String
private final ObjectGraphBuilder.ObjectBeanFactory
private final ObjectGraphBuilder.ObjectFactory
private final ObjectGraphBuilder.ObjectRefFactory
private static final Pattern
private ObjectGraphBuilder.ReferenceResolver
private ObjectGraphBuilder.RelationNameResolver
private final Map<String, Class<T>>
Inherited from groovy.util.FactoryBuilderSupport:
attributeDelegatesautoRegistrationCompleteautoRegistrationRunningCHILD_BUILDERCURRENT_BUILDERCURRENT_FACTORYCURRENT_NAMECURRENT_NODEexplicitMethodsexplicitPropertiesmethodMissingDelegateOWNERPARENT_BUILDERPARENT_CONTEXTPARENT_FACTORYPARENT_NAMEPARENT_NODEpostInstantiateDelegatespostNodeCompletionDelegatespreInstantiateDelegatespropertyMissingDelegateregistrationGroupregistrationGroupNameSCRIPT_CLASS_NAME

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getBeanFactoryName()

Returns the current name of the 'bean' node.

public ObjectGraphBuilder.ChildPropertySetter
getChildPropertySetter()

Returns the current ChildPropertySetter.

public ClassLoader
getClassLoader()

Returns the classLoader used to load a node's class.

public ObjectGraphBuilder.ClassNameResolver
getClassNameResolver()

Returns the current ClassNameResolver.

public ObjectGraphBuilder.NewInstanceResolver
getNewInstanceResolver()

Returns the current NewInstanceResolver.

public ObjectGraphBuilder.RelationNameResolver
getRelationNameResolver()

Returns the current RelationNameResolver.

public boolean
isLazyReferencesAllowed()

Returns true if references can be resolved lazily

private static String
protected void
postInstantiate(Object
the name of the node
name
,
Map<K, V>
the attributes for the node
attributes
,
Object
the object created by the node factory
node
)

Overrides groovy.util.FactoryBuilderSupport.postInstantiate.

A hook after the factory creates the node and before attributes are set.
protected void
preInstantiate(Object
the name of the node
name
,
Map<K, V>
the attributes of the node
attributes
,
Object
the value argument(s) of the node
value
)

Overrides groovy.util.FactoryBuilderSupport.preInstantiate.

A hook before the factory creates the node.
protected Factory
resolveFactory(Object
the name of the factory
name
,
Map<K, V>
the attributes from the node
attributes
,
Object
value arguments from te node
value
)

Overrides groovy.util.FactoryBuilderSupport.resolveFactory.

This is a hook for subclasses to plugin a custom strategy for mapping names to factories.
private void
public void
setBeanFactoryName(String beanFactoryName)

Sets the name for the 'bean' node.

public void
setChildPropertySetter(final Object childPropertySetter)

Sets the current ChildPropertySetter.

public void
setClassLoader(ClassLoader classLoader)

Sets the classLoader used to load a node's class.

public void
setClassNameResolver(final Object classNameResolver)

Sets the current ClassNameResolver.

public void
setIdentifierResolver(final Object identifierResolver)

Sets the current IdentifierResolver.

public void
setLazyReferencesAllowed(boolean lazyReferencesAllowed)

Sets whether references can be resolved lazily or not.

public void
setNewInstanceResolver(final Object newInstanceResolver)

Sets the current NewInstanceResolver.

public void
setReferenceResolver(final Object referenceResolver)

Sets the current ReferenceResolver.

public void
setRelationNameResolver(ObjectGraphBuilder.RelationNameResolver relationNameResolver)

Sets the current RelationNameResolver.

Inherited from groovy.util.FactoryBuilderSupport:
addAttributeDelegateaddDisposalClosureaddPostInstantiateDelegateaddPostNodeCompletionDelegateaddPreInstantiateDelegateautoRegisterNodesbuildbuildbuildcheckExplicitMethodcheckValueIsNullcheckValueIsTypecheckValueIsTypeNotStringcreateNodedispatchNodeCalldispathNodeCalldisposegetAttributeDelegatesgetChildBuildergetContextgetContextAttributegetContextsgetContinuationDatagetCurrentgetCurrentBuildergetCurrentFactorygetCurrentNamegetDisposalClosuresgetExplicitMethodsgetExplicitPropertiesgetFactoriesgetLocalExplicitMethodsgetLocalExplicitPropertiesgetLocalFactoriesgetMethodMissingDelegategetNamegetNameMappingClosuregetParentContextgetParentFactorygetParentNamegetParentNodegetPostInstantiateDelegatesgetPostNodeCompletionDelegatesgetPreInstantiateDelegatesgetPropertygetPropertyMissingDelegategetProxyBuildergetRegistrationGroupItemsgetRegistrationGroupsgetVariablegetVariableshandleNodeAttributesinvokeMethodinvokeMethodnewContextnodeCompletedpopContextpostNodeCompletionregisterBeanFactoryregisterBeanFactoryregisterExplicitMethodregisterExplicitMethodregisterExplicitPropertyregisterExplicitPropertyregisterFactoryregisterFactoryremoveAttributeDelegateremovePostInstantiateDelegateremovePostNodeCompletionDelegateremovePreInstantiateDelegateresetresolveExplicitMethodresolveExplicitPropertyrestoreFromContinuationDatasetClosureDelegatesetMethodMissingDelegatesetNameMappingClosuresetNodeAttributessetParentsetPropertysetPropertyMissingDelegatesetProxyBuildersetVariablewithBuilderwithBuilderwithBuilder