package ca.recrown.islandsurvivalcraft.caching;

import java.util.Objects;

public class CoordinateIdentifier extends Identifier {
    private final int x;
    private final int y;
    private final int hash;

    public CoordinateIdentifier(int x, int y) {
        this.x = x;
        this.y = y;
        hash = Objects.hash(x, y);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof CoordinateIdentifier) {
            CoordinateIdentifier other = (CoordinateIdentifier) obj;
            return x == other.x && y == other.y;
        }
        return false;
    }

    @Override
    public int hashCode() {
        return hash;
    }

    /**
     * @return the x
     */
    public int getX() {
        return x;
    }

    /**
     * @return the y
     */
    public int getY() {
        return y;
    }
}