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 | 0 | @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 | 0 | @SuppressWarnings("unused") |
51 | |
@XmlAnyElement |
52 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | 0 | protected BaseAttribute() { |
59 | 0 | this.id = null; |
60 | 0 | this.attributeDefinitionId = null; |
61 | 0 | this.value = null; |
62 | 0 | this.attributeDefinition = null; |
63 | 0 | } |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | 0 | protected BaseAttribute(Builder builder) { |
72 | 0 | this.id = builder.getId(); |
73 | 0 | this.attributeDefinitionId = builder.getAttributeDefinitionId(); |
74 | 0 | this.value = builder.getValue(); |
75 | 0 | if (builder.getAttributeDefinition() != null) { |
76 | 0 | this.attributeDefinition = builder.getAttributeDefinition().build(); |
77 | |
} else { |
78 | 0 | this.attributeDefinition = null; |
79 | |
} |
80 | 0 | } |
81 | |
|
82 | |
@Override |
83 | |
public String getId() { |
84 | 0 | return this.id; |
85 | |
} |
86 | |
|
87 | |
@Override |
88 | |
public String getAttributeDefinitionId() { |
89 | 0 | return this.attributeDefinitionId; |
90 | |
} |
91 | |
|
92 | |
@Override |
93 | |
public String getValue() { |
94 | 0 | return this.value; |
95 | |
} |
96 | |
|
97 | |
@Override |
98 | |
public KrmsAttributeDefinition getAttributeDefinition() { |
99 | 0 | return this.attributeDefinition; |
100 | |
} |
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | 0 | 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 | 0 | protected Builder(String id, String attributeDefinitionId, String value) { |
118 | 0 | setId(id); |
119 | 0 | setAttributeDefinitionId(attributeDefinitionId); |
120 | 0 | setValue(value); |
121 | 0 | } |
122 | |
|
123 | |
protected Builder(BaseAttributeContract attr) { |
124 | 0 | this (attr.getId(), attr.getAttributeDefinitionId(), attr.getValue()); |
125 | 0 | } |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
public void setId(String id) { |
134 | |
|
135 | |
|
136 | |
|
137 | 0 | this.id = id; |
138 | 0 | } |
139 | |
|
140 | |
public void setAttributeDefinitionId(String attributeDefinitionId) { |
141 | 0 | if (StringUtils.isBlank(attributeDefinitionId)) { |
142 | 0 | throw new IllegalArgumentException("the attribute definition id is blank"); |
143 | |
} |
144 | 0 | this.attributeDefinitionId = attributeDefinitionId; |
145 | 0 | } |
146 | |
|
147 | |
public void setValue(String value) { |
148 | 0 | this.value = value; |
149 | 0 | } |
150 | |
|
151 | |
public void setAttributeDefinition(KrmsAttributeDefinition.Builder attributeDefinition) { |
152 | 0 | this.attributeDefinition = attributeDefinition; |
153 | 0 | } |
154 | |
|
155 | |
@Override |
156 | |
public String getId() { |
157 | 0 | return id; |
158 | |
} |
159 | |
|
160 | |
@Override |
161 | |
public String getAttributeDefinitionId() { |
162 | 0 | return attributeDefinitionId; |
163 | |
} |
164 | |
|
165 | |
@Override |
166 | |
public String getValue() { |
167 | 0 | return value; |
168 | |
} |
169 | |
|
170 | |
@Override |
171 | |
public KrmsAttributeDefinition.Builder getAttributeDefinition() { |
172 | 0 | return attributeDefinition; |
173 | |
} |
174 | |
|
175 | |
} |
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | 0 | 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 | |
} |