/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.collection.maps;

import net.ranides.assira.generic.CompareUtils;
import net.ranides.assira.generic.HashUtils;

import java.util.Map;

/**
 *
 * @param <K>
 * @param <V>
 */
public abstract class AIntEntry<V> implements IntMap.IntEntry<V> {

    @Override
    public abstract V getValue();

    @Override
    public V setValue(V value) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Integer getKey() {
        return getIntKey();
    }


    @Override
    public final boolean equals(Object other) {
        if (!(other instanceof Map.Entry)) {
            return false;
        }
        Map.Entry<?, ?> that = (Map.Entry<?, ?>) other;
        return CompareUtils.equals(this.getIntKey(), that.getKey())
            && CompareUtils.equals(this.getValue(), that.getValue());
    }

    @Override
    public final int hashCode() {
        return getIntKey() ^ HashUtils.hash(getValue());
    }

    @Override
    public final String toString() {
        return getIntKey() + "=" + getValue();
    }
}
