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

import net.ranides.assira.collection.maps.IntMap;
import net.ranides.assira.generic.CompareUtils;
import net.ranides.assira.generic.HashUtils;

import java.util.Map;

/**
 *
 * @param <K>
 * @param <V>
 */
public abstract class ALookupEntry<K> implements Lookup.LookupEntry<K> {

    @Override
    public Integer setValue(Integer value) {
        return setValue(value.intValue());
    }

    @Override
    public Integer getValue() {
        return getIntValue();
    }

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

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

    @Override
    public final String toString() {
        return getKey() + "=" + getIntValue();
    }
}
