1 | |
package org.kuali.rice.ksb.api.registry; |
2 | |
|
3 | |
import java.io.Serializable; |
4 | |
import java.util.Collection; |
5 | |
|
6 | |
import javax.xml.bind.annotation.XmlAccessType; |
7 | |
import javax.xml.bind.annotation.XmlAccessorType; |
8 | |
import javax.xml.bind.annotation.XmlAnyElement; |
9 | |
import javax.xml.bind.annotation.XmlElement; |
10 | |
import javax.xml.bind.annotation.XmlRootElement; |
11 | |
import javax.xml.bind.annotation.XmlType; |
12 | |
|
13 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
14 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
15 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
16 | |
import org.kuali.rice.core.api.CoreConstants; |
17 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
18 | |
import org.kuali.rice.core.api.mo.ModelObjectComplete; |
19 | |
import org.kuali.rice.ksb.api.bus.ServiceConfiguration; |
20 | |
import org.w3c.dom.Element; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
@XmlRootElement(name = ServiceDescriptor.Constants.ROOT_ELEMENT_NAME) |
31 | |
@XmlAccessorType(XmlAccessType.NONE) |
32 | |
@XmlType(name = ServiceDescriptor.Constants.TYPE_NAME, propOrder = { |
33 | |
ServiceDescriptor.Elements.ID, |
34 | |
ServiceDescriptor.Elements.DESCRIPTOR, |
35 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
36 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
37 | |
}) |
38 | 0 | public final class ServiceDescriptor |
39 | |
implements ModelObjectComplete, ServiceDescriptorContract |
40 | |
{ |
41 | |
|
42 | |
private static final long serialVersionUID = 4555599272613878634L; |
43 | |
|
44 | |
@XmlElement(name = Elements.ID, required = false) |
45 | |
private final String id; |
46 | |
|
47 | |
@XmlElement(name = Elements.DESCRIPTOR, required = false) |
48 | |
private final String descriptor; |
49 | |
|
50 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
51 | |
private final Long versionNumber; |
52 | |
|
53 | 0 | @SuppressWarnings("unused") |
54 | |
@XmlAnyElement |
55 | |
private final Collection<Element> _futureElements = null; |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | 0 | private ServiceDescriptor() { |
62 | 0 | this.id = null; |
63 | 0 | this.descriptor = null; |
64 | 0 | this.versionNumber = null; |
65 | 0 | } |
66 | |
|
67 | 0 | private ServiceDescriptor(Builder builder) { |
68 | 0 | this.id = builder.getId(); |
69 | 0 | this.descriptor = builder.getDescriptor(); |
70 | 0 | this.versionNumber = builder.getVersionNumber(); |
71 | 0 | } |
72 | |
|
73 | |
@Override |
74 | |
public String getId() { |
75 | 0 | return this.id; |
76 | |
} |
77 | |
|
78 | |
@Override |
79 | |
public String getDescriptor() { |
80 | 0 | return this.descriptor; |
81 | |
} |
82 | |
|
83 | |
@Override |
84 | |
public Long getVersionNumber() { |
85 | 0 | return this.versionNumber; |
86 | |
} |
87 | |
|
88 | |
@Override |
89 | |
public int hashCode() { |
90 | 0 | return HashCodeBuilder.reflectionHashCode(this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
91 | |
} |
92 | |
|
93 | |
@Override |
94 | |
public boolean equals(Object object) { |
95 | 0 | return EqualsBuilder.reflectionEquals(object, this, Constants.HASH_CODE_EQUALS_EXCLUDE); |
96 | |
} |
97 | |
|
98 | |
@Override |
99 | |
public String toString() { |
100 | 0 | return ToStringBuilder.reflectionToString(this); |
101 | |
} |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | 0 | public final static class Builder |
109 | |
implements Serializable, ModelBuilder, ServiceDescriptorContract |
110 | |
{ |
111 | |
|
112 | |
private static final long serialVersionUID = 4439417051199359358L; |
113 | |
|
114 | |
private String id; |
115 | |
private String descriptor; |
116 | |
private Long versionNumber; |
117 | |
|
118 | 0 | private Builder() { |
119 | 0 | } |
120 | |
|
121 | |
public static Builder create() { |
122 | 0 | return new Builder(); |
123 | |
} |
124 | |
|
125 | |
public static Builder create(ServiceDescriptorContract contract) { |
126 | 0 | if (contract == null) { |
127 | 0 | throw new IllegalArgumentException("contract was null"); |
128 | |
} |
129 | 0 | Builder builder = create(); |
130 | 0 | builder.setId(contract.getId()); |
131 | 0 | builder.setDescriptor(contract.getDescriptor()); |
132 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
133 | 0 | return builder; |
134 | |
} |
135 | |
|
136 | |
public ServiceDescriptor build() { |
137 | 0 | return new ServiceDescriptor(this); |
138 | |
} |
139 | |
|
140 | |
@Override |
141 | |
public String getId() { |
142 | 0 | return this.id; |
143 | |
} |
144 | |
|
145 | |
@Override |
146 | |
public String getDescriptor() { |
147 | 0 | return this.descriptor; |
148 | |
} |
149 | |
|
150 | |
@Override |
151 | |
public Long getVersionNumber() { |
152 | 0 | return this.versionNumber; |
153 | |
} |
154 | |
|
155 | |
public void setId(String id) { |
156 | 0 | this.id = id; |
157 | 0 | } |
158 | |
|
159 | |
public void setDescriptor(String descriptor) { |
160 | 0 | this.descriptor = descriptor; |
161 | 0 | } |
162 | |
|
163 | |
public void setVersionNumber(Long versionNumber) { |
164 | 0 | this.versionNumber = versionNumber; |
165 | 0 | } |
166 | |
|
167 | |
} |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | 0 | static class Constants { |
175 | |
|
176 | |
final static String ROOT_ELEMENT_NAME = "serviceDescriptor"; |
177 | |
final static String TYPE_NAME = "ServiceDescriptorType"; |
178 | 0 | final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS }; |
179 | |
|
180 | |
} |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | 0 | static class Elements { |
188 | |
|
189 | |
final static String ID = "id"; |
190 | |
final static String DESCRIPTOR = "descriptor"; |
191 | |
|
192 | |
} |
193 | |
|
194 | |
} |
195 | |
|