KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mchange > v1 > util > AbstractMapEntry


1 /*
2  * Distributed as part of c3p0 v.0.9.1
3  *
4  * Copyright (C) 2005 Machinery For Change, Inc.
5  *
6  * Author: Steve Waldman <swaldman@mchange.com>
7  *
8  * This library is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License version 2.1, as
10  * published by the Free Software Foundation.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this software; see the file LICENSE. If not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */

22
23
24 package com.mchange.v1.util;
25
26 import java.util.Map JavaDoc;
27 import com.mchange.v2.lang.ObjectUtils;
28
29 public abstract class AbstractMapEntry implements Map.Entry JavaDoc
30 {
31     public abstract Object JavaDoc getKey();
32
33     public abstract Object JavaDoc getValue();
34
35     public abstract Object JavaDoc setValue(Object JavaDoc value);
36
37     public boolean equals(Object JavaDoc o)
38     {
39     if (o instanceof Map.Entry JavaDoc)
40         {
41         Map.Entry JavaDoc other = (Map.Entry JavaDoc) o;
42         return
43             ObjectUtils.eqOrBothNull( this.getKey(), other.getKey() ) &&
44             ObjectUtils.eqOrBothNull( this.getValue(), other.getValue() );
45         }
46     else
47         return false;
48     }
49
50     public int hashCode()
51     {
52     return
53         (this.getKey() == null ? 0 : this.getKey().hashCode()) ^
54         (this.getValue() == null ? 0 : this.getValue().hashCode());
55     }
56 }
57
Popular Tags