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 | |
@XmlRootElement(name = AgendaTreeRuleEntry.Constants.ROOT_ELEMENT_NAME) |
40 | |
@XmlAccessorType(XmlAccessType.NONE) |
41 | |
@XmlType(name = AgendaTreeRuleEntry.Constants.TYPE_NAME, propOrder = { |
42 | |
AgendaTreeRuleEntry.Elements.AGENDA_ITEM_ID, |
43 | |
AgendaTreeRuleEntry.Elements.RULE_ID, |
44 | |
AgendaTreeRuleEntry.Elements.IF_TRUE, |
45 | |
AgendaTreeRuleEntry.Elements.IF_FALSE, |
46 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
47 | |
}) |
48 | 27 | public final class AgendaTreeRuleEntry extends AbstractDataTransferObject implements AgendaTreeEntryDefinition { |
49 | |
|
50 | |
private static final long serialVersionUID = 8594116503548506936L; |
51 | |
|
52 | |
@XmlElement(name = Elements.AGENDA_ITEM_ID, required = true) |
53 | |
private final String agendaItemId; |
54 | |
|
55 | |
@XmlElement(name = Elements.RULE_ID, required = true) |
56 | |
private final String ruleId; |
57 | |
|
58 | |
@XmlElement(name = Elements.IF_TRUE, required = false) |
59 | |
private final AgendaTreeDefinition ifTrue; |
60 | |
|
61 | |
@XmlElement(name = Elements.IF_FALSE, required = false) |
62 | |
private final AgendaTreeDefinition ifFalse; |
63 | |
|
64 | 76 | @SuppressWarnings("unused") |
65 | |
@XmlAnyElement |
66 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | 49 | private AgendaTreeRuleEntry() { |
72 | 49 | this.agendaItemId = null; |
73 | 49 | this.ruleId = null; |
74 | 49 | this.ifTrue = null; |
75 | 49 | this.ifFalse = null; |
76 | 49 | } |
77 | |
|
78 | 27 | private AgendaTreeRuleEntry(Builder builder) { |
79 | 27 | this.agendaItemId = builder.getAgendaItemId(); |
80 | 27 | this.ruleId = builder.getRuleId(); |
81 | 27 | this.ifTrue = builder.getIfTrue() == null ? null : builder.getIfTrue().build(); |
82 | 27 | this.ifFalse = builder.getIfFalse() == null ? null : builder.getIfFalse().build(); |
83 | 27 | } |
84 | |
|
85 | |
@Override |
86 | |
public String getAgendaItemId() { |
87 | 4 | return agendaItemId; |
88 | |
} |
89 | |
|
90 | |
public String getRuleId() { |
91 | 18 | return this.ruleId; |
92 | |
} |
93 | |
|
94 | |
public AgendaTreeDefinition getIfTrue() { |
95 | 8 | return this.ifTrue; |
96 | |
} |
97 | |
|
98 | |
public AgendaTreeDefinition getIfFalse() { |
99 | 6 | return this.ifFalse; |
100 | |
} |
101 | |
|
102 | 27 | public static class Builder implements ModelBuilder, Serializable { |
103 | |
|
104 | |
private static final long serialVersionUID = 3548736700798501429L; |
105 | |
|
106 | |
private String agendaItemId; |
107 | |
private String ruleId; |
108 | |
private AgendaTreeDefinition.Builder ifTrue; |
109 | |
private AgendaTreeDefinition.Builder ifFalse; |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | 40 | private Builder(String agendaItemId, String ruleId) { |
115 | 40 | setAgendaItemId(agendaItemId); |
116 | 36 | setRuleId(ruleId); |
117 | 33 | } |
118 | |
|
119 | |
public static Builder create(String agendaItemId, String ruleId){ |
120 | 40 | return new Builder(agendaItemId, ruleId); |
121 | |
} |
122 | |
|
123 | |
public String getAgendaItemId() { |
124 | 27 | return this.agendaItemId; |
125 | |
} |
126 | |
|
127 | |
public String getRuleId() { |
128 | 27 | return this.ruleId; |
129 | |
} |
130 | |
|
131 | |
public AgendaTreeDefinition.Builder getIfTrue() { |
132 | 32 | return this.ifTrue; |
133 | |
} |
134 | |
|
135 | |
public AgendaTreeDefinition.Builder getIfFalse() { |
136 | 32 | return this.ifFalse; |
137 | |
} |
138 | |
|
139 | |
public void setAgendaItemId(String agendaItemId) { |
140 | 40 | if (StringUtils.isBlank(agendaItemId)) { |
141 | 4 | throw new IllegalArgumentException("agendaItemId was null or blank"); |
142 | |
} |
143 | 36 | this.agendaItemId = agendaItemId; |
144 | 36 | } |
145 | |
|
146 | |
public void setRuleId(String ruleId) { |
147 | 36 | if (StringUtils.isBlank(ruleId)) { |
148 | 3 | throw new IllegalArgumentException("ruleId was null or blank"); |
149 | |
} |
150 | 33 | this.ruleId = ruleId; |
151 | 33 | } |
152 | |
|
153 | |
public void setIfTrue(AgendaTreeDefinition.Builder ifTrue) { |
154 | 8 | this.ifTrue = ifTrue; |
155 | 8 | } |
156 | |
|
157 | |
public void setIfFalse(AgendaTreeDefinition.Builder ifFalse) { |
158 | 8 | this.ifFalse = ifFalse; |
159 | 8 | } |
160 | |
|
161 | |
@Override |
162 | |
public AgendaTreeRuleEntry build() { |
163 | 27 | return new AgendaTreeRuleEntry(this); |
164 | |
} |
165 | |
|
166 | |
} |
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | 0 | static class Constants { |
172 | |
final static String ROOT_ELEMENT_NAME = "agendaTreeRuleEntry"; |
173 | |
final static String TYPE_NAME = "AgendaTreeRuleEntryType"; |
174 | |
} |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | 0 | static class Elements { |
181 | |
final static String AGENDA_ITEM_ID = "agendaItemId"; |
182 | |
final static String RULE_ID = "ruleId"; |
183 | |
final static String IF_TRUE = "ifTrue"; |
184 | |
final static String IF_FALSE = "ifFalse"; |
185 | |
} |
186 | |
|
187 | |
} |