Record Class MemoryLayout.Range

java.lang.Object
java.lang.Record
mars.mips.hardware.MemoryLayout.Range
Record Components:
minAddress - The minimum address in the range.
maxAddress - The maximum address in the range.
Enclosing class:
MemoryLayout

public static record MemoryLayout.Range(int minAddress, int maxAddress) extends Record
Representation of an address range defined by a minimum address and a maximum address.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Range(int minAddress, int maxAddress)
    Construct a new Range given a minimum address and maximum address.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(int address)
    Determine whether a given address lies within this range.
    decode(String string)
    Decode a string representation of a range, which should be two integers separated by a comma.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxAddress record component.
    int
    Returns the value of the minAddress record component.
    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

    • Range

      public Range(int minAddress, int maxAddress)
      Construct a new Range given a minimum address and maximum address.
      Parameters:
      minAddress - The minimum address in the range.
      maxAddress - The maximum address in the range.
      Throws:
      IllegalArgumentException - Thrown if minAddress > maxAddress (using unsigned comparison).
  • Method Details

    • decode

      public static MemoryLayout.Range decode(String string) throws IllegalArgumentException
      Decode a string representation of a range, which should be two integers separated by a comma. Whitespace is ignored everywhere except within the integers themselves.
      Parameters:
      string - The string to decode.
      Returns:
      The range represented by the string.
      Throws:
      IllegalArgumentException - Thrown if the string is improperly formatted, or if minAddress > maxAddress (using unsigned comparison).
    • contains

      public boolean contains(int address)
      Determine whether a given address lies within this range.
      Parameters:
      address - The address to check.
      Returns:
      true if this range contains address, or 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.
    • minAddress

      public int minAddress()
      Returns the value of the minAddress record component.
      Returns:
      the value of the minAddress record component
    • maxAddress

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