View Javadoc

1   /*
2    * Copyright (C) 2004 TiongHiang Lee
3    *
4    * This library is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 2.1 of the License, or (at your option) any later version.
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this library; if not,  write to the Free Software
16   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   *
18   * Email: thlee@onemindsoft.org
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  }