View Javadoc
1   package ch.hslu.exercises.sw02.ex2;
2   
3   import java.util.Objects;
4   
5   public record Allocation(long size, long startingAddress) implements Comparable<Allocation> {
6       @Override
7       public boolean equals(final Object object) {
8           if (this == object) {
9               return true;
10          } else if (object instanceof Allocation that) {
11              return size == that.size && startingAddress == that.startingAddress;
12          } else {
13              return false;
14          }
15      }
16  
17      @Override
18      public int hashCode() {
19          return Objects.hash(size, startingAddress);
20      }
21  
22      @Override
23      public int compareTo(final Allocation o) {
24          "A".compareTo("B");
25          return Long.compare(this.startingAddress, o.startingAddress());
26      }
27  }