Class ModuleIndex

java.lang.Object
dev.metaschema.schemagen.ModuleIndex

public class ModuleIndex extends Object
Indexes definitions from a Metaschema module for use in schema generation.

This class maintains an ordered index of all definitions that are reachable from root assembly definitions, tracking their reference counts, inline status, and other usage patterns relevant to schema generation.

  • Constructor Details

    • ModuleIndex

      public ModuleIndex()
  • Method Details

    • indexDefinitions

      @NonNull public static ModuleIndex indexDefinitions(@NonNull IModule module, @NonNull IInlineStrategy inlineStrategy)
      Creates an index of all definitions reachable from the module's root assembly definitions.
      Parameters:
      module - the Metaschema module to index
      inlineStrategy - the strategy for determining which definitions should be inlined
      Returns:
      a new module index containing entries for all reachable definitions
    • hasEntry

      public boolean hasEntry(@NonNull IDefinition definition)
      Checks if an entry exists in this index for the specified definition.
      Parameters:
      definition - the definition to check
      Returns:
      true if an entry exists for the definition, false otherwise
    • getEntry

      @NonNull public ModuleIndex.DefinitionEntry getEntry(@NonNull IDefinition definition)
      Retrieves or creates the entry for the specified definition.

      If no entry exists for the definition, a new entry is created and added to the index.

      Parameters:
      definition - the definition to get an entry for
      Returns:
      the existing or newly created entry for the definition
    • getDefinitions

      @NonNull public Collection<ModuleIndex.DefinitionEntry> getDefinitions()
      Retrieves all definition entries in this index.
      Returns:
      an unmodifiable collection of all definition entries, in insertion order