blob: be5e88c43cb0d11255b804c39aaf584fc7239970 [file] [log] [blame]
/*
*******************************************************************************
* Copyright (C) 2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package com.ibm.icu.dev.test.util;
import java.util.Map;
/**
* @author markdavis
*
*/
public class ImmutableEntry<K,V> implements Map.Entry<K,V> {
final K k;
final V v;
ImmutableEntry(K key, V value) {
k = key;
v = value;
}
public K getKey() {return k;}
public V getValue() {return v;}
public V setValue(V value) {
throw new UnsupportedOperationException();
}
public boolean equals(Object o) {
try {
Map.Entry e = (Map.Entry)o;
return UnicodeMap.areEqual(e.getKey(), k) && UnicodeMap.areEqual(e.getValue(), v);
} catch (ClassCastException e) {
return false;
}
}
public int hashCode() {
return ((k==null ? 0 : k.hashCode()) ^ (v==null ? 0 : v.hashCode()));
}
public String toString() {
return k+"="+v;
}
}