1 // 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html#License 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2009-2012, International Business Machines Corporation and * 6 * others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9 package com.ibm.icu.dev.util; 10 11 import java.util.Map; 12 13 /** 14 * @author markdavis 15 * 16 */ 17 public class ImmutableEntry<K,V> implements Map.Entry<K,V> { 18 final K k; 19 final V v; 20 21 ImmutableEntry(K key, V value) { 22 k = key; 23 v = value; 24 } 25 26 public K getKey() {return k;} 27 28 public V getValue() {return v;} 29 30 public V setValue(V value) { 31 throw new UnsupportedOperationException(); 32 } 33 34 public boolean equals(Object o) { 35 try { 36 Map.Entry e = (Map.Entry)o; 37 return UnicodeMap.areEqual(e.getKey(), k) && UnicodeMap.areEqual(e.getValue(), v); 38 } catch (ClassCastException e) { 39 return false; 40 } 41 } 42 43 public int hashCode() { 44 return ((k==null ? 0 : k.hashCode()) ^ (v==null ? 0 : v.hashCode())); 45 } 46 47 public String toString() { 48 return k+"="+v; 49 } 50 } 51