1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.r2.core.search.dto; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.ArrayList; |
20 | |
import java.util.Arrays; |
21 | |
import java.util.List; |
22 | |
|
23 | |
import javax.xml.bind.annotation.XmlAccessType; |
24 | |
import javax.xml.bind.annotation.XmlAccessorType; |
25 | |
import javax.xml.bind.annotation.XmlAnyElement; |
26 | |
import javax.xml.bind.annotation.XmlAttribute; |
27 | |
import javax.xml.bind.annotation.XmlElement; |
28 | |
import javax.xml.bind.annotation.XmlType; |
29 | |
|
30 | |
import org.kuali.student.r2.core.search.infc.SearchParam; |
31 | |
import org.w3c.dom.Element; |
32 | |
|
33 | |
@XmlAccessorType(XmlAccessType.FIELD) |
34 | |
@XmlType(name = "SearchParamInfo", propOrder = { |
35 | |
"key", "values", "_futureElements"}) |
36 | |
public class SearchParamInfo |
37 | |
implements SearchParam, Serializable { |
38 | |
|
39 | |
private static final long serialVersionUID = 1L; |
40 | |
@XmlAttribute |
41 | |
private String key; |
42 | |
@XmlElement |
43 | |
private List<String> values; |
44 | |
@XmlAnyElement |
45 | |
private List<Element> _futureElements; |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 0 | public SearchParamInfo() { |
51 | 0 | } |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | 0 | public SearchParamInfo(SearchParam param) { |
60 | 0 | if (param != null) { |
61 | 0 | this.key = param.getKey(); |
62 | 0 | if (param.getValues() != null) { |
63 | 0 | this.values = new ArrayList(param.getValues()); |
64 | |
} |
65 | |
} |
66 | 0 | } |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | 0 | public SearchParamInfo(String key, String value) { |
78 | 0 | this.key = key; |
79 | 0 | this.values = Arrays.asList(value); |
80 | 0 | } |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | 0 | public SearchParamInfo(String key, List<String> values) { |
90 | 0 | this.key = key; |
91 | 0 | this.values = values; |
92 | 0 | } |
93 | |
|
94 | |
@Override |
95 | |
public String getKey() { |
96 | 0 | return key; |
97 | |
} |
98 | |
|
99 | |
public void setKey(String key) { |
100 | 0 | this.key = key; |
101 | 0 | } |
102 | |
|
103 | |
@Override |
104 | |
public List<String> getValues() { |
105 | 0 | return values; |
106 | |
} |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
@Deprecated |
116 | |
public Object getValue() { |
117 | 0 | if (values == null) { |
118 | 0 | return null; |
119 | |
} |
120 | 0 | if (values.size() == 1) { |
121 | 0 | return values.get(0); |
122 | |
} |
123 | 0 | return values; |
124 | |
} |
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
@Deprecated |
134 | |
public void setValue(String value) { |
135 | 0 | this.values = Arrays.asList(value); |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
@Deprecated |
145 | |
public void setValue(List<String> values) { |
146 | 0 | this.values = values; |
147 | 0 | } |
148 | |
|
149 | |
public void setValues(List<String> values) { |
150 | 0 | this.values = values; |
151 | 0 | } |
152 | |
|
153 | |
@Override |
154 | |
public String toString() { |
155 | 0 | return "SearchParam[key=" + key + ", value=" + values + "]"; |
156 | |
} |
157 | |
|
158 | |
@Override |
159 | |
public boolean equals(Object o) { |
160 | 0 | if (this == o) { |
161 | 0 | return true; |
162 | |
} |
163 | 0 | if (o == null || getClass() != o.getClass()) { |
164 | 0 | return false; |
165 | |
} |
166 | |
|
167 | 0 | SearchParamInfo that = (SearchParamInfo) o; |
168 | |
|
169 | 0 | if (key != null ? !key.equals(that.key) : that.key != null) { |
170 | 0 | return false; |
171 | |
} |
172 | 0 | if (values != null ? !values.equals(that.values) : that.values != null) { |
173 | 0 | return false; |
174 | |
} |
175 | |
|
176 | 0 | return true; |
177 | |
} |
178 | |
|
179 | |
@Override |
180 | |
public int hashCode() { |
181 | 0 | int result = values != null ? values.hashCode() : 0; |
182 | 0 | result = 31 * result + (key != null ? key.hashCode() : 0); |
183 | 0 | return result; |
184 | |
} |
185 | |
} |