Record Class LineRange

java.lang.Object
java.lang.Record
org.variantsync.diffdetective.util.LineRange
Record Components:
fromInclusive - The starting line number of this range. This number is included within the range.
toExclusive - The ending line number of this range. This number is excluded from the range (i.e., it points to the line right after the last line).

public record LineRange(int fromInclusive, int toExclusive) extends Record
Class to hold a range of line numbers. Mainly used to locate code snippets in source code files and textual diffs.
Author:
Paul Bittner
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    The field for the fromInclusive record component.
    private final int
    The field for the toExclusive record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LineRange(int fromInclusive, int toExclusive)
    Creates an instance of a LineRange record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    static LineRange
    FromInclToExcl(int fromInclusive, int toExclusive)
    Creates a range of line numbers including the first line number and ending at but excluding the second line number.
    static LineRange
    FromInclToIncl(int fromInclusive, int toInclusive)
    Creates a range of line numbers including the first line number and ending at and including the second line number.
    int
    Returns the value of the fromInclusive record component.
    final int
    Returns a hash code value for this object.
    static LineRange
    Creates an invalid range that does not represent a valid range of line numbers in a text file.
    static LineRange
    SingleLine(int lineNo)
    Creates a range that covers only a single line.
    int
    Returns the value of the toExclusive record component.
    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

    • fromInclusive

      private final int fromInclusive
      The field for the fromInclusive record component.
    • toExclusive

      private final int toExclusive
      The field for the toExclusive record component.
  • Constructor Details

    • LineRange

      public LineRange(int fromInclusive, int toExclusive)
      Creates an instance of a LineRange record class.
      Parameters:
      fromInclusive - the value for the fromInclusive record component
      toExclusive - the value for the toExclusive record component
  • Method Details

    • Invalid

      public static LineRange Invalid()
      Creates an invalid range that does not represent a valid range of line numbers in a text file.
    • SingleLine

      public static LineRange SingleLine(int lineNo)
      Creates a range that covers only a single line.
      Parameters:
      lineNo - The line number to range over.
    • FromInclToExcl

      public static LineRange FromInclToExcl(int fromInclusive, int toExclusive)
      Creates a range of line numbers including the first line number and ending at but excluding the second line number.
      Parameters:
      fromInclusive - Start of the range.
      toExclusive - Line number after the end of the range.
    • FromInclToIncl

      public static LineRange FromInclToIncl(int fromInclusive, int toInclusive)
      Creates a range of line numbers including the first line number and ending at and including the second line number.
      Parameters:
      fromInclusive - Start of the range.
      toInclusive - End of the range.
    • 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 '=='.
      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.
    • fromInclusive

      public int fromInclusive()
      Returns the value of the fromInclusive record component.
      Returns:
      the value of the fromInclusive record component
    • toExclusive

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