1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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      private String _key;
73      private String _value;
74  
75  }