1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.kernel.util;
24  
25  import java.io.Serializable;
26  
27  /**
28   * <a href="KeyValuePair.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class KeyValuePair implements Comparable<KeyValuePair>, Serializable {
33  
34      public KeyValuePair() {
35          this(null, null);
36      }
37  
38      public KeyValuePair(String key, String value) {
39          _key = key;
40          _value = value;
41      }
42  
43      public String getKey() {
44          return _key;
45      }
46  
47      public void setKey(String key) {
48          _key = key;
49      }
50  
51      public String getValue() {
52          return _value;
53      }
54  
55      public void setValue(String value) {
56          _value = value;
57      }
58  
59      public int compareTo(KeyValuePair kvp) {
60          return _key.compareTo(kvp.getKey());
61      }
62  
63      public boolean equals(Object obj) {
64          if (obj == null) {
65              return false;
66          }
67  
68          KeyValuePair kvp = (KeyValuePair)obj;
69  
70          String key = kvp.getKey();
71  
72          if (_key.equals(key)) {
73              return true;
74          }
75          else {
76              return false;
77          }
78      }
79  
80      private String _key;
81      private String _value;
82  
83  }