1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.kuali.rice.krms.api.repository;
21
22 import java.io.Serializable;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.List;
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.XmlRootElement;
32 import javax.xml.bind.annotation.XmlType;
33 import org.kuali.rice.core.api.CoreConstants;
34 import org.kuali.rice.core.api.mo.ModelBuilder;
35 import org.kuali.rice.krms.api.KrmsConstants;
36
37
38
39
40
41
42
43 @XmlRootElement(name = NaturalLanguageTree.Constants.ROOT_ELEMENT_NAME)
44 @XmlAccessorType(XmlAccessType.NONE)
45 @XmlType(name = NaturalLanguageTree.Constants.TYPE_NAME, propOrder = {
46 NaturalLanguageTree.Elements.NATURAL_LANGUAGE,
47 NaturalLanguageTree.Elements.CHILDREN,
48 CoreConstants.CommonElements.FUTURE_ELEMENTS
49 })
50 public class NaturalLanguageTree implements NaturalLanguageTreeContract {
51
52 private static final long serialVersionUID = 2783959459503209577L;
53 @XmlElement(name = NaturalLanguageTree.Elements.NATURAL_LANGUAGE, required = false)
54 private String naturalLanguage;
55 @XmlElement(name = NaturalLanguageTree.Elements.CHILDREN, required = false)
56 private List<NaturalLanguageTree> children;
57 @SuppressWarnings("unused")
58 @XmlAnyElement
59 private final Collection<org.w3c.dom.Element> _futureElements = null;
60
61
62
63
64
65 public NaturalLanguageTree() {
66 this.naturalLanguage = null;
67 this.children = null;
68 }
69
70 @Override
71 public String getNaturalLanguage() {
72 return naturalLanguage;
73 }
74
75 @Override
76 public List<NaturalLanguageTree> getChildren() {
77 return children;
78 }
79
80
81
82
83
84
85
86 private NaturalLanguageTree(Builder builder) {
87 this.naturalLanguage = builder.getNaturalLanguage();
88 List<NaturalLanguageTree> list = null;
89 if (builder.getChildren() != null) {
90 list = new ArrayList<NaturalLanguageTree>(builder.getChildren().size());
91 for (NaturalLanguageTreeContract nltree : builder.getChildren()) {
92 list.add(Builder.create(nltree).build());
93 }
94 this.children = Collections.unmodifiableList(list);
95 }
96 }
97
98
99
100
101
102 public static class Builder implements NaturalLanguageTreeContract, ModelBuilder, Serializable {
103
104 private static final long serialVersionUID = -8862851720709537839L;
105 private String naturalLanguage;
106 private List<? extends NaturalLanguageTreeContract> children;
107
108
109
110
111
112 private Builder() {
113 }
114
115
116
117
118
119 private Builder(String naturalLanguage, List<? extends NaturalLanguageTreeContract> children) {
120 setNaturalLanguage(naturalLanguage);
121 setChildren(children);
122 }
123
124 @Override
125 public String getNaturalLanguage() {
126 return naturalLanguage;
127 }
128
129 public void setNaturalLanguage(String naturalLanguage) {
130 this.naturalLanguage = naturalLanguage;
131 }
132
133 @Override
134 public List<? extends NaturalLanguageTreeContract> getChildren() {
135 return children;
136 }
137
138 public void setChildren(List<? extends NaturalLanguageTreeContract> children) {
139 this.children = children;
140 }
141
142
143
144
145
146
147
148
149
150
151
152 public static NaturalLanguageTree.Builder create() {
153 NaturalLanguageTree.Builder builder = new NaturalLanguageTree.Builder();
154 return builder;
155 }
156
157
158
159
160
161
162
163
164
165 public static NaturalLanguageTree.Builder create(NaturalLanguageTreeContract contract) {
166 if (contract == null) {
167 throw new IllegalArgumentException("contract is null");
168 }
169 NaturalLanguageTree.Builder builder = new NaturalLanguageTree.Builder(contract.getNaturalLanguage(), contract.getChildren());
170
171 return builder;
172 }
173
174
175
176
177
178
179
180 @Override
181 public NaturalLanguageTree build() {
182 return new NaturalLanguageTree(this);
183 }
184 }
185
186
187
188
189 public static class Constants {
190
191 final static String ROOT_ELEMENT_NAME = "naturalLanguageTree";
192 final static String TYPE_NAME = "NaturalLanguageTreeType";
193 final static String[] HASH_CODE_EQUALS_EXCLUDE = {"_futureElements"};
194 public final static String EVENT = "Event";
195 }
196
197
198
199
200
201 public static class Elements {
202
203 final static String NATURAL_LANGUAGE = "naturalLanguage";
204 final static String CHILDREN = "children";
205 }
206
207 public static class Cache {
208
209 public static final String NAME = KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0 + "/" + NaturalLanguageTree.Constants.TYPE_NAME;
210 }
211 }