## 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.

Author:
  Scott Vlaminck (http://refactr.com), Andres Almiray <aalmiray@users.sourceforge.com>

Nested Class Summary
`static interface` `ObjectGraphBuilder.ChildPropertySetter` Strategy for setting a child node on its parent.
`static interface` `ObjectGraphBuilder.ClassNameResolver` Strategy for resolving a classname.
`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.
`static class` `ObjectGraphBuilder.DefaultClassNameResolver` Default impl that capitalizes the classname.
`static class` `ObjectGraphBuilder.DefaultIdentifierResolver` Default impl, always returns 'id'
`static class` `ObjectGraphBuilder.DefaultNewInstanceResolver` Default impl that calls Class.newInstance()
`static class` `ObjectGraphBuilder.DefaultReferenceResolver` Default impl, always returns 'refId'
`static class` `ObjectGraphBuilder.DefaultRelationNameResolver` Default impl that returns parentName & childName accordingly.
`static interface` `ObjectGraphBuilder.IdentifierResolver` Strategy for picking the correct synthetic identifier.
`static interface` `ObjectGraphBuilder.NewInstanceResolver` Strategy for creating new instances of a class.
`static interface` `ObjectGraphBuilder.ReferenceResolver` Strategy for picking the correct synthetic reference identifier.
`static interface` `ObjectGraphBuilder.RelationNameResolver` Strategy for resolving a relationship property name.

Field Summary
`static String` `NODE_CLASS`
`static String` `NODE_NAME`
`static String` `OBJECT_ID`

Fields inherited from class groovy.util.FactoryBuilderSupport
`CURRENT_FACTORY, CURRENT_NAME, CURRENT_NODE, OWNER, PARENT_CONTEXT, PARENT_FACTORY, PARENT_NAME, PARENT_NODE`

Constructor Summary
`ObjectGraphBuilder()`

Method Summary
`ObjectGraphBuilder.ChildPropertySetter` `getChildPropertySetter()` Returns the current ChildPropertySetter.
`ClassLoader` `getClassLoader()` Returns the classLoader used to load a node's class.
`ObjectGraphBuilder.ClassNameResolver` `getClassNameResolver()` Returns the current ClassNameResolver.
`ObjectGraphBuilder.NewInstanceResolver` `getNewInstanceResolver()` Returns the current NewInstanceResolver.
`ObjectGraphBuilder.RelationNameResolver` `getRelationNameResolver()` Returns the current RelationNameResolver.
`protected void` `postInstantiate(Object name, Map attributes, Object node)` A hook after the factory creates the node and before attributes are set.
`protected void` `preInstantiate(Object name, Map attributes, Object value)` A hook before the factory creates the node.
`protected Factory` `resolveFactory(Object name, Map attributes, Object value)` Returns the Factory associated with name.
`void` `setChildPropertySetter(Object childPropertySetter)` Sets the current ChildPropertySetter.
`void` `setClassLoader(ClassLoader classLoader)` Sets the classLoader used to load a node's class.
`void` `setClassNameResolver(Object classNameResolver)` Sets the current ClassNameResolver.
`void` `setIdentifierResolver(Object identifierResolver)` Sets the current IdentifierResolver.
`void` `setNewInstanceResolver(Object newInstanceResolver)` Sets the current NewInstanceResolver.
`void` `setReferenceResolver(Object referenceResolver)` Sets the current ReferenceResolver.
`void` `setRelationNameResolver(ObjectGraphBuilder.RelationNameResolver relationNameResolver)` Sets the current RelationNameResolver.

Methods inherited from class groovy.util.FactoryBuilderSupport

`addAttributeDelegate, addDisposalClosure, addPostInstantiateDelegate, addPostNodeCompletionDelegate, addPreInstantiateDelegate, build, build, build, checkValueIsNull, checkValueIsType, checkValueIsTypeNotString, createNode, dispose, getContext, getContexts, getCurrent, getCurrentFactory, getCurrentName, getFactories, getName, getParentContext, getParentFactory, getParentName, getParentNode, getProxyBuilder, handleNodeAttributes, invokeMethod, invokeMethod, newContext, nodeCompleted, popContext, postNodeCompletion, registerBeanFactory, registerFactory, removeAttributeDelegate, removePostInstantiateDelegate, removePostNodeCompletionDelegate, removePreInstantiateDelegate, reset, setClosureDelegate, setNodeAttributes, setParent, setProxyBuilder, withBuilder, withBuilder, withBuilder`

Methods inherited from class groovy.lang.Binding
`getProperty, getVariable, getVariables, setProperty, setVariable`

Methods inherited from class groovy.lang.GroovyObjectSupport
`getMetaClass, setMetaClass`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NODE_CLASS

    public static final String NODE_CLASS

See Also:
  Constant Field Values

### NODE_NAME

    public static final String NODE_NAME

See Also:
  Constant Field Values

### OBJECT_ID

    public static final String OBJECT_ID

See Also:
  Constant Field Values

Constructor Detail

### ObjectGraphBuilder

    public ObjectGraphBuilder()

Method Detail

### getChildPropertySetter

    public ObjectGraphBuilder.ChildPropertySetter getChildPropertySetter()

  Returns the current ChildPropertySetter.

### getClassLoader

    public ClassLoader getClassLoader()

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

### getClassNameResolver

    public ObjectGraphBuilder.ClassNameResolver getClassNameResolver()

  Returns the current ClassNameResolver.

### getNewInstanceResolver

    public ObjectGraphBuilder.NewInstanceResolver getNewInstanceResolver()

  Returns the current NewInstanceResolver.

### getRelationNameResolver

    public ObjectGraphBuilder.RelationNameResolver getRelationNameResolver()

  Returns the current RelationNameResolver.

### setChildPropertySetter

    public void setChildPropertySetter(Object childPropertySetter)

  Sets the current ChildPropertySetter.
  It will assign DefaultChildPropertySetter if null.
  It accepts a ChildPropertySetter instance or a Closure.

### setClassLoader

    public void setClassLoader(ClassLoader classLoader)

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

### setClassNameResolver

    public void setClassNameResolver(Object classNameResolver)

  Sets the current ClassNameResolver.
  It will assign DefaultClassNameResolver if null.
  It accepts a ClassNameResolver instance, a String or a Closure.

### setIdentifierResolver

    public void setIdentifierResolver(Object identifierResolver)

  Sets the current IdentifierResolver.
  It will assign DefaultIdentifierResolver if null.
  It accepts a IdentifierResolver instance or a Closure.

### setNewInstanceResolver

    public void setNewInstanceResolver(Object newInstanceResolver)

  Sets the current NewInstanceResolver.
  It will assign DefaultNewInstanceResolver if null.
  It accepts a NewInstanceResolver instance or a Closure.

### setReferenceResolver

    public void setReferenceResolver(Object referenceResolver)

  Sets the current ReferenceResolver.
  It will assign DefaultReferenceResolver if null.
  It accepts a ReferenceResolver instance or a Closure.

### setRelationNameResolver

    public void setRelationNameResolver(ObjectGraphBuilder.RelationNameResolver relationNameResolver)

  Sets the current RelationNameResolver.
  It will assign DefaultRelationNameResolver if null.

### postInstantiate

    protected void postInstantiate(Object name,
                                   Map attributes,
                                   Object node)

  Description copied from class: `FactoryBuilderSupport`
  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.

  Overrides:
    `postInstantiate` in class `FactoryBuilderSupport`

### preInstantiate

    protected void preInstantiate(Object name,
                                  Map attributes,
                                  Object value)

  Description copied from class: `FactoryBuilderSupport`
  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.

  Overrides:
    `preInstantiate` in class `FactoryBuilderSupport`

### resolveFactory

    protected Factory resolveFactory(Object name,
                                     Map attributes,
                                     Object value)

  Description copied from class: `FactoryBuilderSupport`
  Returns the Factory associated with name.
  This is a hook for subclasses to plugin a custom strategy for mapping names to factories.

  Overrides:
    `resolveFactory` in class `FactoryBuilderSupport`

Copyright © 2003-2008 The Codehaus. All rights reserved.