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
FieldsModifier and TypeFieldDescriptionprivate final intThe field for thefromInclusiverecord component.private final intThe field for thetoExclusiverecord component. -
Constructor Summary
ConstructorsConstructorDescriptionLineRange(int fromInclusive, int toExclusive) Creates an instance of aLineRangerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static LineRangeFromInclToExcl(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 LineRangeFromInclToIncl(int fromInclusive, int toInclusive) Creates a range of line numbers including the first line number and ending at and including the second line number.intReturns the value of thefromInclusiverecord component.final inthashCode()Returns a hash code value for this object.static LineRangeInvalid()Creates an invalid range that does not represent a valid range of line numbers in a text file.static LineRangeSingleLine(int lineNo) Creates a range that covers only a single line.intReturns the value of thetoExclusiverecord component.toString()Returns a string representation of this record class.
-
Field Details
-
fromInclusive
private final int fromInclusiveThe field for thefromInclusiverecord component. -
toExclusive
private final int toExclusiveThe field for thetoExclusiverecord component.
-
-
Constructor Details
-
LineRange
public LineRange(int fromInclusive, int toExclusive) Creates an instance of aLineRangerecord class.- Parameters:
fromInclusive- the value for thefromInclusiverecord componenttoExclusive- the value for thetoExclusiverecord 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 thefromInclusiverecord component.- Returns:
- the value of the
fromInclusiverecord component
-
toExclusive
public int toExclusive()Returns the value of thetoExclusiverecord component.- Returns:
- the value of the
toExclusiverecord component
-