Class AbstractSchemaGenerator<T extends AutoCloseable,D extends gov.nist.secauto.metaschema.schemagen.datatype.IDatatypeManager,S extends AbstractGenerationState<T,D>>
java.lang.Object
gov.nist.secauto.metaschema.schemagen.AbstractSchemaGenerator<T,D,S>
- Type Parameters:
T
- the writer typeD
- theIDatatypeManager
typeS
- theIGenerationState
type
- All Implemented Interfaces:
ISchemaGenerator
- Direct Known Subclasses:
JsonSchemaGenerator
,XmlSchemaGenerator
public abstract class AbstractSchemaGenerator<T extends AutoCloseable,D extends gov.nist.secauto.metaschema.schemagen.datatype.IDatatypeManager,S extends AbstractGenerationState<T,D>>
extends Object
implements ISchemaGenerator
Thsi abstract class provides a common implementation shared by all schema
generators.
-
Nested Class Summary
Nested classes/interfaces inherited from interface gov.nist.secauto.metaschema.schemagen.ISchemaGenerator
ISchemaGenerator.SchemaFormat
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected List<IAssemblyDefinition>
analyzeDefinitions
(S generationState, BiConsumer<ModuleIndex.DefinitionEntry, IDefinition> handler) Determine the collection of root definitions.void
generateFromModule
(IModule metaschema, Writer out, IConfiguration<SchemaGenerationFeature<?>> configuration) Generate and write a schema for the providedmetaschema
to theWriter
provided bywriter
using the providedconfiguration
.protected abstract void
generateSchema
(S generationState) Called to generate the actual schema content.protected abstract S
newGenerationState
(IModule module, T schemaWriter, IConfiguration<SchemaGenerationFeature<?>> configuration) Create a new schema generation state object.protected abstract T
Create a new writer to use to write the schema.
-
Constructor Details
-
AbstractSchemaGenerator
public AbstractSchemaGenerator()
-
-
Method Details
-
newWriter
Create a new writer to use to write the schema.- Parameters:
out
- theWriter
to write the schema content to- Returns:
- the schema writer
- Throws:
SchemaGenerationException
- if an error occurred while creating the writer
-
newGenerationState
@NonNull protected abstract S newGenerationState(@NonNull IModule module, @NonNull T schemaWriter, @NonNull IConfiguration<SchemaGenerationFeature<?>> configuration) Create a new schema generation state object.- Parameters:
module
- the Metaschema module to generate the schema forschemaWriter
- the writer to use to write the schemaconfiguration
- the generation configuration- Returns:
- the schema generation state used for context and writing
- Throws:
SchemaGenerationException
- if an error occurred while creating the generation state object
-
generateSchema
Called to generate the actual schema content.- Parameters:
generationState
- the generation state object
-
generateFromModule
public void generateFromModule(IModule metaschema, Writer out, IConfiguration<SchemaGenerationFeature<?>> configuration) Description copied from interface:ISchemaGenerator
Generate and write a schema for the providedmetaschema
to theWriter
provided bywriter
using the providedconfiguration
.- Specified by:
generateFromModule
in interfaceISchemaGenerator
- Parameters:
metaschema
- the Module to generate the schema forout
- the writer to use to write the schemaconfiguration
- the schema generation configuration
-
analyzeDefinitions
protected List<IAssemblyDefinition> analyzeDefinitions(@NonNull S generationState, @Nullable BiConsumer<ModuleIndex.DefinitionEntry, IDefinition> handler) Determine the collection of root definitions.- Parameters:
generationState
- the schema generation state used for context and writinghandler
- a callback to execute on each identified root definition- Returns:
- the list of identified root definitions
-