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