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.core.api.paygrade;
17  
18  import java.io.Serializable;
19  import java.math.BigDecimal;
20  import java.util.Collection;
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlAnyElement;
24  import javax.xml.bind.annotation.XmlElement;
25  import javax.xml.bind.annotation.XmlRootElement;
26  import javax.xml.bind.annotation.XmlType;
27  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
28  
29  import org.apache.commons.lang.StringUtils;
30  import org.joda.time.DateTime;
31  import org.joda.time.LocalDate;
32  import org.kuali.rice.core.api.CoreConstants;
33  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
34  import org.kuali.rice.core.api.mo.ModelBuilder;
35  import org.kuali.rice.core.api.util.jaxb.DateTimeAdapter;
36  import org.kuali.rice.core.api.util.jaxb.LocalDateAdapter;
37  import org.w3c.dom.Element;
38  
39  @XmlRootElement(name = PayGrade.Constants.ROOT_ELEMENT_NAME)
40  @XmlAccessorType(XmlAccessType.NONE)
41  @XmlType(name = PayGrade.Constants.TYPE_NAME, propOrder = {
42          PayGrade.Elements.RATE_TYPE,
43          PayGrade.Elements.MIN_RATE,
44          PayGrade.Elements.MAX_RATE,
45          PayGrade.Elements.HR_PAY_GRADE_ID,
46          PayGrade.Elements.PAY_GRADE,
47          PayGrade.Elements.DESCRIPTION,
48          PayGrade.Elements.MID_POINT_RATE,
49          PayGrade.Elements.MAX_HIRING_RATE,
50          PayGrade.Elements.USER_PRINCIPAL_ID,
51          PayGrade.Elements.SAL_GROUP,
52          PayGrade.Elements.ACTIVE,
53          PayGrade.Elements.ID,
54          PayGrade.Elements.CREATE_TIME,
55          PayGrade.Elements.EFFECTIVE_LOCAL_DATE,
56          CoreConstants.CommonElements.VERSION_NUMBER,
57          CoreConstants.CommonElements.OBJECT_ID,
58          CoreConstants.CommonElements.FUTURE_ELEMENTS
59  })
60  public final class PayGrade
61          extends AbstractDataTransferObject
62          implements PayGradeContract
63  {
64  
65      @XmlElement(name = Elements.RATE_TYPE, required = false)
66      private final String rateType;
67      @XmlElement(name = Elements.MIN_RATE, required = false)
68      private final BigDecimal minRate;
69      @XmlElement(name = Elements.MAX_RATE, required = false)
70      private final BigDecimal maxRate;
71      @XmlElement(name = Elements.HR_PAY_GRADE_ID, required = false)
72      private final String hrPayGradeId;
73      @XmlElement(name = Elements.PAY_GRADE, required = false)
74      private final String payGrade;
75      @XmlElement(name = Elements.DESCRIPTION, required = false)
76      private final String description;
77      @XmlElement(name = Elements.MID_POINT_RATE, required = false)
78      private final BigDecimal midPointRate;
79      @XmlElement(name = Elements.MAX_HIRING_RATE, required = false)
80      private final BigDecimal maxHiringRate;
81      @XmlElement(name = Elements.USER_PRINCIPAL_ID, required = false)
82      private final String userPrincipalId;
83      @XmlElement(name = Elements.SAL_GROUP, required = false)
84      private final String salGroup;
85      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
86      private final Long versionNumber;
87      @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
88      private final String objectId;
89      @XmlElement(name = Elements.ACTIVE, required = false)
90      private final boolean active;
91      @XmlElement(name = Elements.ID, required = false)
92      private final String id;
93      @XmlElement(name = Elements.CREATE_TIME, required = false)
94      @XmlJavaTypeAdapter(DateTimeAdapter.class)
95      private final DateTime createTime;
96      @XmlElement(name = Elements.EFFECTIVE_LOCAL_DATE, required = false)
97      @XmlJavaTypeAdapter(LocalDateAdapter.class)
98      private final LocalDate effectiveLocalDate;
99      @SuppressWarnings("unused")
100     @XmlAnyElement
101     private final Collection<Element> _futureElements = null;
102 
103     /**
104      * Private constructor used only by JAXB.
105      *
106      */
107     private PayGrade() {
108         this.rateType = null;
109         this.minRate = null;
110         this.maxRate = null;
111         this.hrPayGradeId = null;
112         this.payGrade = null;
113         this.description = null;
114         this.midPointRate = null;
115         this.maxHiringRate = null;
116         this.userPrincipalId = null;
117         this.salGroup = null;
118         this.versionNumber = null;
119         this.objectId = null;
120         this.active = false;
121         this.id = null;
122         this.createTime = null;
123         this.effectiveLocalDate = null;
124     }
125 
126     private PayGrade(Builder builder) {
127         this.rateType = builder.getRateType();
128         this.minRate = builder.getMinRate();
129         this.maxRate = builder.getMaxRate();
130         this.hrPayGradeId = builder.getHrPayGradeId();
131         this.payGrade = builder.getPayGrade();
132         this.description = builder.getDescription();
133         this.midPointRate = builder.getMidPointRate();
134         this.maxHiringRate = builder.getMaxHiringRate();
135         this.userPrincipalId = builder.getUserPrincipalId();
136         this.salGroup = builder.getSalGroup();
137         this.versionNumber = builder.getVersionNumber();
138         this.objectId = builder.getObjectId();
139         this.active = builder.isActive();
140         this.id = builder.getId();
141         this.createTime = builder.getCreateTime();
142         this.effectiveLocalDate = builder.getEffectiveLocalDate();
143     }
144 
145 
146     @Override
147     public String getRateType() {
148         return this.rateType;
149     }
150 
151     @Override
152     public BigDecimal getMinRate() {
153         return this.minRate;
154     }
155 
156     @Override
157     public BigDecimal getMaxRate() {
158         return this.maxRate;
159     }
160 
161     @Override
162     public String getHrPayGradeId() {
163         return this.hrPayGradeId;
164     }
165 
166     @Override
167     public String getPayGrade() {
168         return this.payGrade;
169     }
170 
171     @Override
172     public String getDescription() {
173         return this.description;
174     }
175 
176     @Override
177     public BigDecimal getMidPointRate() {
178         return this.midPointRate;
179     }
180 
181     @Override
182     public BigDecimal getMaxHiringRate() {
183         return this.maxHiringRate;
184     }
185 
186     @Override
187     public String getUserPrincipalId() {
188         return this.userPrincipalId;
189     }
190 
191     @Override
192     public String getSalGroup() {
193         return this.salGroup;
194     }
195 
196     @Override
197     public Long getVersionNumber() {
198         return this.versionNumber;
199     }
200 
201     @Override
202     public String getObjectId() {
203         return this.objectId;
204     }
205 
206     @Override
207     public boolean isActive() {
208         return this.active;
209     }
210 
211     @Override
212     public String getId() {
213         return this.id;
214     }
215 
216     @Override
217     public DateTime getCreateTime() {
218         return this.createTime;
219     }
220 
221     @Override
222     public LocalDate getEffectiveLocalDate() {
223         return this.effectiveLocalDate;
224     }
225 
226 
227     /**
228      * A builder which can be used to construct {@link PayGrade} instances.  Enforces the constraints of the {@link PayGradeContract}.
229      *
230      */
231     public final static class Builder
232             implements Serializable, PayGradeContract, ModelBuilder
233     {
234 
235         private String rateType;
236         private BigDecimal minRate;
237         private BigDecimal maxRate;
238         private String hrPayGradeId;
239         private String payGrade;
240         private String description;
241         private BigDecimal midPointRate;
242         private BigDecimal maxHiringRate;
243         private String userPrincipalId;
244         private String salGroup;
245         private Long versionNumber;
246         private String objectId;
247         private boolean active;
248         private String id;
249         private DateTime createTime;
250         private LocalDate effectiveLocalDate;
251 
252         private Builder(String payGrade, String salGroup) {
253             setPayGrade(payGrade);
254             setSalGroup(salGroup);
255         }
256 
257         public static Builder create(String payGrade, String salGroup) {
258             return new Builder(payGrade, salGroup);
259         }
260 
261         public static Builder create(PayGradeContract contract) {
262             if (contract == null) {
263                 throw new IllegalArgumentException("contract was null");
264             }
265             Builder builder = create(contract.getPayGrade(), contract.getSalGroup());
266             builder.setRateType(contract.getRateType());
267             builder.setMinRate(contract.getMinRate());
268             builder.setMaxRate(contract.getMaxRate());
269             builder.setHrPayGradeId(contract.getHrPayGradeId());
270             builder.setPayGrade(contract.getPayGrade());
271             builder.setDescription(contract.getDescription());
272             builder.setMidPointRate(contract.getMidPointRate());
273             builder.setMaxHiringRate(contract.getMaxHiringRate());
274             builder.setUserPrincipalId(contract.getUserPrincipalId());
275             builder.setSalGroup(contract.getSalGroup());
276             builder.setVersionNumber(contract.getVersionNumber());
277             builder.setObjectId(contract.getObjectId());
278             builder.setActive(contract.isActive());
279             builder.setId(contract.getId());
280             builder.setCreateTime(contract.getCreateTime());
281             builder.setEffectiveLocalDate(contract.getEffectiveLocalDate());
282             return builder;
283         }
284 
285         public PayGrade build() {
286             return new PayGrade(this);
287         }
288 
289         @Override
290         public String getRateType() {
291             return this.rateType;
292         }
293 
294         @Override
295         public BigDecimal getMinRate() {
296             return this.minRate;
297         }
298 
299         @Override
300         public BigDecimal getMaxRate() {
301             return this.maxRate;
302         }
303 
304         @Override
305         public String getHrPayGradeId() {
306             return this.hrPayGradeId;
307         }
308 
309         @Override
310         public String getPayGrade() {
311             return this.payGrade;
312         }
313 
314         @Override
315         public String getDescription() {
316             return this.description;
317         }
318 
319         @Override
320         public BigDecimal getMidPointRate() {
321             return this.midPointRate;
322         }
323 
324         @Override
325         public BigDecimal getMaxHiringRate() {
326             return this.maxHiringRate;
327         }
328 
329         @Override
330         public String getUserPrincipalId() {
331             return this.userPrincipalId;
332         }
333 
334         @Override
335         public String getSalGroup() {
336             return this.salGroup;
337         }
338 
339         @Override
340         public Long getVersionNumber() {
341             return this.versionNumber;
342         }
343 
344         @Override
345         public String getObjectId() {
346             return this.objectId;
347         }
348 
349         @Override
350         public boolean isActive() {
351             return this.active;
352         }
353 
354         @Override
355         public String getId() {
356             return this.id;
357         }
358 
359         @Override
360         public DateTime getCreateTime() {
361             return this.createTime;
362         }
363 
364         @Override
365         public LocalDate getEffectiveLocalDate() {
366             return this.effectiveLocalDate;
367         }
368 
369         public void setRateType(String rateType) {
370             this.rateType = rateType;
371         }
372 
373         public void setMinRate(BigDecimal minRate) {
374             this.minRate = minRate;
375         }
376 
377         public void setMaxRate(BigDecimal maxRate) {
378             this.maxRate = maxRate;
379         }
380 
381         public void setHrPayGradeId(String hrPayGradeId) {
382             this.hrPayGradeId = hrPayGradeId;
383         }
384 
385         public void setPayGrade(String payGrade) {
386             if (StringUtils.isEmpty(payGrade)) {
387                 throw new IllegalArgumentException("payGrade is blank");
388             }
389             this.payGrade = payGrade;
390         }
391 
392         public void setDescription(String description) {
393             this.description = description;
394         }
395 
396         public void setMidPointRate(BigDecimal midPointRate) {
397             this.midPointRate = midPointRate;
398         }
399 
400         public void setMaxHiringRate(BigDecimal maxHiringRate) {
401             this.maxHiringRate = maxHiringRate;
402         }
403 
404         public void setUserPrincipalId(String userPrincipalId) {
405             this.userPrincipalId = userPrincipalId;
406         }
407 
408         public void setSalGroup(String salGroup) {
409             if (StringUtils.isEmpty(salGroup)) {
410                 throw new IllegalArgumentException("salGroup is blank");
411             }
412             this.salGroup = salGroup;
413         }
414 
415         public void setVersionNumber(Long versionNumber) {
416             this.versionNumber = versionNumber;
417         }
418 
419         public void setObjectId(String objectId) {
420             this.objectId = objectId;
421         }
422 
423         public void setActive(boolean active) {
424             this.active = active;
425         }
426 
427         public void setId(String id) {
428             this.id = id;
429         }
430 
431         public void setCreateTime(DateTime createTime) {
432             this.createTime = createTime;
433         }
434 
435         public void setEffectiveLocalDate(LocalDate effectiveLocalDate) {
436             this.effectiveLocalDate = effectiveLocalDate;
437         }
438 
439     }
440 
441 
442     /**
443      * Defines some internal constants used on this class.
444      *
445      */
446     static class Constants {
447 
448         final static String ROOT_ELEMENT_NAME = "payGrade";
449         final static String TYPE_NAME = "PayGradeType";
450 
451     }
452 
453 
454     /**
455      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
456      *
457      */
458     static class Elements {
459 
460         final static String RATE_TYPE = "rateType";
461         final static String MIN_RATE = "minRate";
462         final static String MAX_RATE = "maxRate";
463         final static String HR_PAY_GRADE_ID = "hrPayGradeId";
464         final static String PAY_GRADE = "payGrade";
465         final static String DESCRIPTION = "description";
466         final static String MID_POINT_RATE = "midPointRate";
467         final static String MAX_HIRING_RATE = "maxHiringRate";
468         final static String USER_PRINCIPAL_ID = "userPrincipalId";
469         final static String SAL_GROUP = "salGroup";
470         final static String ACTIVE = "active";
471         final static String ID = "id";
472         final static String CREATE_TIME = "createTime";
473         final static String EFFECTIVE_LOCAL_DATE = "effectiveLocalDate";
474 
475     }
476 
477 }