1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.api.document.attribute;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.CoreConstants;
20 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
21 import org.kuali.rice.core.api.mo.ModelBuilder;
22 import org.w3c.dom.Element;
23
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlAnyElement;
27 import javax.xml.bind.annotation.XmlElement;
28 import javax.xml.bind.annotation.XmlSeeAlso;
29 import javax.xml.bind.annotation.XmlType;
30 import java.io.Serializable;
31 import java.util.Collection;
32
33
34
35
36
37
38
39
40
41
42
43 @XmlAccessorType(XmlAccessType.NONE)
44 @XmlType(name = DocumentAttribute.Constants.TYPE_NAME, propOrder = {
45 DocumentAttribute.Elements.NAME,
46 CoreConstants.CommonElements.FUTURE_ELEMENTS
47 })
48 @XmlSeeAlso( { DocumentAttributeString.class, DocumentAttributeDateTime.class, DocumentAttributeInteger.class, DocumentAttributeDecimal.class } )
49 public abstract class DocumentAttribute extends AbstractDataTransferObject implements DocumentAttributeContract {
50
51 private static final long serialVersionUID = -1935235225791818090L;
52
53 @XmlElement(name = Elements.NAME, required = true)
54 private final String name;
55
56 @SuppressWarnings("unused")
57 @XmlAnyElement
58 private final Collection<Element> _futureElements = null;
59
60 protected DocumentAttribute() {
61 this.name = null;
62 }
63
64 DocumentAttribute(String name) {
65 if (StringUtils.isBlank(name)) {
66 throw new IllegalArgumentException("name was null or blank");
67 }
68 this.name = name;
69 }
70
71 @Override
72 public String getName() {
73 return name;
74 }
75
76
77
78
79
80
81
82 public abstract static class AbstractBuilder<T> implements Serializable, ModelBuilder, DocumentAttributeContract {
83
84 private static final long serialVersionUID = -4402662354421207678L;
85
86 private String name;
87 private T value;
88
89 protected AbstractBuilder(String name) {
90 setName(name);
91 }
92
93 @Override
94 public String getName() {
95 return name;
96 }
97
98
99
100
101
102
103
104 public void setName(String name) {
105 if (StringUtils.isBlank(name)) {
106 throw new IllegalArgumentException("name was null or blank");
107 }
108 this.name = name;
109 }
110
111 @Override
112 public T getValue() {
113 return value;
114 }
115
116
117
118
119
120
121 public void setValue(T value) {
122 this.value = value;
123 }
124
125
126
127
128
129
130 public abstract DocumentAttribute build();
131
132 }
133
134
135
136
137 static class Constants {
138 final static String TYPE_NAME = "DocumentAttributeType";
139 }
140
141
142
143
144 static class Elements {
145 final static String NAME = "name";
146 }
147
148 }