KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > keyvalue > AbstractMapEntryDecorator


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.collections.keyvalue;
17
18 import java.util.Map JavaDoc;
19
20 import org.apache.commons.collections.KeyValue;
21
22 /**
23  * Provides a base decorator that allows additional functionality to be added
24  * to a Map Entry.
25  *
26  * @since Commons Collections 3.0
27  * @version $Revision: 1.4 $ $Date: 2004/02/18 01:00:08 $
28  *
29  * @author Stephen Colebourne
30  */

31 public abstract class AbstractMapEntryDecorator implements Map.Entry JavaDoc, KeyValue {
32     
33     /** The <code>Map.Entry</code> to decorate */
34     protected final Map.Entry JavaDoc entry;
35
36     /**
37      * Constructor that wraps (not copies).
38      *
39      * @param entry the <code>Map.Entry</code> to decorate, must not be null
40      * @throws IllegalArgumentException if the collection is null
41      */

42     public AbstractMapEntryDecorator(Map.Entry JavaDoc entry) {
43         if (entry == null) {
44             throw new IllegalArgumentException JavaDoc("Map Entry must not be null");
45         }
46         this.entry = entry;
47     }
48
49     /**
50      * Gets the map being decorated.
51      *
52      * @return the decorated map
53      */

54     protected Map.Entry JavaDoc getMapEntry() {
55         return entry;
56     }
57
58     //-----------------------------------------------------------------------
59
public Object JavaDoc getKey() {
60         return entry.getKey();
61     }
62
63     public Object JavaDoc getValue() {
64         return entry.getValue();
65     }
66
67     public Object JavaDoc setValue(Object JavaDoc object) {
68         return entry.setValue(object);
69     }
70    
71     public boolean equals(Object JavaDoc object) {
72         if (object == this) {
73             return true;
74         }
75         return entry.equals(object);
76     }
77
78     public int hashCode() {
79         return entry.hashCode();
80     }
81
82     public String JavaDoc toString() {
83         return entry.toString();
84     }
85
86 }
87
Popular Tags