View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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 = NotificationChannelReviewer.Constants.ROOT_ELEMENT_NAME)
32  @XmlAccessorType(XmlAccessType.NONE)
33  @XmlType(name = NotificationChannelReviewer.Constants.TYPE_NAME, propOrder = {
34          NotificationChannelReviewer.Elements.CHANNEL,
35          NotificationChannelReviewer.Elements.REVIEWER_TYPE,
36          NotificationChannelReviewer.Elements.REVIEWER_ID,
37          NotificationChannelReviewer.Elements.ID,
38          CoreConstants.CommonElements.VERSION_NUMBER,
39          CoreConstants.CommonElements.OBJECT_ID,
40          CoreConstants.CommonElements.FUTURE_ELEMENTS
41  })
42  public final class NotificationChannelReviewer
43          extends AbstractDataTransferObject
44          implements NotificationChannelReviewerContract
45  {
46  
47      @XmlElement(name = Elements.CHANNEL, required = false)
48      private final NotificationChannel channel;
49      @XmlElement(name = Elements.REVIEWER_TYPE, required = false)
50      private final String reviewerType;
51      @XmlElement(name = Elements.REVIEWER_ID, required = false)
52      private final String reviewerId;
53      @XmlElement(name = Elements.ID, required = false)
54      private final Long id;
55      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
56      private final Long versionNumber;
57      @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
58      private final String objectId;
59      @SuppressWarnings("unused")
60      @XmlAnyElement
61      private final Collection<Element> _futureElements = null;
62  
63      /**
64       * Private constructor used only by JAXB.
65       *
66       */
67      private NotificationChannelReviewer() {
68          this.channel = null;
69          this.reviewerType = null;
70          this.reviewerId = null;
71          this.id = null;
72          this.versionNumber = null;
73          this.objectId = null;
74      }
75  
76      private NotificationChannelReviewer(Builder builder) {
77          this.channel = builder.getChannel() != null ? builder.getChannel().build() : null;
78          this.reviewerType = builder.getReviewerType();
79          this.reviewerId = builder.getReviewerId();
80          this.id = builder.getId();
81          this.versionNumber = builder.getVersionNumber();
82          this.objectId = builder.getObjectId();
83      }
84  
85      @Override
86      public NotificationChannel getChannel() {
87          return this.channel;
88      }
89  
90      @Override
91      public String getReviewerType() {
92          return this.reviewerType;
93      }
94  
95      @Override
96      public String getReviewerId() {
97          return this.reviewerId;
98      }
99  
100     @Override
101     public Long getId() {
102         return this.id;
103     }
104 
105     @Override
106     public Long getVersionNumber() {
107         return this.versionNumber;
108     }
109 
110     @Override
111     public String getObjectId() {
112         return this.objectId;
113     }
114 
115 
116     /**
117      * A builder which can be used to construct {@link NotificationChannelReviewer} instances.  Enforces the constraints of the {@link NotificationChannelReviewerContract}.
118      *
119      */
120     public final static class Builder
121             implements Serializable, ModelBuilder, NotificationChannelReviewerContract
122     {
123 
124         private NotificationChannel.Builder channel;
125         private String reviewerType;
126         private String reviewerId;
127         private Long id;
128         private Long versionNumber;
129         private String objectId;
130 
131         private Builder() {
132         }
133 
134         public static Builder create() {
135             return new Builder();
136         }
137 
138         public static Builder create(NotificationChannelReviewerContract contract) {
139             if (contract == null) {
140                 throw new IllegalArgumentException("contract was null");
141             }
142             Builder builder = create();
143             builder.setChannel(contract.getChannel() != null ? NotificationChannel.Builder.create(contract.getChannel()) : null);
144             builder.setReviewerType(contract.getReviewerType());
145             builder.setReviewerId(contract.getReviewerId());
146             builder.setId(contract.getId());
147             builder.setVersionNumber(contract.getVersionNumber());
148             builder.setObjectId(contract.getObjectId());
149             return builder;
150         }
151 
152         public NotificationChannelReviewer build() {
153             return new NotificationChannelReviewer(this);
154         }
155 
156         @Override
157         public NotificationChannel.Builder getChannel() {
158             return this.channel;
159         }
160 
161         @Override
162         public String getReviewerType() {
163             return this.reviewerType;
164         }
165 
166         @Override
167         public String getReviewerId() {
168             return this.reviewerId;
169         }
170 
171         @Override
172         public Long getId() {
173             return this.id;
174         }
175 
176         @Override
177         public Long getVersionNumber() {
178             return this.versionNumber;
179         }
180 
181         @Override
182         public String getObjectId() {
183             return this.objectId;
184         }
185 
186         public void setChannel(NotificationChannel.Builder channel) {
187             this.channel = channel;
188         }
189 
190         public void setReviewerType(String reviewerType) {
191             this.reviewerType = reviewerType;
192         }
193 
194         public void setReviewerId(String reviewerId) {
195             this.reviewerId = reviewerId;
196         }
197 
198         public void setId(Long id) {
199             this.id = id;
200         }
201 
202         public void setVersionNumber(Long versionNumber) {
203             this.versionNumber = versionNumber;
204         }
205 
206         public void setObjectId(String objectId) {
207             this.objectId = objectId;
208         }
209 
210     }
211 
212 
213     /**
214      * Defines some internal constants used on this class.
215      *
216      */
217     static class Constants {
218 
219         final static String ROOT_ELEMENT_NAME = "notificationChannelReviewer";
220         final static String TYPE_NAME = "NotificationChannelReviewerType";
221 
222     }
223 
224 
225     /**
226      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
227      *
228      */
229     static class Elements {
230 
231         final static String CHANNEL = "channel";
232         final static String REVIEWER_TYPE = "reviewerType";
233         final static String REVIEWER_ID = "reviewerId";
234         final static String ID = "id";
235 
236     }
237 
238 }