]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/framework/src/com/ibm/icu/dev/util/ImmutableEntry.java
Added flags.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / framework / src / com / ibm / icu / dev / util / ImmutableEntry.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 2009-2012, International Business Machines Corporation and         *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7 package com.ibm.icu.dev.util;
8
9 import java.util.Map;
10
11 /**
12  * @author markdavis
13  *
14  */
15 public class ImmutableEntry<K,V> implements Map.Entry<K,V> {
16     final K k;
17     final V v;
18
19     ImmutableEntry(K key, V value) {
20         k = key;
21         v = value;
22     }
23
24     public K getKey()   {return k;}
25
26     public V getValue() {return v;}
27
28     public V setValue(V value) {
29         throw new UnsupportedOperationException();
30     }
31
32     public boolean equals(Object o) {
33         try {
34             Map.Entry e = (Map.Entry)o;
35             return UnicodeMap.areEqual(e.getKey(), k) && UnicodeMap.areEqual(e.getValue(), v);
36         } catch (ClassCastException e) {
37             return false;
38         }
39     }
40
41     public int hashCode() {
42         return ((k==null ? 0 : k.hashCode()) ^ (v==null ? 0 : v.hashCode()));
43     }
44
45     public String toString() {
46         return k+"="+v;
47     }
48 }