Class AbstractGenerationState<WRITER,DATATYPE_MANAGER extends dev.metaschema.schemagen.datatype.IDatatypeManager>

java.lang.Object
dev.metaschema.schemagen.AbstractGenerationState<WRITER,DATATYPE_MANAGER>
Type Parameters:
WRITER - the type of writer used for schema output
DATATYPE_MANAGER - the type of datatype manager used for type name resolution
All Implemented Interfaces:
IGenerationState<WRITER>

public abstract class AbstractGenerationState<WRITER,DATATYPE_MANAGER extends dev.metaschema.schemagen.datatype.IDatatypeManager> extends Object implements IGenerationState<WRITER>
Provides a common base implementation for schema generation state management.

This abstract class maintains the context required during schema generation, including the module being processed, the output writer, datatype management, and inlining strategy.

  • Constructor Details

    • AbstractGenerationState

      public AbstractGenerationState(@NonNull IModule module, @NonNull WRITER writer, @NonNull IConfiguration<SchemaGenerationFeature<?>> configuration, @NonNull DATATYPE_MANAGER datatypeManager)
      Construct a new generation state instance.
      Parameters:
      module - the Metaschema module to generate a schema for
      writer - the output writer for the generated schema
      configuration - the configuration controlling schema generation behavior
      datatypeManager - the manager for handling datatype name resolution
  • Method Details

    • getModule

      public IModule getModule()
      Description copied from interface: IGenerationState
      Get the Metaschema module being processed for schema generation.
      Specified by:
      getModule in interface IGenerationState<WRITER>
      Returns:
      the module
    • getWriter

      @NotOwning public WRITER getWriter()
      Description copied from interface: IGenerationState
      Get the writer used for schema output.

      The caller does not own this writer and must not close it.

      Specified by:
      getWriter in interface IGenerationState<WRITER>
      Returns:
      the writer instance
    • getDatatypeManager

      @NonNull protected DATATYPE_MANAGER getDatatypeManager()
      Get the datatype manager used for type name resolution.
      Returns:
      the datatype manager
    • getMetaschemaIndex

      @NonNull public ModuleIndex getMetaschemaIndex()
      Get the module index containing indexed definitions from the module.
      Returns:
      the module index
    • isInline

      public boolean isInline(@NonNull IDefinition definition)
      Description copied from interface: IGenerationState
      Determine if the provided definition should be inlined in the generated schema.
      Specified by:
      isInline in interface IGenerationState<WRITER>
      Parameters:
      definition - the definition to check
      Returns:
      true if the definition should be inlined, false otherwise
    • getContextIndependentEnumeratedValues

      @NonNull protected static AbstractGenerationState.AllowedValueCollection getContextIndependentEnumeratedValues(@NonNull IValuedDefinition definition)
      Retrieve any allowed values that are context independent, meaning they always apply regardless of the location of the node in the larger graph.
      Parameters:
      definition - the definition to get allowed values for
      Returns:
      the list of allowed values or an empty list
    • getTypeNameForDefinition

      @NonNull public String getTypeNameForDefinition(@NonNull IDefinition definition, @Nullable String suffix)
      Description copied from interface: IGenerationState
      Generate a type name for the provided definition with an optional suffix.
      Specified by:
      getTypeNameForDefinition in interface IGenerationState<WRITER>
      Parameters:
      definition - the definition to generate a type name for
      suffix - an optional suffix to append to the type name, or null if no suffix is needed
      Returns:
      the generated type name