Record Class Range

java.lang.Object
java.lang.Record
software.coley.sourcesolver.util.Range
Record Components:
begin - Start of range.
end - End of range.
All Implemented Interfaces:
Comparable<Range>

public record Range(int begin, int end) extends Record implements Comparable<Range>
Simple range model.
Author:
Matt Coley
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Range
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Range(int begin, int end)
    Creates an instance of a Range record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the begin record component.
    int
     
    int
    end()
    Returns the value of the end record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static Range
    extractRange(com.sun.tools.javac.tree.EndPosTable table, Tree tree)
     
    static Range
    extractRange(com.sun.tools.javac.tree.EndPosTable table, Collection<? extends Tree> trees)
     
    final int
    Returns a hash code value for this object.
    boolean
     
    boolean
    isWithin(int position)
     
    boolean
    isWithin(int position, boolean startInclusive, boolean endInclusive)
     
    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
  • Field Details

    • UNKNOWN

      public static final Range UNKNOWN
  • Constructor Details

    • Range

      public Range(int begin, int end)
      Creates an instance of a Range record class.
      Parameters:
      begin - the value for the begin record component
      end - the value for the end record component
  • Method Details

    • extractRange

      @Nonnull public static Range extractRange(@Nonnull com.sun.tools.javac.tree.EndPosTable table, @Nonnull Tree tree)
      Parameters:
      table - Table to lookup tree positions within.
      tree - Tree to calculate range of.
      Returns:
      Range covering tree.
    • extractRange

      @Nonnull public static Range extractRange(@Nonnull com.sun.tools.javac.tree.EndPosTable table, @Nonnull Collection<? extends Tree> trees)
      Parameters:
      table - Table to lookup tree positions within.
      trees - Trees to calculate range of.
      Returns:
      Range covering all trees.
    • isWithin

      public boolean isWithin(int position)
      Parameters:
      position - Position to check.
      Returns:
      true when the position is in the inclusive range.
    • isWithin

      public boolean isWithin(int position, boolean startInclusive, boolean endInclusive)
      Parameters:
      position - Position to check.
      startInclusive - true for an inclusive lower bound.
      endInclusive - true for an inclusive upper bound.
      Returns:
      true when the position is in the range.
    • isUnknown

      public boolean isUnknown()
      Returns:
      true when the range has bogus values.
    • compareTo

      public int compareTo(Range o)
      Specified by:
      compareTo in interface Comparable<Range>
    • 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.
    • begin

      public int begin()
      Returns the value of the begin record component.
      Returns:
      the value of the begin record component
    • end

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