01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.collections.keyvalue;
18:
19: import org.apache.commons.collections.KeyValue;
20:
21: /**
22: * Abstract pair class to assist with creating KeyValue and MapEntry implementations.
23: *
24: * @since Commons Collections 3.0
25: * @version $Revision: 438363 $ $Date: 2006-08-30 05:48:00 +0100 (Wed, 30 Aug 2006) $
26: *
27: * @author James Strachan
28: * @author Michael A. Smith
29: * @author Neil O'Toole
30: * @author Stephen Colebourne
31: */
32: public abstract class AbstractKeyValue implements KeyValue {
33:
34: /** The key */
35: protected Object key;
36: /** The value */
37: protected Object value;
38:
39: /**
40: * Constructs a new pair with the specified key and given value.
41: *
42: * @param key the key for the entry, may be null
43: * @param value the value for the entry, may be null
44: */
45: protected AbstractKeyValue(Object key, Object value) {
46: super ();
47: this .key = key;
48: this .value = value;
49: }
50:
51: /**
52: * Gets the key from the pair.
53: *
54: * @return the key
55: */
56: public Object getKey() {
57: return key;
58: }
59:
60: /**
61: * Gets the value from the pair.
62: *
63: * @return the value
64: */
65: public Object getValue() {
66: return value;
67: }
68:
69: /**
70: * Gets a debugging String view of the pair.
71: *
72: * @return a String view of the entry
73: */
74: public String toString() {
75: return new StringBuffer().append(getKey()).append('=').append(
76: getValue()).toString();
77: }
78:
79: }
|