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 type
D - the IDatatypeManager type
S - the IGenerationState 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.
  • Constructor Details

  • Method Details

    • newWriter

      @NonNull protected abstract T newWriter(@NonNull Writer out)
      Create a new writer to use to write the schema.
      Parameters:
      out - the Writer 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 for
      schemaWriter - the writer to use to write the schema
      configuration - 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: ISchemaGenerator
      Generate and write a schema for the provided metaschema to the Writer provided by writer using the provided configuration.
      Specified by:
      generateFromModule in interface ISchemaGenerator
      Parameters:
      metaschema - the Module to generate the schema for
      out - the writer to use to write the schema
      configuration - 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 writing
      handler - a callback to execute on each identified root definition
      Returns:
      the list of identified root definitions