package lc.mecha.graph;

/**
 * Implements a directed graph key which is represented by a string. This is typically used for attribute names.
 *
 * @author Alex Leigh
 * @since mk11 (ZERO CONTRAST)
 */
public class DGKeyString implements DGKey {
    private final String value;

    public DGKeyString(String value) {
        this.value = value;
    }

    @Override
    public String getPortableString() {
        return value;
    }

    @Override
    public String toString() {
        return "DGKeyString{" +
                "value='" + value + '\'' +
                '}';
    }

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

        DGKeyString that = (DGKeyString) o;

        return value != null ? value.equals(that.value) : that.value == null;
    }

    @Override
    public int hashCode() {
        return value != null ? value.hashCode() : 0;
    }
}
