Record Class Allocation

java.lang.Object
java.lang.Record
ch.hslu.exercises.sw02.ex2.Allocation
All Implemented Interfaces:
Comparable<Allocation>

public record Allocation(long size, long startingAddress) extends Record implements Comparable<Allocation>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocation(long size, long startingAddress)
    Creates an instance of a Allocation record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
    equals(Object object)
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    long
    Returns the value of the size record component.
    long
    Returns the value of the startingAddress 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

    • Allocation

      public Allocation(long size, long startingAddress)
      Creates an instance of a Allocation record class.
      Parameters:
      size - the value for the size record component
      startingAddress - the value for the startingAddress record component
  • Method Details

    • equals

      public boolean equals(Object object)
      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:
      object - the object with which to compare
      Returns:
      true if this object is the same as the object argument; false otherwise.
    • hashCode

      public 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
    • compareTo

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

      public long size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • startingAddress

      public long startingAddress()
      Returns the value of the startingAddress record component.
      Returns:
      the value of the startingAddress record component