1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.collections.keyvalue;
17
18 import org.apache.commons.collections.KeyValue;
19
20 /**
21 * Abstract pair class to assist with creating KeyValue and MapEntry implementations.
22 *
23 * @since Commons Collections 3.0
24 * @version $Revision: 1.1 $ $Date: 2004/05/10 19:53:54 $
25 *
26 * @author James Strachan
27 * @author Michael A. Smith
28 * @author Neil O'Toole
29 * @author Stephen Colebourne
30 */
31 public abstract class AbstractKeyValue implements KeyValue {
32
33 /** The key */
34 protected Object key;
35 /** The value */
36 protected Object value;
37
38 /**
39 * Constructs a new pair with the specified key and given value.
40 *
41 * @param key the key for the entry, may be null
42 * @param value the value for the entry, may be null
43 */
44 protected AbstractKeyValue(Object key, Object value) {
45 super();
46 this.key = key;
47 this.value = value;
48 }
49
50 /**
51 * Gets the key from the pair.
52 *
53 * @return the key
54 */
55 public Object getKey() {
56 return key;
57 }
58
59 /**
60 * Gets the value from the pair.
61 *
62 * @return the value
63 */
64 public Object getValue() {
65 return value;
66 }
67
68 /**
69 * Gets a debugging String view of the pair.
70 *
71 * @return a String view of the entry
72 */
73 public String toString() {
74 return new StringBuffer()
75 .append(getKey())
76 .append('=')
77 .append(getValue())
78 .toString();
79 }
80
81 }