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.Collection;
20
21 import javax.xml.bind.annotation.XmlAccessType;
22 import javax.xml.bind.annotation.XmlAccessorType;
23 import javax.xml.bind.annotation.XmlAnyElement;
24 import javax.xml.bind.annotation.XmlElement;
25 import javax.xml.bind.annotation.XmlRootElement;
26 import javax.xml.bind.annotation.XmlType;
27
28 import org.apache.commons.lang.StringUtils;
29 import org.kuali.rice.core.api.CoreConstants;
30 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
31 import org.kuali.rice.core.api.mo.ModelBuilder;
32
33
34
35
36
37
38
39
40
41 @XmlRootElement(name = AgendaTreeRuleEntry.Constants.ROOT_ELEMENT_NAME)
42 @XmlAccessorType(XmlAccessType.NONE)
43 @XmlType(name = AgendaTreeRuleEntry.Constants.TYPE_NAME, propOrder = {
44 AgendaTreeRuleEntry.Elements.AGENDA_ITEM_ID,
45 AgendaTreeRuleEntry.Elements.RULE_ID,
46 AgendaTreeRuleEntry.Elements.IF_TRUE,
47 AgendaTreeRuleEntry.Elements.IF_FALSE,
48 CoreConstants.CommonElements.FUTURE_ELEMENTS
49 })
50 public final class AgendaTreeRuleEntry extends AbstractDataTransferObject implements AgendaTreeEntryDefinitionContract {
51
52 private static final long serialVersionUID = 8594116503548506936L;
53
54 @XmlElement(name = Elements.AGENDA_ITEM_ID, required = true)
55 private final String agendaItemId;
56
57 @XmlElement(name = Elements.RULE_ID, required = true)
58 private final String ruleId;
59
60 @XmlElement(name = Elements.IF_TRUE, required = false)
61 private final AgendaTreeDefinition ifTrue;
62
63 @XmlElement(name = Elements.IF_FALSE, required = false)
64 private final AgendaTreeDefinition ifFalse;
65
66 @SuppressWarnings("unused")
67 @XmlAnyElement
68 private final Collection<org.w3c.dom.Element> _futureElements = null;
69
70
71
72
73
74 private AgendaTreeRuleEntry() {
75 this.agendaItemId = null;
76 this.ruleId = null;
77 this.ifTrue = null;
78 this.ifFalse = null;
79 }
80
81
82
83
84
85
86
87 private AgendaTreeRuleEntry(Builder builder) {
88 this.agendaItemId = builder.getAgendaItemId();
89 this.ruleId = builder.getRuleId();
90 this.ifTrue = builder.getIfTrue() == null ? null : builder.getIfTrue().build();
91 this.ifFalse = builder.getIfFalse() == null ? null : builder.getIfFalse().build();
92 }
93
94 @Override
95 public String getAgendaItemId() {
96 return agendaItemId;
97 }
98
99
100
101
102
103 public String getRuleId() {
104 return this.ruleId;
105 }
106
107
108
109
110
111 public AgendaTreeDefinition getIfTrue() {
112 return this.ifTrue;
113 }
114
115
116
117
118
119 public AgendaTreeDefinition getIfFalse() {
120 return this.ifFalse;
121 }
122
123
124
125
126
127 public static class Builder implements AgendaTreeEntryDefinitionContract, Serializable {
128
129 private static final long serialVersionUID = 3548736700798501429L;
130
131 private String agendaItemId;
132 private String ruleId;
133 private AgendaTreeDefinition.Builder ifTrue;
134 private AgendaTreeDefinition.Builder ifFalse;
135
136
137
138
139
140
141
142 private Builder(String agendaItemId, String ruleId) {
143 setAgendaItemId(agendaItemId);
144 setRuleId(ruleId);
145 }
146
147
148
149
150
151
152
153
154 public static Builder create(String agendaItemId, String ruleId){
155 return new Builder(agendaItemId, ruleId);
156 }
157
158 @Override
159 public String getAgendaItemId() {
160 return this.agendaItemId;
161 }
162
163
164
165
166
167 public String getRuleId() {
168 return this.ruleId;
169 }
170
171
172
173
174
175 public AgendaTreeDefinition.Builder getIfTrue() {
176 return this.ifTrue;
177 }
178
179
180
181
182
183 public AgendaTreeDefinition.Builder getIfFalse() {
184 return this.ifFalse;
185 }
186
187
188
189
190
191
192 public void setAgendaItemId(String agendaItemId) {
193 if (StringUtils.isBlank(agendaItemId)) {
194 throw new IllegalArgumentException("agendaItemId was null or blank");
195 }
196 this.agendaItemId = agendaItemId;
197 }
198
199
200
201
202
203 public void setRuleId(String ruleId) {
204 if (StringUtils.isBlank(ruleId)) {
205 throw new IllegalArgumentException("ruleId was null or blank");
206 }
207 this.ruleId = ruleId;
208 }
209
210
211
212
213
214 public void setIfTrue(AgendaTreeDefinition.Builder ifTrue) {
215 this.ifTrue = ifTrue;
216 }
217
218
219
220
221
222 public void setIfFalse(AgendaTreeDefinition.Builder ifFalse) {
223 this.ifFalse = ifFalse;
224 }
225
226
227
228
229
230 public AgendaTreeRuleEntry build() {
231 return new AgendaTreeRuleEntry(this);
232 }
233
234 }
235
236
237
238
239 static class Constants {
240 final static String ROOT_ELEMENT_NAME = "agendaTreeRuleEntry";
241 final static String TYPE_NAME = "AgendaTreeRuleEntryType";
242 }
243
244
245
246
247
248 static class Elements {
249 final static String AGENDA_ITEM_ID = "agendaItemId";
250 final static String RULE_ID = "ruleId";
251 final static String IF_TRUE = "ifTrue";
252 final static String IF_FALSE = "ifFalse";
253 }
254
255 }