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