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