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.common.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  
28  	private static final long serialVersionUID = 1L;
29  	@XmlElement
30  	private String value;
31  	@XmlElement
32  	private List<String> listValue;
33  	@XmlAttribute
34  	private String key;
35  
36  	public SearchParam(){
37  		super();
38  	}
39  	
40  	public SearchParam(String key, String value) {
41  		this();
42  		this.key = key;
43  		this.value = value;
44  	}
45  
46  	public SearchParam(String key, List<String> value) {
47  		this();
48  		this.key = key;
49  		this.listValue = value;
50  	}
51  
52  	
53  	public Object getValue() {
54  		if (value != null) {
55  			return value;
56  		} else {
57  			return listValue;
58  		}
59  	}
60  
61  	public void setValue(String value) {
62  		this.value = value;
63  		listValue = null;
64  	}
65  
66  	public void setValue(List<String> listValue) {
67  		this.listValue = listValue;
68  		value = null;
69  	}
70  
71  	public String getKey() {
72  		return key;
73  	}
74  
75  	public void setKey(String key) {
76  		this.key = key;
77  	}
78  
79  	@Override
80  	public String toString() {
81  		return "SearchParam[key=" + key + ", value=" + value + ", listValue="
82  				+ listValue + "]";
83  	}
84  
85      @Override
86      public boolean equals(Object o) {
87          if (this == o) return true;
88          if (o == null || getClass() != o.getClass()) return false;
89  
90          SearchParam that = (SearchParam) o;
91  
92          if (key != null ? !key.equals(that.key) : that.key != null) return false;
93          if (listValue != null ? !listValue.equals(that.listValue) : that.listValue != null) return false;
94          if (value != null ? !value.equals(that.value) : that.value != null) return false;
95  
96          return true;
97      }
98  
99      @Override
100     public int hashCode() {
101         int result = value != null ? value.hashCode() : 0;
102         result = 31 * result + (listValue != null ? listValue.hashCode() : 0);
103         result = 31 * result + (key != null ? key.hashCode() : 0);
104         return result;
105     }
106 }