1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.api.repository.agenda;
17
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.Collection;
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.XmlElements;
29 import javax.xml.bind.annotation.XmlRootElement;
30 import javax.xml.bind.annotation.XmlType;
31
32 import org.apache.commons.lang.StringUtils;
33 import org.kuali.rice.core.api.CoreConstants;
34 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
35 import org.kuali.rice.core.api.mo.ModelBuilder;
36
37
38
39
40
41
42
43
44
45
46 @XmlRootElement(name = AgendaTreeDefinition.Constants.ROOT_ELEMENT_NAME)
47 @XmlAccessorType(XmlAccessType.NONE)
48 @XmlType(name = AgendaTreeDefinition.Constants.TYPE_NAME, propOrder = {
49 AgendaTreeDefinition.Elements.AGENDA_ID,
50 AgendaTreeDefinition.Elements.ENTRIES,
51 CoreConstants.CommonElements.FUTURE_ELEMENTS
52 })
53 public final class AgendaTreeDefinition extends AbstractDataTransferObject {
54
55 private static final long serialVersionUID = 3355519740298280591L;
56
57 @XmlElement(name = Elements.AGENDA_ID, required = false)
58 private final String agendaId;
59
60 @XmlElements(value = {
61 @XmlElement(name = Elements.RULE, type = AgendaTreeRuleEntry.class, required = false),
62 @XmlElement(name = Elements.SUB_AGENDA, type = AgendaTreeSubAgendaEntry.class, required = false)
63 })
64 private final List<AgendaTreeEntryDefinitionContract> entries;
65
66 @SuppressWarnings("unused")
67 @XmlAnyElement
68 private final Collection<org.w3c.dom.Element> _futureElements = null;
69
70
71
72
73
74 private AgendaTreeDefinition() {
75 this.agendaId = null;
76 this.entries = null;
77 }
78
79
80
81
82
83
84
85 private AgendaTreeDefinition(Builder builder) {
86 this.agendaId = builder.getAgendaId();
87 this.entries = builder.getEntries();
88 }
89
90
91
92
93
94 public String getAgendaId() {
95 return agendaId;
96 }
97
98
99
100
101
102 public List<AgendaTreeEntryDefinitionContract> getEntries() {
103 if (entries == null){
104 return Collections.emptyList();
105 }
106 return Collections.unmodifiableList(entries);
107 }
108
109
110
111
112
113 public static class Builder implements ModelBuilder, Serializable {
114
115 private static final long serialVersionUID = 7981215392039022620L;
116
117 private String agendaId;
118 private List<AgendaTreeEntryDefinitionContract> entries;
119
120
121
122
123 private Builder() {
124 this.entries = new ArrayList<AgendaTreeEntryDefinitionContract>();
125 }
126
127
128
129
130
131 public static Builder create(){
132 return new Builder();
133 }
134
135
136
137
138
139
140 public void setAgendaId(String agendaId) {
141 if (StringUtils.isBlank(agendaId)) {
142 throw new IllegalArgumentException("agendaItemId was null or blank");
143 }
144 this.agendaId = agendaId;
145 }
146
147
148
149
150
151
152 public void addRuleEntry(AgendaTreeRuleEntry ruleEntry) {
153 if (ruleEntry == null) {
154 throw new IllegalArgumentException("ruleEntry was null");
155 }
156 entries.add(ruleEntry);
157 }
158
159
160
161
162
163
164 public void addSubAgendaEntry(AgendaTreeSubAgendaEntry subAgendaEntry) {
165 if (subAgendaEntry == null) {
166 throw new IllegalArgumentException("subAgendaEntry was null");
167 }
168 entries.add(subAgendaEntry);
169 }
170
171
172
173
174
175 public String getAgendaId() {
176 return this.agendaId;
177 }
178
179
180
181
182
183 public List<AgendaTreeEntryDefinitionContract> getEntries() {
184 return this.entries;
185 }
186
187 @Override
188 public AgendaTreeDefinition build() {
189 return new AgendaTreeDefinition(this);
190 }
191
192 }
193
194
195
196
197 static class Constants {
198 final static String ROOT_ELEMENT_NAME = "agendaTreeDefinition";
199 final static String TYPE_NAME = "AgendaTreeDefinition";
200 }
201
202
203
204
205
206 static class Elements {
207 final static String AGENDA_ID = "agendaId";
208 final static String ENTRIES = "entries";
209 final static String RULE = "rule";
210 final static String SUB_AGENDA = "subAgenda";
211 }
212
213 }