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).
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
Modifier and TypeFieldDescriptionprivate final int
The field for thefromInclusive
record component.private final int
The field for thetoExclusive
record component. -
Constructor Summary
ConstructorDescriptionLineRange
(int fromInclusive, int toExclusive) Creates an instance of aLineRange
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal 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 thefromInclusive
record component.final int
hashCode()
Returns a hash code value for this object.static LineRange
Invalid()
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 thetoExclusive
record component.toString()
Returns a string representation of this record class.
-
Field Details
-
fromInclusive
private final int fromInclusiveThe field for thefromInclusive
record component. -
toExclusive
private final int toExclusiveThe field for thetoExclusive
record component.
-
-
Constructor Details
-
LineRange
public LineRange(int fromInclusive, int toExclusive) Creates an instance of aLineRange
record class.- Parameters:
fromInclusive
- the value for thefromInclusive
record componenttoExclusive
- the value for thetoExclusive
record component
-
-
Method Details
-
Invalid
Creates an invalid range that does not represent a valid range of line numbers in a text file. -
SingleLine
Creates a range that covers only a single line.- Parameters:
lineNo
- The line number to range over.
-
FromInclToExcl
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
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
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. -
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. -
equals
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 '=='. -
fromInclusive
public int fromInclusive()Returns the value of thefromInclusive
record component.- Returns:
- the value of the
fromInclusive
record component
-
toExclusive
public int toExclusive()Returns the value of thetoExclusive
record component.- Returns:
- the value of the
toExclusive
record component
-