1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.contract.model.test.source;
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.contract.model.test.source.Comparison;
32 import org.kuali.student.contract.model.test.source.ModelBuilder;
33 import org.w3c.dom.Element;
34
35 @XmlAccessorType(XmlAccessType.FIELD)
36 @XmlType(name = "ComparisonInfo", propOrder = {"fieldKey", "operator", "values", "ignoreCase", "_futureElements"})
37 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 private ComparisonInfo() {
57 this.fieldKey = null;
58 this.operator = null;
59 this.values = null;
60 this.ignoreCase = false;
61 this._futureElements = null;
62 }
63
64 private ComparisonInfo(Comparison bldr) {
65 this.fieldKey = bldr.getFieldKey();
66 this.operator = bldr.getOperator();
67 if (bldr.getValues() == null)
68 {
69 this.values = null;
70 }else
71 {
72 this.values = Collections.unmodifiableList(bldr.getValues());
73 }
74 this.ignoreCase = bldr.isIgnoreCase();
75 this._futureElements = null;
76 }
77
78 @Override
79 public String getFieldKey() {
80 return fieldKey;
81 }
82
83 @Override
84 public String getOperator() {
85 return operator;
86 }
87
88 @Override
89 public List<String> getValues() {
90 return values;
91 }
92
93 @Override
94 public boolean isIgnoreCase() {
95 return this.ignoreCase;
96 }
97
98 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 public Builder() {
106 }
107
108 public Builder(Comparison infc) {
109 this.fieldKey = infc.getFieldKey();
110 this.operator = infc.getOperator();
111 if (infc.getValues() != null) {
112 this.values = new ArrayList<String>(infc.getValues());
113 }
114 }
115
116 public ComparisonInfo build() {
117 return new ComparisonInfo(this);
118 }
119
120 @Override
121 public String getFieldKey() {
122 return fieldKey;
123 }
124
125 @Override
126 public String getOperator() {
127 return operator;
128 }
129
130 @Override
131 public List<String> getValues() {
132 return values;
133 }
134
135 @Override
136 public boolean isIgnoreCase() {
137 return this.ignoreCase;
138 }
139
140 public Builder setFieldKey(String fieldKey) {
141 this.fieldKey = fieldKey;
142 return this;
143 }
144
145 public Builder setOperator(String operator) {
146 this.operator = operator;
147 return this;
148 }
149
150
151
152
153
154
155 public void setValue(String value) {
156 this.setValues(Arrays.asList(value));
157 }
158
159 public void setValues(List<String> values) {
160 this.values = values;
161 }
162
163 public void setIgnoreCase(boolean ignoreCase) {
164 this.ignoreCase = ignoreCase;
165 }
166 }
167 }