1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.util;
16  
17  import java.io.Serializable;
18  
19  /**
20   * <a href="KeyValuePair.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Brian Wing Shun Chan
23   */
24  public class KeyValuePair implements Comparable<KeyValuePair>, Serializable {
25  
26      public KeyValuePair() {
27          this(null, null);
28      }
29  
30      public KeyValuePair(String key, String value) {
31          _key = key;
32          _value = value;
33      }
34  
35      public String getKey() {
36          return _key;
37      }
38  
39      public void setKey(String key) {
40          _key = key;
41      }
42  
43      public String getValue() {
44          return _value;
45      }
46  
47      public void setValue(String value) {
48          _value = value;
49      }
50  
51      public int compareTo(KeyValuePair kvp) {
52          return _key.compareTo(kvp.getKey());
53      }
54  
55      public boolean equals(Object obj) {
56          if (obj == null) {
57              return false;
58          }
59  
60          KeyValuePair kvp = (KeyValuePair)obj;
61  
62          String key = kvp.getKey();
63  
64          if (_key.equals(key)) {
65              return true;
66          }
67          else {
68              return false;
69          }
70      }
71  
72      public int hashCode() {
73          return _key.hashCode();
74      }
75  
76      private String _key;
77      private String _value;
78  
79  }