View Javadoc

1   /**
2    * Copyright 2004-2013 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.student.contract.model.test.source;
17  
18  import java.io.Serializable;
19  import java.util.Date;
20  import java.util.List;
21  
22  import javax.xml.bind.annotation.XmlAccessType;
23  import javax.xml.bind.annotation.XmlAccessorType;
24  import javax.xml.bind.annotation.XmlAnyElement;
25  import javax.xml.bind.annotation.XmlAttribute;
26  import javax.xml.bind.annotation.XmlElement;
27  import javax.xml.bind.annotation.XmlType;
28  
29  import org.kuali.student.contract.model.test.source.ModelBuilder;
30  import org.kuali.student.contract.model.test.source.State;
31  import org.w3c.dom.Element;
32  
33  @SuppressWarnings("serial")
34  @XmlAccessorType(XmlAccessType.FIELD)
35  @XmlType(name = "StateInfo", propOrder = {"key", "name", "descr", "effectiveDate", "expirationDate", "attributes", "_futureElements"})
36  public class StateInfo extends HasAttributesInfo implements State, Serializable {
37  
38      @XmlAttribute
39      private final String key;
40  
41      @XmlElement
42      private final String name;
43  
44      @XmlElement
45      private final String descr;
46  
47      @XmlElement
48      private final Date effectiveDate;
49  
50      @XmlElement
51      private final Date expirationDate;
52  
53      @XmlAnyElement
54      private final List<Element> _futureElements;
55  
56      private StateInfo() {
57          key = null;
58          name = null;
59          descr = null;
60          effectiveDate = null;
61          expirationDate = null;
62          _futureElements = null;
63      }
64  
65      private StateInfo(State builder) {
66          super(builder);
67          this.key = builder.getKey();
68          this.name = builder.getName();
69          this.descr = builder.getDescr();
70          this.effectiveDate = null != builder.getEffectiveDate() ? new Date(builder.getEffectiveDate().getTime()) : null;
71          this.expirationDate = null != builder.getExpirationDate() ? new Date(builder.getExpirationDate().getTime()) : null;
72          this._futureElements = null;
73      }
74  
75      @Override
76      public String getKey() {
77          return key;
78      }
79  
80      @Override
81      public String getName() {
82          return name;
83      }
84  
85      @Override
86      public String getDescr() {
87          return descr;
88      }
89  
90      @Override
91      public Date getEffectiveDate() {
92          return effectiveDate;
93      }
94  
95      @Override
96      public Date getExpirationDate() {
97          return expirationDate;
98      }
99  
100     public static class Builder extends HasAttributesInfo.Builder implements ModelBuilder<StateInfo>, State {
101         private String key;
102         private String name;
103         private String descr;
104         private Date effectiveDate;
105         private Date expirationDate;
106 
107         public Builder() {}
108 
109         public Builder(State stateInfo) {
110             this.key = stateInfo.getKey();
111             this.name = stateInfo.getName();
112             this.descr = stateInfo.getDescr();
113             this.effectiveDate = stateInfo.getEffectiveDate();
114             this.expirationDate = stateInfo.getExpirationDate();
115         }
116 
117         public StateInfo build() {
118             return new StateInfo(this);
119         }
120 
121         public String getKey() {
122             return key;
123         }
124 
125         public void setKey(String key) {
126             this.key = key;
127         }
128 
129         public String getName() {
130             return name;
131         }
132 
133         public void setName(String name) {
134             this.name = name;
135         }
136 
137         public String getDescr() {
138             return descr;
139         }
140 
141         public void setDescr(String descr) {
142             this.descr = descr;
143         }
144 
145         public Date getEffectiveDate() {
146             return effectiveDate;
147         }
148 
149         public void setEffectiveDate(Date effectiveDate) {
150             this.effectiveDate = effectiveDate;
151         }
152 
153         public Date getExpirationDate() {
154             return expirationDate;
155         }
156 
157         public void setExpirationDate(Date expirationDate) {
158             this.expirationDate = expirationDate;
159         }
160 
161     }
162 }