Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
HolidayInfo |
|
| 1.2857142857142858;1.286 | ||||
HolidayInfo$Builder |
|
| 1.2857142857142858;1.286 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.core.academiccalendar.dto; | |
17 | ||
18 | import java.io.Serializable; | |
19 | import java.util.Date; | |
20 | import java.util.List; | |
21 | import org.w3c.dom.Element; | |
22 | ||
23 | import javax.xml.bind.annotation.XmlAccessType; | |
24 | import javax.xml.bind.annotation.XmlAccessorType; | |
25 | import javax.xml.bind.annotation.XmlAnyElement; | |
26 | import javax.xml.bind.annotation.XmlElement; | |
27 | import javax.xml.bind.annotation.XmlType; | |
28 | ||
29 | import org.kuali.student.common.infc.ModelBuilder; | |
30 | import org.kuali.student.r2.common.dto.KeyEntityInfo; | |
31 | import org.kuali.student.core.academiccalendar.infc.Holiday; | |
32 | ||
33 | ||
34 | /** | |
35 | * Information about a holiday. | |
36 | * | |
37 | * @Author tom | |
38 | * @Since Tue Apr 05 14:22:34 EDT 2011 | |
39 | */ | |
40 | ||
41 | @XmlAccessorType(XmlAccessType.FIELD) | |
42 | @XmlType(name = "HolidayInfo", propOrder = {"key", "typeKey", "stateKey", "name", "descr", "isDateRange", "startDate", "endDate", "metaInfo", "attributes", "_futureElements"}) | |
43 | ||
44 | public class HolidayInfo extends KeyEntityInfo implements Holiday, Serializable { | |
45 | ||
46 | private static final long serialVersionUID = 1L; | |
47 | ||
48 | @XmlElement | |
49 | private final Boolean isDateRange; | |
50 | ||
51 | @XmlElement | |
52 | private final Date startDate; | |
53 | ||
54 | @XmlElement | |
55 | private final Date endDate; | |
56 | ||
57 | @XmlAnyElement | |
58 | private final List<Element> _futureElements; | |
59 | ||
60 | 0 | private HolidayInfo() { |
61 | 0 | isDateRange = false; |
62 | 0 | startDate = null; |
63 | 0 | endDate = null; |
64 | 0 | _futureElements = null; |
65 | 0 | } |
66 | ||
67 | /** | |
68 | * Constructs a new HolidayInfo from another Holiday. | |
69 | * | |
70 | * @param holiday the Holiday to copy | |
71 | */ | |
72 | public HolidayInfo(Holiday holiday) { | |
73 | 0 | super(holiday); |
74 | ||
75 | 0 | this.isDateRange = holiday.getIsDateRange(); |
76 | 0 | this.startDate = null != holiday.getStartDate() ? new Date(holiday.getStartDate().getTime()) : null; |
77 | 0 | this.endDate = null != holiday.getEndDate() ? new Date(holiday.getEndDate().getTime()) : null; |
78 | ||
79 | 0 | _futureElements = null; |
80 | 0 | } |
81 | ||
82 | /** | |
83 | * Tests if this holiday has a date range. If true, the end date | |
84 | * value follows the start date. | |
85 | * | |
86 | * @return true if this Holiday has different start end end | |
87 | * dates, false if this Holiday represents a single date | |
88 | */ | |
89 | @Override | |
90 | public Boolean getIsDateRange() { | |
91 | 0 | return isDateRange; |
92 | } | |
93 | ||
94 | /** | |
95 | * Gets the start Date and time of the holiday. | |
96 | * | |
97 | * @return the holiday start | |
98 | */ | |
99 | @Override | |
100 | public Date getStartDate() { | |
101 | 0 | return startDate; |
102 | } | |
103 | ||
104 | /** | |
105 | * Gets the end Date and time of the holiday. | |
106 | * | |
107 | * @return the holiday end | |
108 | */ | |
109 | @Override | |
110 | public Date getEndDate() { | |
111 | 0 | return endDate; |
112 | } | |
113 | ||
114 | /** | |
115 | * The builder class for this HolidayInfo. | |
116 | */ | |
117 | 0 | public static class Builder extends KeyEntityInfo.Builder implements ModelBuilder<HolidayInfo>, Holiday { |
118 | ||
119 | private Boolean isDateRange; | |
120 | private Date startDate; | |
121 | private Date endDate; | |
122 | ||
123 | /** | |
124 | * Constructs a new builder. | |
125 | */ | |
126 | 0 | public Builder() { |
127 | 0 | } |
128 | ||
129 | /** | |
130 | * Constructs a new builder initialized from another | |
131 | * Holiday. | |
132 | */ | |
133 | public Builder(Holiday holiday) { | |
134 | 0 | super(holiday); |
135 | 0 | this.isDateRange = holiday.getIsDateRange(); |
136 | 0 | this.startDate = null != holiday.getStartDate() ? new Date(holiday.getStartDate().getTime()) : null; |
137 | 0 | this.endDate = null != holiday.getEndDate() ? new Date(holiday.getEndDate().getTime()) : null; |
138 | 0 | } |
139 | ||
140 | /** | |
141 | * Builds the Holiday. | |
142 | * | |
143 | * @return a new Holiday | |
144 | */ | |
145 | public HolidayInfo build() { | |
146 | 0 | return new HolidayInfo(this); |
147 | } | |
148 | ||
149 | /** | |
150 | * Tests if this holiday has a date range. If true, the end date | |
151 | * value follows the start date. | |
152 | * | |
153 | * @return true if this Holiday has different start end end | |
154 | * dates, false if this Holiday represents a single date | |
155 | */ | |
156 | @Override | |
157 | public Boolean getIsDateRange() { | |
158 | 0 | return isDateRange; |
159 | } | |
160 | ||
161 | /** | |
162 | * Sets the date range flag (should this flag be inferred from | |
163 | * the dates?) | |
164 | * | |
165 | * @param isDateRange true if this Holiday has different | |
166 | * start end end dates, false if this Holiday | |
167 | * represents a single date | |
168 | */ | |
169 | public void setIsDateRange(Boolean isDateRange) { | |
170 | 0 | this.isDateRange = isDateRange; |
171 | 0 | } |
172 | ||
173 | /** | |
174 | * Gets the start date. | |
175 | * | |
176 | * @return the Holiday start date | |
177 | */ | |
178 | @Override | |
179 | public Date getStartDate() { | |
180 | 0 | return startDate; |
181 | } | |
182 | ||
183 | /** | |
184 | * Sets the Holiday start date. | |
185 | * | |
186 | * @param endDate the start date | |
187 | */ | |
188 | public void setStartDate(Date startDate) { | |
189 | 0 | this.startDate = new Date(startDate.getTime()); |
190 | 0 | } |
191 | ||
192 | /** | |
193 | * Gets the start date. | |
194 | * | |
195 | * @return the Holiday end date | |
196 | */ | |
197 | @Override | |
198 | public Date getEndDate() { | |
199 | 0 | return endDate; |
200 | } | |
201 | ||
202 | /** | |
203 | * Sets the Holiday end date. | |
204 | * | |
205 | * @param endDate the end date | |
206 | */ | |
207 | public void setEndDate(Date endDate) { | |
208 | 0 | this.endDate = new Date(endDate.getTime()); |
209 | 0 | } |
210 | } | |
211 | } |