1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.api.notification;
17
18 import java.io.Serializable;
19 import java.util.Collection;
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlAnyElement;
23 import javax.xml.bind.annotation.XmlElement;
24 import javax.xml.bind.annotation.XmlRootElement;
25 import javax.xml.bind.annotation.XmlType;
26 import org.kuali.rice.core.api.CoreConstants;
27 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
28 import org.kuali.rice.core.api.mo.ModelBuilder;
29 import org.w3c.dom.Element;
30
31 @XmlRootElement(name = UserChannelSubscription.Constants.ROOT_ELEMENT_NAME)
32 @XmlAccessorType(XmlAccessType.NONE)
33 @XmlType(name = UserChannelSubscription.Constants.TYPE_NAME, propOrder = {
34 UserChannelSubscription.Elements.CHANNEL,
35 UserChannelSubscription.Elements.USER_ID,
36 UserChannelSubscription.Elements.ID,
37 CoreConstants.CommonElements.VERSION_NUMBER,
38 CoreConstants.CommonElements.OBJECT_ID,
39 CoreConstants.CommonElements.FUTURE_ELEMENTS
40 })
41 public final class UserChannelSubscription
42 extends AbstractDataTransferObject
43 implements UserChannelSubscriptionContract
44 {
45
46 @XmlElement(name = Elements.CHANNEL, required = false)
47 private final NotificationChannel channel;
48 @XmlElement(name = Elements.USER_ID, required = false)
49 private final String userId;
50 @XmlElement(name = Elements.ID, required = false)
51 private final Long id;
52 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
53 private final Long versionNumber;
54 @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
55 private final String objectId;
56 @SuppressWarnings("unused")
57 @XmlAnyElement
58 private final Collection<Element> _futureElements = null;
59
60
61
62
63
64 private UserChannelSubscription() {
65 this.channel = null;
66 this.userId = null;
67 this.id = null;
68 this.versionNumber = null;
69 this.objectId = null;
70 }
71
72 private UserChannelSubscription(Builder builder) {
73 this.channel = builder.getChannel() == null ? null : builder.getChannel().build();
74 this.userId = builder.getUserId();
75 this.id = builder.getId();
76 this.versionNumber = builder.getVersionNumber();
77 this.objectId = builder.getObjectId();
78 }
79
80 @Override
81 public NotificationChannel getChannel() {
82 return this.channel;
83 }
84
85 @Override
86 public String getUserId() {
87 return this.userId;
88 }
89
90 @Override
91 public Long getId() {
92 return this.id;
93 }
94
95 @Override
96 public Long getVersionNumber() {
97 return this.versionNumber;
98 }
99
100 @Override
101 public String getObjectId() {
102 return this.objectId;
103 }
104
105
106
107
108
109
110 public final static class Builder
111 implements Serializable, ModelBuilder, UserChannelSubscriptionContract
112 {
113
114 private NotificationChannel.Builder channel;
115 private String userId;
116 private Long id;
117 private Long versionNumber;
118 private String objectId;
119
120 private Builder() {
121 }
122
123 public static Builder create() {
124 return new Builder();
125 }
126
127 public static Builder create(UserChannelSubscriptionContract contract) {
128 if (contract == null) {
129 throw new IllegalArgumentException("contract was null");
130 }
131 Builder builder = create();
132 builder.setChannel(contract.getChannel() == null ? null : NotificationChannel.Builder.create(contract.getChannel()));
133 builder.setUserId(contract.getUserId());
134 builder.setId(contract.getId());
135 builder.setVersionNumber(contract.getVersionNumber());
136 builder.setObjectId(contract.getObjectId());
137 return builder;
138 }
139
140 public UserChannelSubscription build() {
141 return new UserChannelSubscription(this);
142 }
143
144 @Override
145 public NotificationChannel.Builder getChannel() {
146 return this.channel;
147 }
148
149 @Override
150 public String getUserId() {
151 return this.userId;
152 }
153
154 @Override
155 public Long getId() {
156 return this.id;
157 }
158
159 @Override
160 public Long getVersionNumber() {
161 return this.versionNumber;
162 }
163
164 @Override
165 public String getObjectId() {
166 return this.objectId;
167 }
168
169 public void setChannel(NotificationChannel.Builder channel) {
170 this.channel = channel;
171 }
172
173 public void setUserId(String userId) {
174 this.userId = userId;
175 }
176
177 public void setId(Long id) {
178 this.id = id;
179 }
180
181 public void setVersionNumber(Long versionNumber) {
182
183 this.versionNumber = versionNumber;
184 }
185
186 public void setObjectId(String objectId) {
187
188 this.objectId = objectId;
189 }
190
191 }
192
193
194
195
196
197
198 static class Constants {
199
200 final static String ROOT_ELEMENT_NAME = "userChannelSubscription";
201 final static String TYPE_NAME = "UserChannelSubscriptionType";
202
203 }
204
205
206
207
208
209
210 static class Elements {
211
212 final static String CHANNEL = "channel";
213 final static String USER_ID = "userId";
214 final static String ID = "id";
215
216 }
217
218 }