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.Collections; |
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.XmlElement; |
27 | |
import javax.xml.bind.annotation.XmlElementWrapper; |
28 | |
import javax.xml.bind.annotation.XmlType; |
29 | |
|
30 | |
import org.kuali.student.common.infc.Comparison; |
31 | |
import org.kuali.student.common.infc.Criteria; |
32 | |
import org.kuali.student.common.infc.ModelBuilder; |
33 | |
import org.w3c.dom.Element; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
@XmlAccessorType(XmlAccessType.FIELD) |
44 | |
@XmlType(name = "CriteriaInfo", propOrder = {"comparisons", "maxResults", "_futureElements"}) |
45 | 0 | public class CriteriaInfo implements Criteria, Serializable { |
46 | |
|
47 | |
private static final long serialVersionUID = 1L; |
48 | |
|
49 | |
@XmlElementWrapper(name="comparisons") |
50 | |
@XmlElement(name="comparison") |
51 | |
private final List<ComparisonInfo> comparisons; |
52 | |
@XmlElement |
53 | |
private final Integer maxResults; |
54 | |
@XmlAnyElement |
55 | |
private final List<Element> _futureElements; |
56 | |
|
57 | 0 | private CriteriaInfo() { |
58 | 0 | comparisons = null; |
59 | 0 | maxResults = null; |
60 | 0 | _futureElements = null; |
61 | 0 | } |
62 | |
|
63 | |
@Override |
64 | |
public List<ComparisonInfo> getComparisons() { |
65 | 0 | return this.comparisons; |
66 | |
} |
67 | |
|
68 | |
@Override |
69 | |
public Integer getMaxResults() { |
70 | 0 | return this.maxResults; |
71 | |
} |
72 | |
|
73 | 0 | private CriteriaInfo(Criteria builder) { |
74 | 0 | if (builder.getComparisons() == null) { |
75 | 0 | this.comparisons = null; |
76 | |
} else { |
77 | 0 | List<ComparisonInfo> list = new ArrayList(builder.getComparisons().size()); |
78 | 0 | for (Comparison infc : builder.getComparisons()) { |
79 | 0 | list.add(new ComparisonInfo.Builder(infc).build()); |
80 | |
} |
81 | 0 | this.comparisons = Collections.unmodifiableList(list); |
82 | |
} |
83 | 0 | this.maxResults = builder.getMaxResults(); |
84 | 0 | this._futureElements = null; |
85 | 0 | } |
86 | |
|
87 | 0 | public static class Builder implements ModelBuilder<CriteriaInfo>, Criteria { |
88 | |
|
89 | |
private List<? extends Comparison> comparisons; |
90 | |
private Integer maxResults; |
91 | |
|
92 | 0 | public Builder() { |
93 | 0 | } |
94 | |
|
95 | 0 | public Builder(Criteria info) { |
96 | 0 | this.comparisons = info.getComparisons(); |
97 | 0 | this.maxResults = info.getMaxResults(); |
98 | 0 | } |
99 | |
|
100 | |
public CriteriaInfo build() { |
101 | 0 | return new CriteriaInfo(this); |
102 | |
} |
103 | |
|
104 | |
@Override |
105 | |
public List<? extends Comparison> getComparisons() { |
106 | 0 | return this.comparisons; |
107 | |
} |
108 | |
|
109 | |
@Override |
110 | |
public Integer getMaxResults() { |
111 | 0 | return this.maxResults; |
112 | |
} |
113 | |
|
114 | |
public void setComparisons(List<? extends Comparison> comparisons) { |
115 | 0 | this.comparisons = comparisons; |
116 | 0 | } |
117 | |
|
118 | |
public void setMaxResults(Integer maxResults) { |
119 | 0 | this.maxResults = maxResults; |
120 | 0 | } |
121 | |
} |
122 | |
} |