001    package org.kuali.rice.ken.api.notification;
002    
003    import java.io.Serializable;
004    import java.util.Collection;
005    import javax.xml.bind.annotation.XmlAccessType;
006    import javax.xml.bind.annotation.XmlAccessorType;
007    import javax.xml.bind.annotation.XmlAnyElement;
008    import javax.xml.bind.annotation.XmlElement;
009    import javax.xml.bind.annotation.XmlRootElement;
010    import javax.xml.bind.annotation.XmlType;
011    import org.kuali.rice.core.api.CoreConstants;
012    import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
013    import org.kuali.rice.core.api.mo.ModelBuilder;
014    import org.w3c.dom.Element;
015    
016    @XmlRootElement(name = NotificationRecipient.Constants.ROOT_ELEMENT_NAME)
017    @XmlAccessorType(XmlAccessType.NONE)
018    @XmlType(name = NotificationRecipient.Constants.TYPE_NAME, propOrder = {
019            NotificationRecipient.Elements.NOTIFICATION_ID,
020            NotificationRecipient.Elements.RECIPIENT_TYPE,
021            NotificationRecipient.Elements.RECIPIENT_ID,
022            NotificationRecipient.Elements.ID,
023            CoreConstants.CommonElements.VERSION_NUMBER,
024            CoreConstants.CommonElements.OBJECT_ID,
025            CoreConstants.CommonElements.FUTURE_ELEMENTS
026    })
027    public final class NotificationRecipient
028            extends AbstractDataTransferObject
029            implements NotificationRecipientContract
030    {
031    
032        @XmlElement(name = Elements.NOTIFICATION_ID, required = false)
033        private final Long notificationId;
034        @XmlElement(name = Elements.RECIPIENT_TYPE, required = false)
035        private final String recipientType;
036        @XmlElement(name = Elements.RECIPIENT_ID, required = false)
037        private final String recipientId;
038        @XmlElement(name = Elements.ID, required = false)
039        private final Long id;
040        @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
041        private final Long versionNumber;
042        @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
043        private final String objectId;
044        @SuppressWarnings("unused")
045        @XmlAnyElement
046        private final Collection<Element> _futureElements = null;
047    
048        /**
049         * Private constructor used only by JAXB.
050         *
051         */
052        private NotificationRecipient() {
053            this.notificationId = null;
054            this.recipientType = null;
055            this.recipientId = null;
056            this.id = null;
057            this.versionNumber = null;
058            this.objectId = null;
059        }
060    
061        private NotificationRecipient(Builder builder) {
062            this.notificationId = builder.getNotificationId();
063            this.recipientType = builder.getRecipientType();
064            this.recipientId = builder.getRecipientId();
065            this.id = builder.getId();
066            this.versionNumber = builder.getVersionNumber();
067            this.objectId = builder.getObjectId();
068        }
069    
070        @Override
071        public Long getNotificationId() {
072            return this.notificationId;
073        }
074    
075        @Override
076        public String getRecipientType() {
077            return this.recipientType;
078        }
079    
080        @Override
081        public String getRecipientId() {
082            return this.recipientId;
083        }
084    
085        @Override
086        public Long getId() {
087            return this.id;
088        }
089    
090        @Override
091        public Long getVersionNumber() {
092            return this.versionNumber;
093        }
094    
095        @Override
096        public String getObjectId() {
097            return this.objectId;
098        }
099    
100    
101        /**
102         * A builder which can be used to construct {@link NotificationRecipient} instances.  Enforces the constraints of the {@link NotificationRecipientContract}.
103         *
104         */
105        public final static class Builder
106                implements Serializable, ModelBuilder, NotificationRecipientContract
107        {
108    
109            private Long notificationId;
110            private String recipientType;
111            private String recipientId;
112            private Long id;
113            private Long versionNumber;
114            private String objectId;
115    
116            private Builder() {
117                // TODO modify this constructor as needed to pass any required values and invoke the appropriate 'setter' methods
118            }
119    
120            public static Builder create() {
121                // TODO modify as needed to pass any required values and add them to the signature of the 'create' method
122                return new Builder();
123            }
124    
125            public static Builder create(NotificationRecipientContract contract) {
126                if (contract == null) {
127                    throw new IllegalArgumentException("contract was null");
128                }
129                // TODO if create() is modified to accept required parameters, this will need to be modified
130                Builder builder = create();
131                builder.setNotificationId(contract.getNotificationId());
132                builder.setRecipientType(contract.getRecipientType());
133                builder.setRecipientId(contract.getRecipientId());
134                builder.setId(contract.getId());
135                builder.setVersionNumber(contract.getVersionNumber());
136                builder.setObjectId(contract.getObjectId());
137                return builder;
138            }
139    
140            public NotificationRecipient build() {
141                return new NotificationRecipient(this);
142            }
143    
144            @Override
145            public Long getNotificationId() {
146                return this.notificationId;
147            }
148    
149            @Override
150            public String getRecipientType() {
151                return this.recipientType;
152            }
153    
154            @Override
155            public String getRecipientId() {
156                return this.recipientId;
157            }
158    
159            @Override
160            public Long getId() {
161                return this.id;
162            }
163    
164            @Override
165            public Long getVersionNumber() {
166                return this.versionNumber;
167            }
168    
169            @Override
170            public String getObjectId() {
171                return this.objectId;
172            }
173    
174            public void setNotificationId(Long notificationId) {
175                // TODO add validation of input value if required and throw IllegalArgumentException if needed
176                this.notificationId = notificationId;
177            }
178    
179            public void setRecipientType(String recipientType) {
180                // TODO add validation of input value if required and throw IllegalArgumentException if needed
181                this.recipientType = recipientType;
182            }
183    
184            public void setRecipientId(String recipientId) {
185                // TODO add validation of input value if required and throw IllegalArgumentException if needed
186                this.recipientId = recipientId;
187            }
188    
189            public void setId(Long id) {
190                // TODO add validation of input value if required and throw IllegalArgumentException if needed
191                this.id = id;
192            }
193    
194            public void setVersionNumber(Long versionNumber) {
195                // TODO add validation of input value if required and throw IllegalArgumentException if needed
196                this.versionNumber = versionNumber;
197            }
198    
199            public void setObjectId(String objectId) {
200                // TODO add validation of input value if required and throw IllegalArgumentException if needed
201                this.objectId = objectId;
202            }
203    
204        }
205    
206    
207        /**
208         * Defines some internal constants used on this class.
209         *
210         */
211        static class Constants {
212    
213            final static String ROOT_ELEMENT_NAME = "notificationRecipient";
214            final static String TYPE_NAME = "NotificationRecipientType";
215    
216        }
217    
218    
219        /**
220         * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
221         *
222         */
223        static class Elements {
224    
225            final static String NOTIFICATION_ID = "notificationId";
226            final static String RECIPIENT_TYPE = "recipientType";
227            final static String RECIPIENT_ID = "recipientId";
228            final static String ID = "id";
229    
230        }
231    
232    }