View Javadoc

1   package org.kuali.rice.kim.api.identity.visa;
2   
3   import java.io.Serializable;
4   import java.util.Collection;
5   import javax.xml.bind.annotation.XmlAccessType;
6   import javax.xml.bind.annotation.XmlAccessorType;
7   import javax.xml.bind.annotation.XmlAnyElement;
8   import javax.xml.bind.annotation.XmlElement;
9   import javax.xml.bind.annotation.XmlRootElement;
10  import javax.xml.bind.annotation.XmlType;
11  
12  import org.apache.commons.lang.StringUtils;
13  import org.kuali.rice.core.api.CoreConstants;
14  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
15  import org.kuali.rice.core.api.mo.ModelBuilder;
16  import org.w3c.dom.Element;
17  
18  @XmlRootElement(name = EntityVisa.Constants.ROOT_ELEMENT_NAME)
19  @XmlAccessorType(XmlAccessType.NONE)
20  @XmlType(name = EntityVisa.Constants.TYPE_NAME, propOrder = {
21      EntityVisa.Elements.ID,
22      EntityVisa.Elements.ENTITY_ID,
23      EntityVisa.Elements.VISA_TYPE_KEY,
24      EntityVisa.Elements.VISA_ENTRY,
25      EntityVisa.Elements.VISA_ID,
26      CoreConstants.CommonElements.VERSION_NUMBER,
27      CoreConstants.CommonElements.OBJECT_ID,
28      CoreConstants.CommonElements.FUTURE_ELEMENTS
29  })
30  public final class EntityVisa extends AbstractDataTransferObject
31      implements EntityVisaContract
32  {
33  
34      @XmlElement(name = Elements.ENTITY_ID, required = false)
35      private final String entityId;
36      @XmlElement(name = Elements.VISA_TYPE_KEY, required = false)
37      private final String visaTypeKey;
38      @XmlElement(name = Elements.VISA_ENTRY, required = false)
39      private final String visaEntry;
40      @XmlElement(name = Elements.VISA_ID, required = false)
41      private final String visaId;
42      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
43      private final Long versionNumber;
44      @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
45      private final String objectId;
46      @XmlElement(name = Elements.ID, required = false)
47      private final String id;
48      @SuppressWarnings("unused")
49      @XmlAnyElement
50      private final Collection<Element> _futureElements = null;
51  
52      /**
53       * Private constructor used only by JAXB.
54       * 
55       */
56      private EntityVisa() {
57          this.entityId = null;
58          this.visaTypeKey = null;
59          this.visaEntry = null;
60          this.visaId = null;
61          this.versionNumber = null;
62          this.objectId = null;
63          this.id = null;
64      }
65  
66      private EntityVisa(Builder builder) {
67          this.entityId = builder.getEntityId();
68          this.visaTypeKey = builder.getVisaTypeKey();
69          this.visaEntry = builder.getVisaEntry();
70          this.visaId = builder.getVisaId();
71          this.versionNumber = builder.getVersionNumber();
72          this.objectId = builder.getObjectId();
73          this.id = builder.getId();
74      }
75  
76      @Override
77      public String getEntityId() {
78          return this.entityId;
79      }
80  
81      @Override
82      public String getVisaTypeKey() {
83          return this.visaTypeKey;
84      }
85  
86      @Override
87      public String getVisaEntry() {
88          return this.visaEntry;
89      }
90  
91      @Override
92      public String getVisaId() {
93          return this.visaId;
94      }
95  
96      @Override
97      public Long getVersionNumber() {
98          return this.versionNumber;
99      }
100 
101     @Override
102     public String getObjectId() {
103         return this.objectId;
104     }
105 
106     @Override
107     public String getId() {
108         return this.id;
109     }
110 
111 
112 
113     /**
114      * A builder which can be used to construct {@link EntityVisa} instances.  Enforces the constraints of the {@link EntityVisaContract}.
115      * 
116      */
117     public final static class Builder
118         implements Serializable, ModelBuilder, EntityVisaContract
119     {
120 
121         private String entityId;
122         private String visaTypeKey;
123         private String visaEntry;
124         private String visaId;
125         private Long versionNumber;
126         private String objectId;
127         private String id;
128 
129         private Builder() { }
130 
131         public static Builder create() {
132             return new Builder();
133         }
134 
135         public static Builder create(EntityVisaContract contract) {
136             if (contract == null) {
137                 throw new IllegalArgumentException("contract was null");
138             }
139             Builder builder = create();
140             builder.setEntityId(contract.getEntityId());
141             builder.setVisaTypeKey(contract.getVisaTypeKey());
142             builder.setVisaEntry(contract.getVisaEntry());
143             builder.setVisaId(contract.getVisaId());
144             builder.setVersionNumber(contract.getVersionNumber());
145             builder.setObjectId(contract.getObjectId());
146             builder.setId(contract.getId());
147             return builder;
148         }
149 
150         public EntityVisa build() {
151             return new EntityVisa(this);
152         }
153 
154         @Override
155         public String getEntityId() {
156             return this.entityId;
157         }
158 
159         @Override
160         public String getVisaTypeKey() {
161             return this.visaTypeKey;
162         }
163 
164         @Override
165         public String getVisaEntry() {
166             return this.visaEntry;
167         }
168 
169         @Override
170         public String getVisaId() {
171             return this.visaId;
172         }
173 
174         @Override
175         public Long getVersionNumber() {
176             return this.versionNumber;
177         }
178 
179         @Override
180         public String getObjectId() {
181             return this.objectId;
182         }
183 
184         @Override
185         public String getId() {
186             return this.id;
187         }
188 
189         public void setEntityId(String entityId) {
190             this.entityId = entityId;
191         }
192 
193         public void setVisaTypeKey(String visaTypeKey) {
194             this.visaTypeKey = visaTypeKey;
195         }
196 
197         public void setVisaEntry(String visaEntry) {
198             this.visaEntry = visaEntry;
199         }
200 
201         public void setVisaId(String visaId) {
202             this.visaId = visaId;
203         }
204 
205         public void setVersionNumber(Long versionNumber) {
206             this.versionNumber = versionNumber;
207         }
208 
209         public void setObjectId(String objectId) {
210             this.objectId = objectId;
211         }
212 
213         public void setId(String id) {
214             if (StringUtils.isWhitespace(id)) {
215                 throw new IllegalArgumentException("id is blank");
216             }
217             this.id = id;
218         }
219 
220     }
221 
222 
223     /**
224      * Defines some internal constants used on this class.
225      * 
226      */
227     static class Constants {
228 
229         final static String ROOT_ELEMENT_NAME = "entityVisa";
230         final static String TYPE_NAME = "EntityVisaType";
231     }
232 
233 
234     /**
235      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
236      * 
237      */
238     static class Elements {
239 
240         final static String ENTITY_ID = "entityId";
241         final static String VISA_TYPE_KEY = "visaTypeKey";
242         final static String VISA_ENTRY = "visaEntry";
243         final static String VISA_ID = "visaId";
244         final static String ID = "id";
245 
246     }
247 
248 }