Allocation.java
package ch.hslu.exercises.sw02.ex2;
import java.util.Objects;
public final class Allocation implements Comparable<Allocation> {
private final long size;
private final long startingAddress;
@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);
}
public Allocation(final long size, final long startingAddress) {
this.size = size;
this.startingAddress = startingAddress;
}
public long getStartingAddress() {
return startingAddress;
}
public long getSize() {
return size;
}
@Override
public int compareTo(final Allocation o) {
return Long.compare(this.startingAddress, o.getStartingAddress());
}
}