1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.api.repository;
17
18 import java.io.Serializable;
19 import java.util.Collection;
20
21 import javax.xml.bind.annotation.XmlAnyElement;
22 import javax.xml.bind.annotation.XmlElement;
23 import javax.xml.bind.annotation.XmlTransient;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
27 import org.kuali.rice.core.api.mo.ModelBuilder;
28 import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition;
29
30
31
32
33
34
35 @XmlTransient
36 public abstract class BaseAttribute extends AbstractDataTransferObject implements BaseAttributeContract {
37 private static final long serialVersionUID = -6126133049308968098L;
38
39 @XmlElement(name = Elements.ID, required=true)
40 private final String id;
41
42 @XmlElement(name = Elements.ATTR_DEFN_ID, required=false)
43 private final String attributeDefinitionId;
44
45 @XmlElement(name = Elements.VALUE, required=false)
46 private final String value;
47
48 @XmlElement(name = Elements.ATTR_DEFN, required=false)
49 private final KrmsAttributeDefinition attributeDefinition;
50
51 @SuppressWarnings("unused")
52 @XmlAnyElement
53 private final Collection<org.w3c.dom.Element> _futureElements = null;
54
55
56
57
58
59 protected BaseAttribute() {
60 this.id = null;
61 this.attributeDefinitionId = null;
62 this.value = null;
63 this.attributeDefinition = null;
64 }
65
66
67
68
69
70
71
72 protected BaseAttribute(Builder builder) {
73 this.id = builder.getId();
74 this.attributeDefinitionId = builder.getAttributeDefinitionId();
75 this.value = builder.getValue();
76 if (builder.getAttributeDefinition() != null) {
77 this.attributeDefinition = builder.getAttributeDefinition().build();
78 } else {
79 this.attributeDefinition = null;
80 }
81 }
82
83 @Override
84 public String getId() {
85 return this.id;
86 }
87
88 @Override
89 public String getAttributeDefinitionId() {
90 return this.attributeDefinitionId;
91 }
92
93 @Override
94 public String getValue() {
95 return this.value;
96 }
97
98 @Override
99 public KrmsAttributeDefinition getAttributeDefinition() {
100 return this.attributeDefinition;
101 }
102
103
104
105
106
107 public abstract static class Builder implements BaseAttributeContract, ModelBuilder, Serializable {
108 private static final long serialVersionUID = 5799994031051731535L;
109
110 private String id;
111 private String attributeDefinitionId;
112 private String value;
113 private KrmsAttributeDefinition.Builder attributeDefinition;
114
115
116
117
118 protected Builder(String id, String attributeDefinitionId, String value) {
119 setId(id);
120 setAttributeDefinitionId(attributeDefinitionId);
121 setValue(value);
122 }
123
124 protected Builder(BaseAttributeContract attr) {
125 this (attr.getId(), attr.getAttributeDefinitionId(), attr.getValue());
126 }
127
128
129
130
131
132
133
134 public void setId(String id) {
135
136
137
138 this.id = id;
139 }
140
141
142
143
144
145
146 public void setAttributeDefinitionId(String attributeDefinitionId) {
147 if (StringUtils.isBlank(attributeDefinitionId)) {
148 throw new IllegalArgumentException("the attribute definition id is blank");
149 }
150 this.attributeDefinitionId = attributeDefinitionId;
151 }
152
153
154
155
156
157 public void setValue(String value) {
158 this.value = value;
159 }
160
161
162
163
164
165 public void setAttributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition) {
166 this.attributeDefinition = attributeDefinition;
167 }
168
169 @Override
170 public String getId() {
171 return id;
172 }
173
174 @Override
175 public String getAttributeDefinitionId() {
176 return attributeDefinitionId;
177 }
178
179 @Override
180 public String getValue() {
181 return value;
182 }
183
184 @Override
185 public KrmsAttributeDefinition.Builder getAttributeDefinition() {
186 return attributeDefinition;
187 }
188
189 }
190
191
192
193
194
195 public static class Elements {
196 public final static String ID = "id";
197 public final static String ATTR_DEFN_ID = "attributeDefinitionId";
198 public final static String VALUE = "value";
199 public final static String ATTR_DEFN = "attributeDefinition";
200 }
201 }