001    /**
002     * Copyright 2005-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.ken.api.notification;
017    
018    import java.io.Serializable;
019    import java.util.Collection;
020    import javax.xml.bind.annotation.XmlAccessType;
021    import javax.xml.bind.annotation.XmlAccessorType;
022    import javax.xml.bind.annotation.XmlAnyElement;
023    import javax.xml.bind.annotation.XmlElement;
024    import javax.xml.bind.annotation.XmlRootElement;
025    import javax.xml.bind.annotation.XmlType;
026    import org.kuali.rice.core.api.CoreConstants;
027    import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
028    import org.kuali.rice.core.api.mo.ModelBuilder;
029    import org.w3c.dom.Element;
030    
031    @XmlRootElement(name = NotificationChannelReviewer.Constants.ROOT_ELEMENT_NAME)
032    @XmlAccessorType(XmlAccessType.NONE)
033    @XmlType(name = NotificationChannelReviewer.Constants.TYPE_NAME, propOrder = {
034            NotificationChannelReviewer.Elements.CHANNEL,
035            NotificationChannelReviewer.Elements.REVIEWER_TYPE,
036            NotificationChannelReviewer.Elements.REVIEWER_ID,
037            NotificationChannelReviewer.Elements.ID,
038            CoreConstants.CommonElements.VERSION_NUMBER,
039            CoreConstants.CommonElements.OBJECT_ID,
040            CoreConstants.CommonElements.FUTURE_ELEMENTS
041    })
042    public final class NotificationChannelReviewer
043            extends AbstractDataTransferObject
044            implements NotificationChannelReviewerContract
045    {
046    
047        @XmlElement(name = Elements.CHANNEL, required = false)
048        private final NotificationChannel channel;
049        @XmlElement(name = Elements.REVIEWER_TYPE, required = false)
050        private final String reviewerType;
051        @XmlElement(name = Elements.REVIEWER_ID, required = false)
052        private final String reviewerId;
053        @XmlElement(name = Elements.ID, required = false)
054        private final Long id;
055        @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
056        private final Long versionNumber;
057        @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
058        private final String objectId;
059        @SuppressWarnings("unused")
060        @XmlAnyElement
061        private final Collection<Element> _futureElements = null;
062    
063        /**
064         * Private constructor used only by JAXB.
065         *
066         */
067        private NotificationChannelReviewer() {
068            this.channel = null;
069            this.reviewerType = null;
070            this.reviewerId = null;
071            this.id = null;
072            this.versionNumber = null;
073            this.objectId = null;
074        }
075    
076        private NotificationChannelReviewer(Builder builder) {
077            this.channel = builder.getChannel() != null ? builder.getChannel().build() : null;
078            this.reviewerType = builder.getReviewerType();
079            this.reviewerId = builder.getReviewerId();
080            this.id = builder.getId();
081            this.versionNumber = builder.getVersionNumber();
082            this.objectId = builder.getObjectId();
083        }
084    
085        @Override
086        public NotificationChannel getChannel() {
087            return this.channel;
088        }
089    
090        @Override
091        public String getReviewerType() {
092            return this.reviewerType;
093        }
094    
095        @Override
096        public String getReviewerId() {
097            return this.reviewerId;
098        }
099    
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    }