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- theIDatatypeManagertypeS- theIGenerationStatetype
- 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
Constructors Constructor Description AbstractSchemaGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected List<IAssemblyDefinition>analyzeDefinitions(S generationState, BiConsumer<ModuleIndex.DefinitionEntry,IDefinition> handler)Determine the collection of root definitions.voidgenerateFromModule(IModule metaschema, Writer out, IConfiguration<SchemaGenerationFeature<?>> configuration)Generate and write a schema for the providedmetaschemato theWriterprovided bywriterusing the providedconfiguration.protected abstract voidgenerateSchema(S generationState)Called to generate the actual schema content.protected abstract SnewGenerationState(IModule module, T schemaWriter, IConfiguration<SchemaGenerationFeature<?>> configuration)Create a new schema generation state object.protected abstract TnewWriter(Writer out)Create a new writer to use to write the schema.
-
-
-
Constructor Detail
-
AbstractSchemaGenerator
public AbstractSchemaGenerator()
-
-
Method Detail
-
newWriter
@NonNull protected abstract T newWriter(@NonNull Writer out)
Create a new writer to use to write the schema.- Parameters:
out- theWriterto 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
protected abstract void generateSchema(@NonNull S generationState)
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:ISchemaGeneratorGenerate and write a schema for the providedmetaschemato theWriterprovided bywriterusing the providedconfiguration.- Specified by:
generateFromModulein 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
-
-