View Javadoc

1   /*
2    * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
3    * not use this file except in compliance with the License. You may obtain a copy of the License at
4    * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
5    * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
6    * implied. See the License for the specific language governing permissions and limitations under the License.
7    */
8   
9   package org.kuali.student.common.dto;
10  
11  import java.io.Serializable;
12  import java.util.Date;
13  import java.util.List;
14  
15  import javax.xml.bind.annotation.XmlAccessType;
16  import javax.xml.bind.annotation.XmlAccessorType;
17  import javax.xml.bind.annotation.XmlAnyElement;
18  import javax.xml.bind.annotation.XmlAttribute;
19  import javax.xml.bind.annotation.XmlElement;
20  import javax.xml.bind.annotation.XmlType;
21  
22  import org.kuali.student.common.infc.ModelBuilder;
23  import org.kuali.student.common.infc.State;
24  import org.w3c.dom.Element;
25  
26  @SuppressWarnings("serial")
27  @XmlAccessorType(XmlAccessType.FIELD)
28  @XmlType(name = "StateInfo", propOrder = {"key", "name", "descr", "effectiveDate", "expirationDate", "attributes", "_futureElements"})
29  public class StateInfo extends HasAttributesInfo implements State, Serializable {
30  
31      @XmlAttribute
32      private final String key;
33  
34      @XmlElement
35      private final String name;
36  
37      @XmlElement
38      private final String descr;
39  
40      @XmlElement
41      private final Date effectiveDate;
42  
43      @XmlElement
44      private final Date expirationDate;
45  
46      @XmlAnyElement
47      private final List<Element> _futureElements;
48  
49      private StateInfo() {
50          key = null;
51          name = null;
52          descr = null;
53          effectiveDate = null;
54          expirationDate = null;
55          _futureElements = null;
56      }
57  
58      private StateInfo(State builder) {
59          super(builder);
60          this.key = builder.getKey();
61          this.name = builder.getName();
62          this.descr = builder.getDescr();
63          this.effectiveDate = null != builder.getEffectiveDate() ? new Date(builder.getEffectiveDate().getTime()) : null;
64          this.expirationDate = null != builder.getExpirationDate() ? new Date(builder.getExpirationDate().getTime()) : null;
65          this._futureElements = null;
66      }
67  
68      @Override
69      public String getKey() {
70          return key;
71      }
72  
73      @Override
74      public String getName() {
75          return name;
76      }
77  
78      @Override
79      public String getDescr() {
80          return descr;
81      }
82  
83      @Override
84      public Date getEffectiveDate() {
85          return effectiveDate;
86      }
87  
88      @Override
89      public Date getExpirationDate() {
90          return expirationDate;
91      }
92  
93      public static class Builder extends HasAttributesInfo.Builder implements ModelBuilder<StateInfo>, State {
94          private String key;
95          private String name;
96          private String descr;
97          private Date effectiveDate;
98          private Date expirationDate;
99  
100         public Builder() {}
101 
102         public Builder(State stateInfo) {
103             this.key = stateInfo.getKey();
104             this.name = stateInfo.getName();
105             this.descr = stateInfo.getDescr();
106             this.effectiveDate = stateInfo.getEffectiveDate();
107             this.expirationDate = stateInfo.getExpirationDate();
108         }
109 
110         public StateInfo build() {
111             return new StateInfo(this);
112         }
113 
114         public String getKey() {
115             return key;
116         }
117 
118         public void setKey(String key) {
119             this.key = key;
120         }
121 
122         public String getName() {
123             return name;
124         }
125 
126         public void setName(String name) {
127             this.name = name;
128         }
129 
130         public String getDescr() {
131             return descr;
132         }
133 
134         public void setDescr(String descr) {
135             this.descr = descr;
136         }
137 
138         public Date getEffectiveDate() {
139             return effectiveDate;
140         }
141 
142         public void setEffectiveDate(Date effectiveDate) {
143             this.effectiveDate = effectiveDate;
144         }
145 
146         public Date getExpirationDate() {
147             return expirationDate;
148         }
149 
150         public void setExpirationDate(Date expirationDate) {
151             this.expirationDate = expirationDate;
152         }
153 
154     }
155 }