001/**
002 * Copyright 2005-2018 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 */
016package org.kuali.rice.ken.api.notification;
017
018import java.io.Serializable;
019import java.util.Collection;
020import javax.xml.bind.annotation.XmlAccessType;
021import javax.xml.bind.annotation.XmlAccessorType;
022import javax.xml.bind.annotation.XmlAnyElement;
023import javax.xml.bind.annotation.XmlElement;
024import javax.xml.bind.annotation.XmlRootElement;
025import javax.xml.bind.annotation.XmlType;
026import org.kuali.rice.core.api.CoreConstants;
027import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
028import org.kuali.rice.core.api.mo.ModelBuilder;
029import org.w3c.dom.Element;
030
031@XmlRootElement(name = NotificationContentType.Constants.ROOT_ELEMENT_NAME)
032@XmlAccessorType(XmlAccessType.NONE)
033@XmlType(name = NotificationContentType.Constants.TYPE_NAME, propOrder = {
034        NotificationContentType.Elements.NAME,
035        NotificationContentType.Elements.VERSION,
036        NotificationContentType.Elements.CURRENT,
037        NotificationContentType.Elements.DESCRIPTION,
038        NotificationContentType.Elements.NAMESPACE,
039        NotificationContentType.Elements.XSD,
040        NotificationContentType.Elements.XSL,
041        NotificationContentType.Elements.ID,
042        CoreConstants.CommonElements.VERSION_NUMBER,
043        CoreConstants.CommonElements.OBJECT_ID,
044        CoreConstants.CommonElements.FUTURE_ELEMENTS
045})
046public final class NotificationContentType
047        extends AbstractDataTransferObject
048        implements NotificationContentTypeContract
049{
050
051    @XmlElement(name = Elements.NAME, required = false)
052    private final String name;
053    @XmlElement(name = Elements.VERSION, required = false)
054    private final Integer version;
055    @XmlElement(name = Elements.CURRENT, required = false)
056    private final boolean current;
057    @XmlElement(name = Elements.DESCRIPTION, required = false)
058    private final String description;
059    @XmlElement(name = Elements.NAMESPACE, required = false)
060    private final String namespace;
061    @XmlElement(name = Elements.XSD, required = false)
062    private final String xsd;
063    @XmlElement(name = Elements.XSL, required = false)
064    private final String xsl;
065    @XmlElement(name = Elements.ID, required = false)
066    private final Long id;
067    @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
068    private final Long versionNumber;
069    @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
070    private final String objectId;
071    @SuppressWarnings("unused")
072    @XmlAnyElement
073    private final Collection<Element> _futureElements = null;
074
075    /**
076     * Private constructor used only by JAXB.
077     *
078     */
079    private NotificationContentType() {
080        this.name = null;
081        this.version = null;
082        this.current = false;
083        this.description = null;
084        this.namespace = null;
085        this.xsd = null;
086        this.xsl = null;
087        this.id = null;
088        this.versionNumber = null;
089        this.objectId = null;
090    }
091
092    private NotificationContentType(Builder builder) {
093        this.name = builder.getName();
094        this.version = builder.getVersion();
095        this.current = builder.isCurrent();
096        this.description = builder.getDescription();
097        this.namespace = builder.getNamespace();
098        this.xsd = builder.getXsd();
099        this.xsl = builder.getXsl();
100        this.id = builder.getId();
101        this.versionNumber = builder.getVersionNumber();
102        this.objectId = builder.getObjectId();
103    }
104
105    @Override
106    public String getName() {
107        return this.name;
108    }
109
110    @Override
111    public Integer getVersion() {
112        return this.version;
113    }
114
115    @Override
116    public boolean isCurrent() {
117        return this.current;
118    }
119
120    @Override
121    public String getDescription() {
122        return this.description;
123    }
124
125    @Override
126    public String getNamespace() {
127        return this.namespace;
128    }
129
130    @Override
131    public String getXsd() {
132        return this.xsd;
133    }
134
135    @Override
136    public String getXsl() {
137        return this.xsl;
138    }
139
140    @Override
141    public Long getId() {
142        return this.id;
143    }
144
145    @Override
146    public Long getVersionNumber() {
147        return this.versionNumber;
148    }
149
150    @Override
151    public String getObjectId() {
152        return this.objectId;
153    }
154
155
156    /**
157     * A builder which can be used to construct {@link NotificationContentType} instances.  Enforces the constraints of the {@link NotificationContentTypeContract}.
158     *
159     */
160    public final static class Builder
161            implements Serializable, ModelBuilder, NotificationContentTypeContract
162    {
163
164        private String name;
165        private Integer version;
166        private boolean current;
167        private String description;
168        private String namespace;
169        private String xsd;
170        private String xsl;
171        private Long id;
172        private Long versionNumber;
173        private String objectId;
174
175        private Builder() {
176        }
177
178        public static Builder create() {
179            return new Builder();
180        }
181
182        public static Builder create(NotificationContentTypeContract contract) {
183            if (contract == null) {
184                throw new IllegalArgumentException("contract was null");
185            }
186            Builder builder = create();
187            builder.setName(contract.getName());
188            builder.setVersion(contract.getVersion());
189            builder.setCurrent(contract.isCurrent());
190            builder.setDescription(contract.getDescription());
191            builder.setNamespace(contract.getNamespace());
192            builder.setXsd(contract.getXsd());
193            builder.setXsl(contract.getXsl());
194            builder.setId(contract.getId());
195            builder.setVersionNumber(contract.getVersionNumber());
196            builder.setObjectId(contract.getObjectId());
197            return builder;
198        }
199
200        public NotificationContentType build() {
201            return new NotificationContentType(this);
202        }
203
204        @Override
205        public String getName() {
206            return this.name;
207        }
208
209        @Override
210        public Integer getVersion() {
211            return this.version;
212        }
213
214        @Override
215        public boolean isCurrent() {
216            return this.current;
217        }
218
219        @Override
220        public String getDescription() {
221            return this.description;
222        }
223
224        @Override
225        public String getNamespace() {
226            return this.namespace;
227        }
228
229        @Override
230        public String getXsd() {
231            return this.xsd;
232        }
233
234        @Override
235        public String getXsl() {
236            return this.xsl;
237        }
238
239        @Override
240        public Long getId() {
241            return this.id;
242        }
243
244        @Override
245        public Long getVersionNumber() {
246            return this.versionNumber;
247        }
248
249        @Override
250        public String getObjectId() {
251            return this.objectId;
252        }
253
254        public void setName(String name) {
255            this.name = name;
256        }
257
258        public void setVersion(Integer version) {
259            this.version = version;
260        }
261
262        public void setCurrent(boolean current) {
263            this.current = current;
264        }
265
266        public void setDescription(String description) {
267            this.description = description;
268        }
269
270        public void setNamespace(String namespace) {
271            this.namespace = namespace;
272        }
273
274        public void setXsd(String xsd) {
275            this.xsd = xsd;
276        }
277
278        public void setXsl(String xsl) {
279            this.xsl = xsl;
280        }
281
282        public void setId(Long id) {
283            this.id = id;
284        }
285
286        public void setVersionNumber(Long versionNumber) {
287            this.versionNumber = versionNumber;
288        }
289
290        public void setObjectId(String objectId) {
291            this.objectId = objectId;
292        }
293
294    }
295
296
297    /**
298     * Defines some internal constants used on this class.
299     *
300     */
301    static class Constants {
302
303        final static String ROOT_ELEMENT_NAME = "notificationContentType";
304        final static String TYPE_NAME = "NotificationContentTypeType";
305
306    }
307
308
309    /**
310     * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
311     *
312     */
313    static class Elements {
314
315        final static String NAME = "name";
316        final static String VERSION = "version";
317        final static String CURRENT = "current";
318        final static String DESCRIPTION = "description";
319        final static String NAMESPACE = "namespace";
320        final static String XSD = "xsd";
321        final static String XSL = "xsl";
322        final static String ID = "id";
323
324    }
325
326}