package lc.mecha.graph;

/**
 * Storage for a directed graph key containing a numerical index. This is typically used for array values.
 *
 * @author Alex Leigh
 * @since mk11 (ZERO CONTRAST)
 */
public class DGKeyIndex implements DGKey {
    private final int idx;

    public DGKeyIndex(int idx) {
        this.idx = idx;
    }

    @Override
    public String getPortableString() {
        return Integer.toString(idx);
    }

    @Override
    public String toString() {
        return "DGKeyIndex{" +
                "idx=" + idx +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        DGKeyIndex that = (DGKeyIndex) o;

        return idx == that.idx;
    }

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