View Javadoc
1   /**
2    * Copyright 2004-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.kpme.pm.api.position;
17  
18  import java.io.Serializable;
19  import java.util.Collection;
20  import java.util.Collections;
21  import java.util.List;
22  import javax.xml.bind.annotation.*;
23  
24  import org.joda.time.LocalDate;
25  import org.kuali.rice.core.api.CoreConstants;
26  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
27  import org.kuali.rice.core.api.mo.ModelBuilder;
28  import org.w3c.dom.Element;
29  
30  @XmlRootElement(name = PstnFlag.Constants.ROOT_ELEMENT_NAME)
31  @XmlAccessorType(XmlAccessType.NONE)
32  @XmlType(name = PstnFlag.Constants.TYPE_NAME, propOrder = {
33  	PstnFlag.Elements.HR_POSITION_ID,
34      PstnFlag.Elements.EFFECTIVE_LOCAL_DATE_OF_OWNER,
35      CoreConstants.CommonElements.VERSION_NUMBER,
36      CoreConstants.CommonElements.OBJECT_ID,
37      PstnFlag.Elements.CATEGORY,
38      PstnFlag.Elements.NAMES,
39      PstnFlag.Elements.PM_FLAG_ID,
40      CoreConstants.CommonElements.FUTURE_ELEMENTS
41  })
42  public final class PstnFlag extends AbstractDataTransferObject implements PstnFlagContract {
43  
44  	private static final long serialVersionUID = 6134747794553428319L;
45  	
46  	@XmlElement(name = Elements.HR_POSITION_ID, required = false)
47      private final String hrPositionId;
48      @XmlElement(name = Elements.EFFECTIVE_LOCAL_DATE_OF_OWNER, required = false)
49      private final LocalDate effectiveLocalDateOfOwner;
50      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
51      private final Long versionNumber;
52      @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
53      private final String objectId;
54      @XmlElement(name = Elements.CATEGORY, required = false)
55      private final String category;
56      @XmlElementWrapper(name = Elements.NAMES, required = false)
57      @XmlElement(name = Elements.NAME, required = false)
58      private final List<String> names;
59      @XmlElement(name = Elements.PM_FLAG_ID, required = false)
60      private final String pmFlagId;
61      @XmlAnyElement
62      private final Collection<Element> _futureElements = null;
63  
64      /**
65       * Private constructor used only by JAXB.
66       * 
67       */
68      private PstnFlag() {
69          this.hrPositionId = null;
70          this.effectiveLocalDateOfOwner = null;
71          this.versionNumber = null;
72          this.objectId = null;
73          this.category = null;
74          this.names = null;
75          this.pmFlagId = null;
76      }
77  
78      private PstnFlag(Builder builder) {
79          this.hrPositionId = builder.getHrPositionId();
80          this.effectiveLocalDateOfOwner = builder.getEffectiveLocalDateOfOwner();
81          this.versionNumber = builder.getVersionNumber();
82          this.objectId = builder.getObjectId();
83          this.category = builder.getCategory();
84          this.names = builder.getNames() == null ? Collections.<String>emptyList() : Collections.unmodifiableList(builder.getNames());
85          this.pmFlagId = builder.getPmFlagId();
86      }
87      
88      @Override
89      public String getHrPositionId() {
90          return this.hrPositionId;
91      }
92  
93      @Override
94      public LocalDate getEffectiveLocalDateOfOwner() {
95          return this.effectiveLocalDateOfOwner;
96      }
97  
98      @Override
99      public Long getVersionNumber() {
100         return this.versionNumber;
101     }
102 
103     @Override
104     public String getObjectId() {
105         return this.objectId;
106     }
107 
108     @Override
109     public String getCategory() {
110         return this.category;
111     }
112 
113     @Override
114     public List<String> getNames() {
115     	// has been set to an unmodifiable list in the constructor
116         return this.names;
117     }
118 
119     @Override
120     public String getPmFlagId() {
121         return this.pmFlagId;
122     }
123 
124 
125     /**
126      * A builder which can be used to construct {@link PstnFlag} instances.  Enforces the constraints of the {@link PstnFlagContract}.
127      * 
128      */
129     public final static class Builder implements Serializable, PstnFlagContract, ModelBuilder {
130 
131     	private static final long serialVersionUID = -515866156444153425L;
132 		
133     	private String hrPositionId;
134         private LocalDate effectiveLocalDateOfOwner;
135         private Long versionNumber;
136         private String objectId;
137         private String category;
138         private List<String> names;
139         private String pmFlagId;
140 
141         private Builder() {
142         }
143 
144         public static Builder create() {
145             return new Builder();
146         }
147 
148         public static Builder create(PstnFlagContract contract) {
149             if (contract == null) {
150                 throw new IllegalArgumentException("contract was null");
151             }
152             Builder builder = create();
153             builder.setHrPositionId(contract.getHrPositionId());
154             builder.setEffectiveLocalDateOfOwner(contract.getEffectiveLocalDateOfOwner());
155             builder.setVersionNumber(contract.getVersionNumber());
156             builder.setObjectId(contract.getObjectId());
157             builder.setCategory(contract.getCategory());
158             builder.setNames(contract.getNames());
159             builder.setPmFlagId(contract.getPmFlagId());
160             return builder;
161         }
162 
163         public PstnFlag build() {
164             return new PstnFlag(this);
165         }
166         
167         @Override
168         public String getHrPositionId() {
169             return this.hrPositionId;
170         }
171 
172         @Override
173         public LocalDate getEffectiveLocalDateOfOwner() {
174             return this.effectiveLocalDateOfOwner;
175         }
176 
177         @Override
178         public Long getVersionNumber() {
179             return this.versionNumber;
180         }
181 
182         @Override
183         public String getObjectId() {
184             return this.objectId;
185         }
186 
187         @Override
188         public String getCategory() {
189             return this.category;
190         }
191 
192         @Override
193         public List<String> getNames() {
194             return this.names;
195         }
196 
197         @Override
198         public String getPmFlagId() {
199             return this.pmFlagId;
200         }
201         
202         public void setHrPositionId(String hrPositionId) {
203             this.hrPositionId = hrPositionId;
204         }
205 
206         public void setEffectiveLocalDateOfOwner(LocalDate effectiveLocalDateOfOwner) {
207 
208             this.effectiveLocalDateOfOwner = effectiveLocalDateOfOwner;
209         }
210 
211         public void setVersionNumber(Long versionNumber) {
212 
213             this.versionNumber = versionNumber;
214         }
215 
216         public void setObjectId(String objectId) {
217 
218             this.objectId = objectId;
219         }
220 
221         public void setCategory(String category) {
222 
223             this.category = category;
224         }
225 
226         public void setNames(List<String> names) {
227 
228             this.names = names;
229         }
230 
231         public void setPmFlagId(String pmFlagId) {
232 
233             this.pmFlagId = pmFlagId;
234         }
235 
236     }
237 
238 
239     /**
240      * Defines some internal constants used on this class.
241      * 
242      */
243     static class Constants {
244 
245         final static String ROOT_ELEMENT_NAME = "pstnFlag";
246         final static String TYPE_NAME = "PstnFlagType";
247 
248     }
249 
250 
251     /**
252      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
253      * 
254      */
255     static class Elements {
256 
257         final static String HR_POSITION_ID = "hrPositionId";
258         final static String EFFECTIVE_LOCAL_DATE_OF_OWNER = "effectiveLocalDateOfOwner";
259         final static String CATEGORY = "category";
260         final static String NAMES = "names";
261         final static String NAME = "name";
262         final static String PM_FLAG_ID = "pmFlagId";
263 
264     }
265 
266 }