Package groovy.util

Class 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.
  • Field Details

  • Constructor Details

    • ObjectGraphBuilder

      public ObjectGraphBuilder()
  • Method Details

    • getBeanFactoryName

      public String getBeanFactoryName()
      Returns the current name of the 'bean' node.
    • 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.
    • isLazyReferencesAllowed

      public boolean isLazyReferencesAllowed()
      Returns true if references can be resolved lazily
    • setBeanFactoryName

      public void setBeanFactoryName​(String beanFactoryName)
      Sets the name for the 'bean' node.
    • 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, a Closure or a Map.
    • setIdentifierResolver

      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.
    • setLazyReferencesAllowed

      public void setLazyReferencesAllowed​(boolean lazyReferencesAllowed)
      Sets whether references can be resolved lazily or not.
    • 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, a String 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
      Parameters:
      name - the name of the node
      attributes - the attributes for the node
      node - the object created by the node factory
    • 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
      Parameters:
      name - the name of the node
      attributes - the attributes of the node
      value - the value argument(s) of the node
    • resolveFactory

      protected Factory resolveFactory​(Object name, Map attributes, Object value)
      Description copied from class: FactoryBuilderSupport
      This is a hook for subclasses to plugin a custom strategy for mapping names to factories.
      Overrides:
      resolveFactory in 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.