blob: decc342b940bb4ce458aa8a011c0ae2f84dc9d68 [file] [log] [blame]
Shuyi Chend7955ce2013-05-22 14:51:55 -07001// GenericsNote: Converted.
2/*
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * 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 */
17package org.jivesoftware.smack.util.collections;
18
19
20/**
21 * Abstract pair class to assist with creating KeyValue and MapEntry implementations.
22 *
23 * @author James Strachan
24 * @author Michael A. Smith
25 * @author Neil O'Toole
26 * @author Matt Hall, John Watkinson, Stephen Colebourne
27 * @version $Revision: 1.1 $ $Date: 2005/10/11 17:05:32 $
28 * @since Commons Collections 3.0
29 */
30public abstract class AbstractKeyValue <K,V> implements KeyValue<K, V> {
31
32 /**
33 * The key
34 */
35 protected K key;
36 /**
37 * The value
38 */
39 protected V value;
40
41 /**
42 * Constructs a new pair with the specified key and given value.
43 *
44 * @param key the key for the entry, may be null
45 * @param value the value for the entry, may be null
46 */
47 protected AbstractKeyValue(K key, V value) {
48 super();
49 this.key = key;
50 this.value = value;
51 }
52
53 /**
54 * Gets the key from the pair.
55 *
56 * @return the key
57 */
58 public K getKey() {
59 return key;
60 }
61
62 /**
63 * Gets the value from the pair.
64 *
65 * @return the value
66 */
67 public V getValue() {
68 return value;
69 }
70
71 /**
72 * Gets a debugging String view of the pair.
73 *
74 * @return a String view of the entry
75 */
76 public String toString() {
77 return new StringBuilder().append(getKey()).append('=').append(getValue()).toString();
78 }
79
80}