Class InternalKlumBuilder<M>

java.lang.Object
groovy.lang.GroovyObjectSupport
com.blackbuild.klum.ast.runtime.internal.InternalKlumBuilder<M>
All Implemented Interfaces:
KlumBuilder<M>, groovy.lang.GroovyObject, Serializable
Direct Known Subclasses:
GeneratedKlumBuilder

public abstract class InternalKlumBuilder<M> extends groovy.lang.GroovyObjectSupport implements KlumBuilder<M>, Serializable
Mutable construction-time counterpart of a DSL Object.

Generated Builders inherit this internal support base and own every mutable value until the graph is materialized. A completed model never retains its Builder.

The public KlumBuilder capability deliberately exposes no runtime operations. Generated implementations use this class internally.

See Also:
  • Field Details

  • Constructor Details

    • InternalKlumBuilder

      protected InternalKlumBuilder(Class<M> modelType)
  • Method Details

    • $attachConstructionSession

      public final void $attachConstructionSession(ConstructionSession session)
      Internal hook used by PhaseDriver; the token remains opaque to clients.
    • $completeConstructionSession

      public final void $completeConstructionSession(ConstructionSession session)
      Internal hook used by PhaseDriver when the owning root lifecycle ends.
    • $isInActiveConstructionSession

      public final boolean $isInActiveConstructionSession(ConstructionSession session)
      Internal hook used by PhaseDriver to keep Builder adapters in their owning session.
    • getModelType

      public final Class<M> getModelType()
    • isSealed

      public final boolean isSealed()
    • isTemplate

      public final boolean isTemplate()
    • markAsTemplate

      public final void markAsTemplate()
    • getCompletedModel

      public final M getCompletedModel()
    • sealTo

      public final void sealTo(M existingModel)
    • $modelImplementationType

      protected abstract Class<? extends M> $modelImplementationType()
      Identifies the generated model implementation. Allocation remains private to graph materialization.
    • $assignRelationships

      protected void $assignRelationships()
      Assigns relationship fields after every object in the graph was allocated.
    • materializeTemplateForImport

      public static Object materializeTemplateForImport(InternalKlumBuilder<?> root)
      Internal adapter hook that materializes a value-only Template graph without lifecycle phases.
    • $assignMaterializedRelationship

      protected void $assignMaterializedRelationship(String fieldName)
      Internal Builder hook that assigns one completed relationship without exposing a model mutator.
    • $snapshotField

      public final Object $snapshotField(String fieldName)
      Called by generated model constructors for non-relationship fields.
    • $materializeRelationship

      public final Object $materializeRelationship(String fieldName)
      Called by generated internal relationship assignment code.
    • $createCompanion

      public final KlumObjectCompanion $createCompanion(groovy.lang.GroovyObject model)
      Creates the internal companion retained by a generated DSL Object. Public visibility exists only for generated constructors in arbitrary packages.
    • getInstanceAttribute

      public <T> T getInstanceAttribute(String attributeName)
    • getInstanceAttributeOrGetter

      public <T> T getInstanceAttributeOrGetter(String attributeName)
    • getInstanceProperty

      public Object getInstanceProperty(String name)
    • setInstanceAttribute

      public void setInstanceAttribute(String name, Object value)
    • getField

      public Field getField(String name)
    • getModelField

      public Field getModelField(String name)
    • apply

      public Object apply(Map<String,?> values, groovy.lang.Closure<?> body)
      Applies named values and a configuration closure to this Builder.
      Parameters:
      values - named values translated into Builder method calls
      body - closure executed against this Builder
      Returns:
      this Builder
    • apply

      public Object apply(Map<String,?> values)
    • apply

      public Object apply(groovy.lang.Closure<?> body)
    • applyOnly

      public void applyOnly(Map<String,?> values, groovy.lang.Closure<?> body)
    • copyFrom

      public void copyFrom(Object template)
      Copies all non-null/non-empty recipe values from the template to this Builder.
      Parameters:
      template - the recipe to apply
    • copyFromRecipe

      public void copyFromRecipe(Object template)
      Internal target used by generated typed copyFrom overloads.
    • getNullableKey

      public Object getNullableKey()
    • getSingleOwner

      public Object getSingleOwner()
    • getOwners

      public Set<Object> getOwners()
    • createSingleChild

      public <T> T createSingleChild(Map<String,Object> namedParams, String fieldOrMethodName, Class<T> type, boolean explicitType, String key, groovy.lang.Closure<T> body)
      Creates a new '{{fieldName}}' Builder {{param:type?with the given type}} or configures the existing Builder. The resulting Builder is configured by the optional values and closure.
      Type Parameters:
      T - the generated Builder type
      Parameters:
      namedParams - the optional parameters
      fieldOrMethodName - the name of the field to set or Builder method to call
      type - the model type of the new Builder
      key - the key to use for the new Builder
      body - the closure used to configure the Builder
      Returns:
      the newly created or existing Builder
    • createSingleChild

      public Object createSingleChild(Map<String,Object> namedParams, String fieldOrMethodName, KlumFactory.BuilderFactoryProvider<?,?> factory, String key, groovy.lang.Closure<?> body)
      Creates an owned child selected by its generated factory without opening a root lifecycle.

      The provider exposes the factory's active-session view. Its selected public Builder type is preserved for generated static signatures while this method keeps the existing child creation and materialization path.

    • setSingleField

      public <T> T setSingleField(String fieldOrMethodName, T value)
      Sets '{{fieldName}}' on this Builder, or calls a Builder method with that name.
      Type Parameters:
      T - the value type
      Parameters:
      fieldOrMethodName - the field or method name
      value - the value to set
      Returns:
      the supplied value
    • link

      public <T> T link(String fieldName, T target)
      Adds an aggregation fallback during @AutoLink processing without replacing configured values. The target must already be a completed model or a Builder claimed by another composition relationship.
    • setSingleFieldViaConverter

      public <T> T setSingleFieldViaConverter(String fieldOrMethodName, Class<?> converterType, String converterMethod, Object... args)
    • addElementToCollection

      public <T> T addElementToCollection(String fieldName, T element)
      Adds an existing '{{singleElementName}}' to the Builder's '{{fieldName}}' collection.
      Type Parameters:
      T - the element type
      Parameters:
      fieldName - the collection field name
      element - the element to add
      Returns:
      the added element
    • addElementToCollectionViaConverter

      public <T> T addElementToCollectionViaConverter(String fieldOrMethodName, Class<?> converterType, String converterMethod, Object... args)
    • addNewDslElementToCollection

      public <T> T addNewDslElementToCollection(Map<String,Object> namedParams, String collectionName, Class<? extends T> type, boolean explicitType, String key, groovy.lang.Closure<T> body)
      Creates a new '{{singleElementName}}' Builder {{param:type?with the given type}} and adds it to the Builder's '{{fieldName}}' collection. The newly created Builder is configured by the optional values and closure.
      Type Parameters:
      T - the generated Builder type
      Parameters:
      namedParams - the optional parameters
      collectionName - the collection field name
      type - the model type of the new Builder
      key - the key to use for the new Builder
      body - the closure used to configure the Builder
      Returns:
      the newly created Builder
    • addNewDslElementToCollection

      public Object addNewDslElementToCollection(Map<String,Object> namedParams, String collectionName, KlumFactory.BuilderFactoryProvider<?,?> factory, String key, groovy.lang.Closure<?> body)
      Adds an owned collection child selected by its generated factory in the current session.
    • addElementsToCollection

      public void addElementsToCollection(String fieldName, Object... elements)
      Adds one or more existing '{{singleElementName}}' values to the Builder's '{{fieldName}}' collection.
      Parameters:
      fieldName - the collection field name
      elements - the elements to add
    • addElementsToCollection

      public void addElementsToCollection(String fieldName, Iterable<?> elements)
      Adds one or more existing '{{singleElementName}}' values to the Builder's '{{fieldName}}' collection.
      Parameters:
      fieldName - the collection field name
      elements - the elements to add
    • addProjectedBuildersFromCollectionToCollection

      public <C extends Collection<?>> C addProjectedBuildersFromCollectionToCollection(String fieldName, C builders)
      Attaches a projected batch of child Builders and returns the producer's original container.
    • addProjectedBuildersFromMapToCollection

      public <T extends Map<?, ?>> T addProjectedBuildersFromMapToCollection(String fieldName, T builders)
      Attaches the values of a projected map to a collection relationship and returns the same map.
    • addElementsToMap

      public <K, V> void addElementsToMap(String fieldName, Map<K,V> values)
    • addProjectedBuildersFromMapToMap

      public <T extends Map<?, ?>> T addProjectedBuildersFromMapToMap(String fieldName, T builders)
      Attaches a projected map of child Builders, preserving its keys, then returns that same map.
    • addProjectedBuildersFromCollectionToMap

      public <C extends Collection<?>> C addProjectedBuildersFromCollectionToMap(String fieldName, C builders)
      Attaches a projected collection to a keyed relationship and returns the producer's original collection.
    • addElementsToMap

      public <V> void addElementsToMap(String fieldName, Iterable<V> values)
    • addElementsToMap

      public void addElementsToMap(String fieldName, Object... values)
    • addNewDslElementToMap

      public <T> T addNewDslElementToMap(Map<String,Object> namedParams, String mapName, Class<? extends T> type, boolean explicitType, String key, groovy.lang.Closure<T> body)
      Creates a new '{{singleElementName}}' Builder {{param:type?with the given type}} and adds it to the Builder's '{{fieldName}}' map. The newly created Builder is configured by the optional values and closure.
      Type Parameters:
      T - the generated Builder type
      Parameters:
      namedParams - the optional parameters
      mapName - the map field name
      type - the model type of the new Builder
      key - the key to use for the new Builder
      body - the closure used to configure the Builder
      Returns:
      the newly created Builder
    • addNewDslElementToMap

      public Object addNewDslElementToMap(Map<String,Object> namedParams, String mapName, KlumFactory.BuilderFactoryProvider<?,?> factory, String key, groovy.lang.Closure<?> body)
      Adds an owned map child selected by its generated factory in the current session.
    • addElementToMap

      public <K, V> V addElementToMap(String fieldName, K key, V value)
    • addElementToMapViaConverter

      public <K, V> V addElementToMapViaConverter(String fieldOrMethodName, Class<?> converterType, String converterMethod, K key, Object... args)
    • addElementsFromScriptsToCollection

      @SafeVarargs public final void addElementsFromScriptsToCollection(String fieldName, Class<? extends groovy.lang.Script>... scripts)
    • addElementsFromScriptsToMap

      @SafeVarargs public final void addElementsFromScriptsToMap(String fieldName, Class<? extends groovy.lang.Script>... scripts)
    • copyFromTemplate

      public void copyFromTemplate()
    • resolveKeyForFieldFromAnnotation

      public Optional<String> resolveKeyForFieldFromAnnotation(String name, AnnotatedElement field)
    • getBreadcrumbPath

      public String getBreadcrumbPath()
    • setBreadcrumbPath

      public void setBreadcrumbPath(String breadcrumbPath)
    • increaseBreadcrumbQuantifier

      public void increaseBreadcrumbQuantifier()
    • setCurrentTemplates

      public void setCurrentTemplates(Map<Class<?>,Object> currentTemplates)
    • getCurrentTemplates

      public Map<Class<?>,Object> getCurrentTemplates()
    • applyLater

      public void applyLater(groovy.lang.Closure<?> closure)
    • scheduleApplyLater

      public void scheduleApplyLater(groovy.lang.Closure<?> closure)
    • applyLater

      public void applyLater(KlumPhase phase, groovy.lang.Closure<?> closure)
    • scheduleApplyLater

      public void scheduleApplyLater(KlumPhase phase, groovy.lang.Closure<?> closure)
    • applyLater

      public void applyLater(Integer number, groovy.lang.Closure<?> closure)
    • scheduleApplyLater

      public void scheduleApplyLater(Integer number, groovy.lang.Closure<?> closure)
    • executeApplyLaterClosures

      public void executeApplyLaterClosures(int phase)
    • cleanup

      public void cleanup()
    • setModelPath

      public void setModelPath(String path)
    • getModelPath

      public String getModelPath()