1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.location.api.state;
18
19 import org.kuali.rice.core.api.CoreConstants;
20 import org.kuali.rice.core.api.criteria.QueryResults;
21 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
22 import org.kuali.rice.core.api.mo.ModelBuilder;
23 import org.kuali.rice.location.api.postalcode.PostalCode;
24 import org.w3c.dom.Element;
25
26 import javax.xml.bind.annotation.XmlAccessType;
27 import javax.xml.bind.annotation.XmlAccessorType;
28 import javax.xml.bind.annotation.XmlAnyElement;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.XmlElementWrapper;
31 import javax.xml.bind.annotation.XmlRootElement;
32 import javax.xml.bind.annotation.XmlType;
33 import java.util.ArrayList;
34 import java.util.Collection;
35 import java.util.Collections;
36 import java.util.List;
37
38
39
40
41 @XmlRootElement(name = StateQueryResults.Constants.ROOT_ELEMENT_NAME)
42 @XmlAccessorType(XmlAccessType.NONE)
43 @XmlType(name = StateQueryResults.Constants.TYPE_NAME, propOrder = {
44 StateQueryResults.Elements.RESULTS,
45 StateQueryResults.Elements.TOTAL_ROW_COUNT,
46 StateQueryResults.Elements.MORE_RESULTS_AVAILALBE,
47 CoreConstants.CommonElements.FUTURE_ELEMENTS })
48 public class StateQueryResults extends AbstractDataTransferObject implements QueryResults<State> {
49
50 @XmlElementWrapper(name = Elements.RESULTS, required = false)
51 @XmlElement(name = Elements.RESULT_ELEM, required = false)
52 private final List<State> results;
53
54 @XmlElement(name = Elements.TOTAL_ROW_COUNT, required = false)
55 private final Integer totalRowCount;
56
57 @XmlElement(name = Elements.MORE_RESULTS_AVAILALBE, required = true)
58 private final boolean moreResultsAvailable;
59
60 @SuppressWarnings("unused")
61 @XmlAnyElement
62 private final Collection<Element> _futureElements = null;
63
64 private StateQueryResults() {
65 this.results = null;
66 this.totalRowCount = null;
67 this.moreResultsAvailable = false;
68 }
69
70 private StateQueryResults(Builder builder) {
71 final List<State> temp = new ArrayList<State>();
72 for (State.Builder b : builder.getResults()) {
73 if (b != null) {
74 temp.add(b.build());
75 }
76 }
77
78 this.results = Collections.unmodifiableList(temp);
79 this.totalRowCount = builder.getTotalRowCount();
80 this.moreResultsAvailable = builder.isMoreResultsAvailable();
81 }
82
83 @Override
84 public List<State> getResults() {
85 return results;
86 }
87
88 @Override
89 public Integer getTotalRowCount() {
90 return totalRowCount;
91 }
92
93 @Override
94 public boolean isMoreResultsAvailable() {
95 return moreResultsAvailable;
96 }
97
98 public static class Builder implements ModelBuilder, QueryResults<State.Builder> {
99
100 private List<State.Builder> results;
101 private Integer totalRowCount;
102 private boolean moreResultsAvailable;
103
104 public static Builder create() {
105 return new Builder();
106 }
107
108 private Builder() {
109 this.results = new ArrayList<State.Builder>();
110 this.moreResultsAvailable = false;
111 }
112
113 @Override
114 public StateQueryResults build() {
115 return new StateQueryResults(this);
116 }
117
118 @Override
119 public List<State.Builder> getResults() {
120 return Collections.unmodifiableList(this.results);
121 }
122
123 public void setResults(List<State.Builder> results) {
124 this.results = new ArrayList<State.Builder>(results);
125 }
126
127 @Override
128 public Integer getTotalRowCount() {
129 return this.totalRowCount;
130 }
131
132 public void setTotalRowCount(Integer totalRowCount) {
133 this.totalRowCount = totalRowCount;
134 }
135
136 @Override
137 public boolean isMoreResultsAvailable() {
138 return this.moreResultsAvailable;
139 }
140
141 public void setMoreResultsAvailable(boolean moreResultsAvailable) {
142 this.moreResultsAvailable = moreResultsAvailable;
143 }
144
145 }
146
147
148
149
150 public static class Constants {
151 public final static String ROOT_ELEMENT_NAME = "StateQueryResults";
152 public final static String TYPE_NAME = "StateQueryResultsType";
153 }
154
155
156
157
158
159 public static class Elements {
160 public final static String RESULTS = "results";
161 public final static String RESULT_ELEM = "State";
162 public final static String TOTAL_ROW_COUNT = "totalRowCount";
163 public final static String MORE_RESULTS_AVAILALBE = "moreResultsAvailable";
164 }
165
166 }