Record Class SourceSpan

java.lang.Object
java.lang.Record
org.clafer.frontend.SourceSpan
Record Components:
line - the first line
column - the first column
endLine - the last line
endColumn - the column after the last character

public record SourceSpan(int line, int column, int endLine, int endColumn) extends Record
Where a clafer, constraint, assertion or objective is in the source model: from line:column up to, not including, endLine:endColumn. Lines and columns start at 1, as in the Clafer compiler's error messages.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SourceSpan(int line, int column, int endLine, int endColumn)
    Creates an instance of a SourceSpan record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static SourceSpan
    at(int line, int column)
     
    int
    Returns the value of the column record component.
    int
    Returns the value of the endColumn record component.
    int
    Returns the value of the endLine record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    format(String message)
    Prefixes a message with the start of this span, as the compiler's messages are.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the line record component.
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • SourceSpan

      public SourceSpan(int line, int column, int endLine, int endColumn)
      Creates an instance of a SourceSpan record class.
      Parameters:
      line - the value for the line record component
      column - the value for the column record component
      endLine - the value for the endLine record component
      endColumn - the value for the endColumn record component
  • Method Details

    • at

      public static SourceSpan at(int line, int column)
      Parameters:
      line - the line
      column - the column
      Returns:
      the empty span at a position, for when only the start is known
    • format

      public String format(String message)
      Prefixes a message with the start of this span, as the compiler's messages are.
      Parameters:
      message - the message
      Returns:
      "line:column: message"
    • toString

      public 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 the compare method from their corresponding wrapper classes.
      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.
    • line

      public int line()
      Returns the value of the line record component.
      Returns:
      the value of the line record component
    • column

      public int column()
      Returns the value of the column record component.
      Returns:
      the value of the column record component
    • endLine

      public int endLine()
      Returns the value of the endLine record component.
      Returns:
      the value of the endLine record component
    • endColumn

      public int endColumn()
      Returns the value of the endColumn record component.
      Returns:
      the value of the endColumn record component