Allocation.java

package ch.hslu.exercises.sw02.ex2;

import java.util.Objects;

public record Allocation(long size, long startingAddress) implements Comparable<Allocation> {
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        } else if (object instanceof Allocation that) {
            return size == that.size && startingAddress == that.startingAddress;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return Objects.hash(size, startingAddress);
    }

    @Override
    public int compareTo(final Allocation o) {
        "A".compareTo("B");
        return Long.compare(this.startingAddress, o.startingAddress());
    }
}