Record Class LineNumberRange

java.lang.Object
java.lang.Record
com.atlassian.bitbucket.comment.LineNumberRange
Record Components:
maximum - The inclusive upper bound of the line number range
minimum - The inclusive lower bound of the line number range

public record LineNumberRange(int minimum, int maximum) extends Record
A data object to represent a line number range across a git diff.
Since:
9.3
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    LineNumberRange(int minimum, int maximum)
    Creates a new line number range
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(int lineNumber)
    Determines whether the provided line number falls within the range
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
     
    int
    Returns the value of the maximum record component.
    int
    Returns the value of the minimum record component.
    boolean
    Determines whether the provided line number range overlaps (shares line numbers in common) with this range
    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
  • Constructor Details

    • LineNumberRange

      public LineNumberRange(int minimum, int maximum)
      Creates a new line number range
      Parameters:
      minimum - the inclusive upper bound of the line number range
      maximum - the inclusive lower bound of the line number range
      Throws:
      IllegalArgumentException - if either arguments are less than 0, or if the range contains no elements
  • Method Details

    • contains

      public boolean contains(int lineNumber)
      Determines whether the provided line number falls within the range
      Parameters:
      lineNumber - a line number to check
      Returns:
      true if the line number falls within the range; false otherwise
    • isSingleLine

      public boolean isSingleLine()
      Returns:
      true if the line number range contains a single element; false otherwise
    • overlaps

      public boolean overlaps(@Nonnull LineNumberRange otherRange)
      Determines whether the provided line number range overlaps (shares line numbers in common) with this range
      Parameters:
      otherRange - the line number range to check
      Returns:
      true if any elements of the provided range are shared with this range; false otherwise
    • 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.
    • minimum

      public int minimum()
      Returns the value of the minimum record component.
      Returns:
      the value of the minimum record component
    • maximum

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