Record Class SourceLocation

java.lang.Object
java.lang.Record
com.kazforge.jsonapi.diagnostic.SourceLocation
All Implemented Interfaces:
Serializable

public record SourceLocation(int lineNumber, int columnNumber, long charOffset, long byteOffset) extends Record implements Serializable
Backend-independent payload-safe source position for a document-read diagnostic. The current Jackson adapters populate it from parser positions reported through caller-configured Jackson.

The value contains line, column, and character/byte offsets only, never source text. A negative component is unavailable; UNKNOWN has no available components.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SourceLocation
    Location when the current backend did not report a usable position.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SourceLocation(int lineNumber, int columnNumber, long charOffset, long byteOffset)
    Creates an instance of a SourceLocation record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the byteOffset record component.
    long
    Returns the value of the charOffset record component.
    int
    Returns the value of the columnNumber record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether at least one position component is available.
    int
    Returns the value of the lineNumber record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • UNKNOWN

      public static final SourceLocation UNKNOWN
      Location when the current backend did not report a usable position.
  • Constructor Details

    • SourceLocation

      public SourceLocation(int lineNumber, int columnNumber, long charOffset, long byteOffset)
      Creates an instance of a SourceLocation record class.
      Parameters:
      lineNumber - the value for the lineNumber record component
      columnNumber - the value for the columnNumber record component
      charOffset - the value for the charOffset record component
      byteOffset - the value for the byteOffset record component
  • Method Details

    • isKnown

      public boolean isKnown()
      Returns whether at least one position component is available.
    • 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 '=='.
      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.
    • lineNumber

      public int lineNumber()
      Returns the value of the lineNumber record component.
      Returns:
      the value of the lineNumber record component
    • columnNumber

      public int columnNumber()
      Returns the value of the columnNumber record component.
      Returns:
      the value of the columnNumber record component
    • charOffset

      public long charOffset()
      Returns the value of the charOffset record component.
      Returns:
      the value of the charOffset record component
    • byteOffset

      public long byteOffset()
      Returns the value of the byteOffset record component.
      Returns:
      the value of the byteOffset record component