Record Class GrammarCatalogEntry

java.lang.Object
java.lang.Record
name.jurgenei.gradle.antlr.catalog.GrammarCatalogEntry

public record GrammarCatalogEntry(String name, String runtimeGrammar, String parser, String lexer, String startRule) extends Record
Immutable grammar entry loaded from a catalog file.
  • Constructor Details

    • GrammarCatalogEntry

      public GrammarCatalogEntry(String name, String runtimeGrammar, String parser, String lexer, String startRule)
      Creates an immutable grammar catalog entry.
      Parameters:
      name - catalog grammar name.
      runtimeGrammar - optional runtime grammar key used by legacy converter mode.
      parser - parser coordinate (path or class name depending on task configuration).
      lexer - lexer coordinate (path or class name depending on task configuration).
      startRule - parser entry rule name.
  • Method Details

    • name

      public String name()
      Returns the catalog grammar name.
      Returns:
      catalog grammar name.
    • runtimeGrammar

      public String runtimeGrammar()
      Returns the optional runtime grammar alias.
      Returns:
      optional runtime grammar key.
    • parser

      public String parser()
      Returns the parser coordinate from the catalog entry.
      Returns:
      parser coordinate value.
    • lexer

      public String lexer()
      Returns the lexer coordinate from the catalog entry.
      Returns:
      lexer coordinate value.
    • startRule

      public String startRule()
      Returns the parser start rule configured for this entry.
      Returns:
      parser entry rule name.
    • resolveRuntimeGrammar

      public String resolveRuntimeGrammar()
      Resolves effective runtime grammar key.
      Returns:
      runtimeGrammar when provided, otherwise name.
    • resolveParserPath

      public Path resolveParserPath(Path baseDirectory)
      Resolves parser coordinate to a local path when applicable.
      Parameters:
      baseDirectory - base directory used for relative coordinates.
      Returns:
      local parser path, or null for non-file URIs.
    • resolveLexerPath

      public Path resolveLexerPath(Path baseDirectory)
      Resolves lexer coordinate to a local path when applicable.
      Parameters:
      baseDirectory - base directory used for relative coordinates.
      Returns:
      local lexer path, or null for non-file URIs.
    • resolveParserUri

      public URI resolveParserUri(Path baseDirectory)
      Resolves parser coordinate to a URI.
      Parameters:
      baseDirectory - base directory used for relative coordinates.
      Returns:
      parser URI.
    • resolveLexerUri

      public URI resolveLexerUri(Path baseDirectory)
      Resolves lexer coordinate to a URI.
      Parameters:
      baseDirectory - base directory used for relative coordinates.
      Returns:
      lexer URI.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.