Module dev.metaschema.schemagen
Package dev.metaschema.schemagen
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 outputDATATYPE_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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a collection of allowed values with a flag indicating whether the value set is closed (no other values allowed) or open. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractGenerationState(IModule module, WRITER writer, IConfiguration<SchemaGenerationFeature<?>> configuration, DATATYPE_MANAGER datatypeManager) Construct a new generation state instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected static AbstractGenerationState.AllowedValueCollectionRetrieve any allowed values that are context independent, meaning they always apply regardless of the location of the node in the larger graph.protected DATATYPE_MANAGERGet the datatype manager used for type name resolution.Get the module index containing indexed definitions from the module.Get the Metaschema module being processed for schema generation.getTypeNameForDefinition(IDefinition definition, String suffix) Generate a type name for the provided definition with an optional suffix.Get the writer used for schema output.booleanisInline(IDefinition definition) Determine if the provided definition should be inlined in the generated schema.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.metaschema.schemagen.IGenerationState
flushWriter, getRootDefinitions
-
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 forwriter- the output writer for the generated schemaconfiguration- the configuration controlling schema generation behaviordatatypeManager- the manager for handling datatype name resolution
-
-
Method Details
-
getModule
Description copied from interface:IGenerationStateGet the Metaschema module being processed for schema generation.- Specified by:
getModulein interfaceIGenerationState<WRITER>- Returns:
- the module
-
getWriter
Description copied from interface:IGenerationStateGet the writer used for schema output.The caller does not own this writer and must not close it.
- Specified by:
getWriterin interfaceIGenerationState<WRITER>- Returns:
- the writer instance
-
getDatatypeManager
Get the datatype manager used for type name resolution.- Returns:
- the datatype manager
-
getMetaschemaIndex
Get the module index containing indexed definitions from the module.- Returns:
- the module index
-
isInline
Description copied from interface:IGenerationStateDetermine if the provided definition should be inlined in the generated schema.- Specified by:
isInlinein interfaceIGenerationState<WRITER>- Parameters:
definition- the definition to check- Returns:
trueif the definition should be inlined,falseotherwise
-
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:IGenerationStateGenerate a type name for the provided definition with an optional suffix.- Specified by:
getTypeNameForDefinitionin interfaceIGenerationState<WRITER>- Parameters:
definition- the definition to generate a type name forsuffix- an optional suffix to append to the type name, ornullif no suffix is needed- Returns:
- the generated type name
-