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