View Javadoc
1   /*******************************************************************************
2    * Copyright 2012 Internet2
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   ******************************************************************************/
16  /**
17   * @author mchyzer $Id: NameValuePair.java,v 1.1 2009-09-09 15:10:03 mchyzer Exp $
18   */
19  package edu.internet2.middleware.grouper.grouperUi.beans;
20  
21  import java.io.Serializable;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.apache.commons.lang.builder.HashCodeBuilder;
25  
26  /**
27   * Name value pair
28   * 
29   */
30  public class NameValuePair implements Serializable {
31  
32    /**
33     * Default constructor.
34     * 
35     */
36    public NameValuePair() {
37    }
38  
39    /**
40     * Constructor.
41     * @param name1 The name.
42     * @param value1 The value.
43     */
44    public NameValuePair(String name1, String value1) {
45      this.name = name1;
46      this.value = value1;
47    }
48  
49    /**
50     * Name.
51     */
52    private String name = null;
53  
54    /**
55     * Value.
56     */
57    private String value = null;
58  
59    /**
60     * Set the name.
61     *
62     * @param name1 The new name
63     */
64    public void setName(String name1) {
65      this.name = name1;
66    }
67  
68    /**
69     * Return the name.
70     *
71     * @return String name The name
72     */
73    public String getName() {
74      return this.name;
75    }
76  
77    /**
78     * Set the value.
79     *
80     * @param value1 The new value.
81     */
82    public void setValue(String value1) {
83      this.value = value1;
84    }
85  
86    /**
87     * Return the current value.
88     *
89     * @return String value The current value.
90     */
91    public String getValue() {
92      return this.value;
93    }
94  
95    /**
96     * 
97     * @see java.lang.Object#toString()
98     */
99    @Override
100   public String toString() {
101     return this.name + ": " + this.value;
102   }
103 
104   /**
105    * 
106    * @see java.lang.Object#equals(java.lang.Object)
107    */
108   @Override
109   public boolean equals(Object another) {
110     if (another == this) {
111       return true;
112     }
113     if (!(another instanceof NameValuePair)) {
114       return false;
115     }
116     NameValuePair../../edu/internet2/middleware/grouper/grouperUi/beans/NameValuePair.html#NameValuePair">NameValuePair anotherPair = (NameValuePair) another;
117     return StringUtils.equals(this.name, anotherPair.name) && StringUtils.equals(this.value, anotherPair.value);
118   }
119 
120   /**
121    * the hashcode
122    * @return the hashcode
123    */
124   @Override
125   public int hashCode() {
126     return new HashCodeBuilder().append(this.name).append(this.value).hashCode();
127   }
128   
129 }