View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.core.search.dto;
17  
18  import java.io.Serializable;
19  import java.util.List;
20  
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlAttribute;
24  import javax.xml.bind.annotation.XmlElement;
25  @XmlAccessorType(XmlAccessType.FIELD)
26  public class SearchParam implements Serializable {
27  	private static final long serialVersionUID = 1L;
28  	@XmlElement
29  	private String value;
30  	@XmlElement
31  	private List<String> listValue;
32  	@XmlAttribute
33  	private String key;
34  
35  	public Object getValue() {
36  		if (value != null) {
37  			return value;
38  		} else {
39  			return listValue;
40  		}
41  	}
42  
43  	public void setValue(String value) {
44  		this.value = value;
45  		listValue = null;
46  	}
47  
48  	public void setValue(List<String> listValue) {
49  		this.listValue = listValue;
50  		value = null;
51  	}
52  
53  	public String getKey() {
54  		return key;
55  	}
56  
57  	public void setKey(String key) {
58  		this.key = key;
59  	}
60  
61  	@Override
62  	public String toString() {
63  		return "SearchParam[key=" + key + ", value=" + value + ", listValue="
64  				+ listValue + "]";
65  	}
66  
67      @Override
68      public boolean equals(Object o) {
69          if (this == o) return true;
70          if (o == null || getClass() != o.getClass()) return false;
71  
72          SearchParam that = (SearchParam) o;
73  
74          if (key != null ? !key.equals(that.key) : that.key != null) return false;
75          if (listValue != null ? !listValue.equals(that.listValue) : that.listValue != null) return false;
76          if (value != null ? !value.equals(that.value) : that.value != null) return false;
77  
78          return true;
79      }
80  
81      @Override
82      public int hashCode() {
83          int result = value != null ? value.hashCode() : 0;
84          result = 31 * result + (listValue != null ? listValue.hashCode() : 0);
85          result = 31 * result + (key != null ? key.hashCode() : 0);
86          return result;
87      }
88  }