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 @XmlTransient
35 public abstract class BaseAttribute extends AbstractDataTransferObject implements BaseAttributeContract {
36 private static final long serialVersionUID = -6126133049308968098L;
37
38 @XmlElement(name = Elements.ID, required=true)
39 private final String id;
40
41 @XmlElement(name = Elements.ATTR_DEFN_ID, required=false)
42 private final String attributeDefinitionId;
43
44 @XmlElement(name = Elements.VALUE, required=false)
45 private final String value;
46
47 @XmlElement(name = Elements.ATTR_DEFN, required=false)
48 private final KrmsAttributeDefinition attributeDefinition;
49
50 @SuppressWarnings("unused")
51 @XmlAnyElement
52 private final Collection<org.w3c.dom.Element> _futureElements = null;
53
54
55
56
57
58 protected BaseAttribute() {
59 this.id = null;
60 this.attributeDefinitionId = null;
61 this.value = null;
62 this.attributeDefinition = null;
63 }
64
65
66
67
68
69
70
71 protected BaseAttribute(Builder builder) {
72 this.id = builder.getId();
73 this.attributeDefinitionId = builder.getAttributeDefinitionId();
74 this.value = builder.getValue();
75 if (builder.getAttributeDefinition() != null) {
76 this.attributeDefinition = builder.getAttributeDefinition().build();
77 } else {
78 this.attributeDefinition = null;
79 }
80 }
81
82 @Override
83 public String getId() {
84 return this.id;
85 }
86
87 @Override
88 public String getAttributeDefinitionId() {
89 return this.attributeDefinitionId;
90 }
91
92 @Override
93 public String getValue() {
94 return this.value;
95 }
96
97 @Override
98 public KrmsAttributeDefinition getAttributeDefinition() {
99 return this.attributeDefinition;
100 }
101
102
103
104
105
106 public abstract static class Builder implements BaseAttributeContract, ModelBuilder, Serializable {
107 private static final long serialVersionUID = 5799994031051731535L;
108
109 private String id;
110 private String attributeDefinitionId;
111 private String value;
112 private KrmsAttributeDefinition.Builder attributeDefinition;
113
114
115
116
117 protected Builder(String id, String attributeDefinitionId, String value) {
118 setId(id);
119 setAttributeDefinitionId(attributeDefinitionId);
120 setValue(value);
121 }
122
123 protected Builder(BaseAttributeContract attr) {
124 this (attr.getId(), attr.getAttributeDefinitionId(), attr.getValue());
125 }
126
127
128
129
130
131
132
133 public void setId(String id) {
134
135
136
137 this.id = id;
138 }
139
140 public void setAttributeDefinitionId(String attributeDefinitionId) {
141 if (StringUtils.isBlank(attributeDefinitionId)) {
142 throw new IllegalArgumentException("the attribute definition id is blank");
143 }
144 this.attributeDefinitionId = attributeDefinitionId;
145 }
146
147 public void setValue(String value) {
148 this.value = value;
149 }
150
151 public void setAttributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition) {
152 this.attributeDefinition = attributeDefinition;
153 }
154
155 @Override
156 public String getId() {
157 return id;
158 }
159
160 @Override
161 public String getAttributeDefinitionId() {
162 return attributeDefinitionId;
163 }
164
165 @Override
166 public String getValue() {
167 return value;
168 }
169
170 @Override
171 public KrmsAttributeDefinition.Builder getAttributeDefinition() {
172 return attributeDefinition;
173 }
174
175 }
176
177
178
179
180
181 public static class Elements {
182 public final static String ID = "id";
183 public final static String ATTR_DEFN_ID = "attributeDefinitionId";
184 public final static String VALUE = "value";
185 public final static String ATTR_DEFN = "attributeDefinition";
186 }
187 }