1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()
76 .append(getKey())
77 .append('=')
78 .append(getValue())
79 .toString();
80 }
81
82 }