1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.common.dto; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.ArrayList; |
20 | |
import java.util.Arrays; |
21 | |
import java.util.Collections; |
22 | |
import java.util.List; |
23 | |
|
24 | |
import javax.xml.bind.annotation.XmlAccessType; |
25 | |
import javax.xml.bind.annotation.XmlAccessorType; |
26 | |
import javax.xml.bind.annotation.XmlAnyElement; |
27 | |
import javax.xml.bind.annotation.XmlElement; |
28 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
29 | |
import javax.xml.bind.annotation.XmlType; |
30 | |
|
31 | |
import org.kuali.student.common.infc.Comparison; |
32 | |
import org.kuali.student.common.infc.ModelBuilder; |
33 | |
import org.w3c.dom.Element; |
34 | |
|
35 | |
@XmlAccessorType(XmlAccessType.FIELD) |
36 | |
@XmlType(name = "ComparisonInfo", propOrder = {"fieldKey", "operator", "values", "ignoreCase", "_futureElements"}) |
37 | 0 | public class ComparisonInfo implements Comparison, Serializable { |
38 | |
|
39 | |
private static final long serialVersionUID = 1L; |
40 | |
@XmlElement |
41 | |
private final String fieldKey; |
42 | |
|
43 | |
@XmlElement |
44 | |
private final String operator; |
45 | |
|
46 | |
@XmlElementWrapper(name="values") |
47 | |
@XmlElement(name="value") |
48 | |
private final List<String> values; |
49 | |
|
50 | |
@XmlElement |
51 | |
private final boolean ignoreCase; |
52 | |
|
53 | |
@XmlAnyElement |
54 | |
private final List<Element> _futureElements; |
55 | |
|
56 | 0 | private ComparisonInfo() { |
57 | 0 | this.fieldKey = null; |
58 | 0 | this.operator = null; |
59 | 0 | this.values = null; |
60 | 0 | this.ignoreCase = false; |
61 | 0 | this._futureElements = null; |
62 | 0 | } |
63 | |
|
64 | 0 | private ComparisonInfo(Comparison bldr) { |
65 | 0 | this.fieldKey = bldr.getFieldKey(); |
66 | 0 | this.operator = bldr.getOperator(); |
67 | 0 | if (bldr.getValues() == null) |
68 | |
{ |
69 | 0 | this.values = null; |
70 | |
}else |
71 | |
{ |
72 | 0 | this.values = Collections.unmodifiableList(bldr.getValues()); |
73 | |
} |
74 | 0 | this.ignoreCase = bldr.isIgnoreCase(); |
75 | 0 | this._futureElements = null; |
76 | 0 | } |
77 | |
|
78 | |
@Override |
79 | |
public String getFieldKey() { |
80 | 0 | return fieldKey; |
81 | |
} |
82 | |
|
83 | |
@Override |
84 | |
public String getOperator() { |
85 | 0 | return operator; |
86 | |
} |
87 | |
|
88 | |
@Override |
89 | |
public List<String> getValues() { |
90 | 0 | return values; |
91 | |
} |
92 | |
|
93 | |
@Override |
94 | |
public boolean isIgnoreCase() { |
95 | 0 | return this.ignoreCase; |
96 | |
} |
97 | |
|
98 | 0 | public static class Builder implements ModelBuilder<ComparisonInfo>, Comparison { |
99 | |
|
100 | |
private String fieldKey; |
101 | |
private String operator; |
102 | |
private List<String> values; |
103 | |
private boolean ignoreCase; |
104 | |
|
105 | 0 | public Builder() { |
106 | 0 | } |
107 | |
|
108 | 0 | public Builder(Comparison infc) { |
109 | 0 | this.fieldKey = infc.getFieldKey(); |
110 | 0 | this.operator = infc.getOperator(); |
111 | 0 | if (infc.getValues() != null) { |
112 | 0 | this.values = new ArrayList<String>(infc.getValues()); |
113 | |
} |
114 | 0 | } |
115 | |
|
116 | |
public ComparisonInfo build() { |
117 | 0 | return new ComparisonInfo(this); |
118 | |
} |
119 | |
|
120 | |
@Override |
121 | |
public String getFieldKey() { |
122 | 0 | return fieldKey; |
123 | |
} |
124 | |
|
125 | |
@Override |
126 | |
public String getOperator() { |
127 | 0 | return operator; |
128 | |
} |
129 | |
|
130 | |
@Override |
131 | |
public List<String> getValues() { |
132 | 0 | return values; |
133 | |
} |
134 | |
|
135 | |
@Override |
136 | |
public boolean isIgnoreCase() { |
137 | 0 | return this.ignoreCase; |
138 | |
} |
139 | |
|
140 | |
public Builder setFieldKey(String fieldKey) { |
141 | 0 | this.fieldKey = fieldKey; |
142 | 0 | return this; |
143 | |
} |
144 | |
|
145 | |
public Builder setOperator(String operator) { |
146 | 0 | this.operator = operator; |
147 | 0 | return this; |
148 | |
} |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
public void setValue(String value) { |
156 | 0 | this.setValues(Arrays.asList(value)); |
157 | 0 | } |
158 | |
|
159 | |
public void setValues(List<String> values) { |
160 | 0 | this.values = values; |
161 | 0 | } |
162 | |
|
163 | |
public void setIgnoreCase(boolean ignoreCase) { |
164 | 0 | this.ignoreCase = ignoreCase; |
165 | 0 | } |
166 | |
} |
167 | |
} |