Package: groovy.util

## [Java] Class ObjectGraphBuilder

- groovy.util.ObjectGraphBuilder

- 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 Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `interface` | `ObjectGraphBuilder.ChildPropertySetter` | Strategy for setting a child node on its parent.
    `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 and childName accordingly.
    `interface` | `ObjectGraphBuilder.IdentifierResolver` | Strategy for picking the correct synthetic identifier.
    `interface` | `ObjectGraphBuilder.NewInstanceResolver` | Strategy for creating new instances of a class.
    `interface` | `ObjectGraphBuilder.ReferenceResolver` | Strategy for picking the correct synthetic reference identifier.
    `class` | `ObjectGraphBuilder.ReflectionClassNameResolver` | Build objects using reflection to resolve class names.
    `interface` | `ObjectGraphBuilder.RelationNameResolver` | Strategy for resolving a relationship property name.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `CLASSNAME_RESOLVER_KEY` |
    `static String` | `CLASSNAME_RESOLVER_REFLECTION` |
    `static String` | `CLASSNAME_RESOLVER_REFLECTION_ROOT` |
    `static String` | `LAZY_REF` |
    `static String` | `NODE_CLASS` |
    `static String` | `NODE_NAME` |
    `static String` | `OBJECT_ID` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class FactoryBuilderSupport` | `CURRENT_FACTORY, PARENT_FACTORY, PARENT_NODE, CURRENT_NODE, PARENT_CONTEXT, PARENT_NAME, CURRENT_NAME, OWNER, PARENT_BUILDER, CURRENT_BUILDER, CHILD_BUILDER, SCRIPT_CLASS_NAME`

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `String` | `beanFactoryName`
    `ObjectGraphBuilder.ChildPropertySetter` | `childPropertySetter`
    `ClassLoader` | `classLoader`
    `ObjectGraphBuilder.ClassNameResolver` | `classNameResolver`
    `boolean` | `lazyReferencesAllowed`
    `ObjectGraphBuilder.NewInstanceResolver` | `newInstanceResolver`
    `ObjectGraphBuilder.RelationNameResolver` | `relationNameResolver`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ObjectGraphBuilder ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `String` | `getBeanFactoryName()` Returns the current name of the 'bean' node.
    `` | `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.
    `` | `boolean` | `isLazyReferencesAllowed()` Returns true if references can be resolved lazily
    `` | `protected void` | `postInstantiate(Object name, Map attributes, Object node)`
    `` | `protected void` | `preInstantiate(Object name, Map attributes, Object value)`
    `` | `protected Factory` | `resolveFactory(Object name, Map attributes, Object value)`
    `` | `void` | `setBeanFactoryName(String beanFactoryName)` Sets the name for the 'bean' node.
    `` | `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` | `setLazyReferencesAllowed(boolean lazyReferencesAllowed)` Sets whether references can be resolved lazily or not.
    `` | `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.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class FactoryBuilderSupport` | `getProperty, getName, setProperty, getContext, build, build, build, dispose, invokeMethod, invokeMethod, getCurrent, getParentName, registerFactory, registerFactory, setVariable, getVariable, getVariables, getParentNode, checkValueIsType, getLocalFactories, getParentFactory, getChildBuilder, getParentContext, checkValueIsNull, autoRegisterNodes, getFactories, getCurrentBuilder, getExplicitMethods, getCurrentFactory, withBuilder, withBuilder, withBuilder, addDisposalClosure, getCurrentName, registerBeanFactory, registerBeanFactory, addPostInstantiateDelegate, setMethodMissingDelegate, getContextAttribute, getPostInstantiateDelegates, registerExplicitProperty, registerExplicitProperty, addAttributeDelegate, getPropertyMissingDelegate, getPostNodeCompletionDelegates, removePostInstantiateDelegate, getAttributeDelegates, getLocalExplicitProperties, getLocalExplicitMethods, getPreInstantiateDelegates, removePreInstantiateDelegate, getRegistrationGroups, checkValueIsTypeNotString, setPropertyMissingDelegate, addPreInstantiateDelegate, removeAttributeDelegate, getRegistrationGroupItems, getNameMappingClosure, setNameMappingClosure, removePostNodeCompletionDelegate, getExplicitProperties, registerExplicitMethod, registerExplicitMethod, getMethodMissingDelegate, addPostNodeCompletionDelegate, getDisposalClosures, hasVariable, getMetaClass, setMetaClass, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### public static final String CLASSNAME_RESOLVER_KEY

    - #### public static final String CLASSNAME_RESOLVER_REFLECTION

    - #### public static final String CLASSNAME_RESOLVER_REFLECTION_ROOT

    - #### public static final String LAZY_REF

    - #### public static final String NODE_CLASS

    - #### public static final String NODE_NAME

    - #### public static final String OBJECT_ID

  - ### Property Detail

    - #### String beanFactoryName

    - #### ObjectGraphBuilder.ChildPropertySetter childPropertySetter

    - #### ClassLoader classLoader

    - #### ObjectGraphBuilder.ClassNameResolver classNameResolver

    - #### boolean lazyReferencesAllowed

    - #### ObjectGraphBuilder.NewInstanceResolver newInstanceResolver

    - #### ObjectGraphBuilder.RelationNameResolver relationNameResolver

  - ### Constructor Detail

    - #### public ObjectGraphBuilder()

  - ### Method Detail

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

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

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

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

    - #### public void setBeanFactoryName(String beanFactoryName)

      Sets the name for the 'bean' node.

    - #### public void setChildPropertySetter(Object childPropertySetter)

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

    - #### public void setClassLoader(ClassLoader classLoader)

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

    - #### public void setClassNameResolver(Object classNameResolver)

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

    - #### public void setIdentifierResolver(Object identifierResolver)

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

    - #### public void setLazyReferencesAllowed(boolean lazyReferencesAllowed)

      Sets whether references can be resolved lazily or not.

    - #### public void setNewInstanceResolver(Object newInstanceResolver)

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

    - #### public void setReferenceResolver(Object referenceResolver)

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

    - #### public void setRelationNameResolver(ObjectGraphBuilder.RelationNameResolver relationNameResolver)

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