1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.onemind.commons.java.datastructure;
22
23 import java.util.Map;
24 /***
25 * A simple Map.Entry implementation that can be used for Map extension
26 * @author TiongHiang Lee (thlee@onemindsoft.org)
27 * @version $Id: MapEntry.java,v 1.3 2005/04/26 17:41:48 thlee Exp $ $Name: $
28 */
29 public class MapEntry implements Map.Entry
30 {
31
32 /*** the key * */
33 private Object _key;
34
35 /*** the value * */
36 private Object _value;
37
38 /***
39 * {@inheritDoc}
40 */
41 public MapEntry(Object key, Object value)
42 {
43 _key = key;
44 _value = value;
45 }
46
47 /***
48 * {@inheritDoc}
49 */
50 public Object getKey()
51 {
52 return _key;
53 }
54
55 /***
56 * {@inheritDoc}
57 */
58 public Object getValue()
59 {
60 return _value;
61 }
62
63 /***
64 * {@inheritDoc}
65 */
66 public Object setValue(Object value)
67 {
68 Object o = _value;
69 _value = value;
70 return o;
71 }
72
73 /***
74 * {@inheritDoc}
75 */
76 public int hashCode()
77 {
78 return _key.hashCode();
79 }
80
81 /***
82 * {@inheritDoc}
83 */
84 public boolean equals(Object o)
85 {
86 return _key.equals(((MapEntry) o)._key);
87 }
88 }