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

import java.io.Serializable;
import java.util.Map;
import java.util.Map.Entry;
import net.ranides.assira.collection.lookups.Lookup.LookupEntry;
import net.ranides.assira.collection.maps.IntMap.IntEntry;

public class IntPair implements LookupEntry<Integer>, IntEntry<Integer>, Serializable {

    private static final long serialVersionUID = 2L;

    private final int key;
    
	private final int value;

    public IntPair(int key, int value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public int hashCode() {
         return key ^ value;
    }

    @Override
    public boolean equals(Object object) {
        if (object instanceof Entry) {
            Map.Entry<?,?> other = (Map.Entry<?,?>)object;
            return CompareUtils.equals(other.getKey(), key) && CompareUtils.equals(other.getValue(), value);
        }
	    return false;
    }

    @Override
    public int setValue(int value) {
        throw new UnsupportedOperationException("Immutable");
    }

    @Override
    public int getIntValue() {
        return value;
    }

    @Override
    public int getIntKey() {
        return key;
    }

}
