View Javadoc

1   /*
2    * Copyright 2012 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.r2.common.dto;
17  
18  import java.io.Serializable;
19  import java.util.List;
20  
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.XmlType;
26  
27  import org.kuali.student.r2.common.infc.TimeOfDay;
28  
29  //import javax.xml.bind.Element;
30  //import java.util.List;
31  
32  @XmlAccessorType(XmlAccessType.FIELD)
33  @XmlType(name = "TimeOfDayInfo", propOrder = {"milliSeconds", "_futureElements" }) 
34  public class TimeOfDayInfo implements TimeOfDay, Serializable {
35  
36      @XmlElement
37      private Long milliSeconds;
38      
39      @XmlAnyElement
40      private List<Object> _futureElements;  
41  
42      public TimeOfDayInfo() {
43  
44      }
45  
46      public TimeOfDayInfo(TimeOfDay timeOfDay) {
47          if(null != timeOfDay) {
48              this.milliSeconds = timeOfDay.getMilliSeconds();
49          }
50      }
51  
52      @Override
53      public Long getMilliSeconds() {
54          return this.milliSeconds;
55      }
56  
57      public void setMilliSeconds(Long milliSeconds) {
58          this.milliSeconds = milliSeconds;
59      }
60  
61      /**
62       * Tests if this TimeOfDay is after the specified TimeOfDay.
63       * @param timeOfDay the specified TimeOfDay
64       * @return true if this TimeOfDay is after the specified TimeOfDay, false otherwise.
65       */
66      public boolean isAfter(TimeOfDay timeOfDay) {
67          return this.milliSeconds>timeOfDay.getMilliSeconds();
68      }
69  
70      /**
71       * Tests if this TimeOfDay is before the specified TimeOfDay.
72       * @param timeOfDay the specified TimeOfDay
73       * @return true if this TimeOfDay is before the specified TimeOfDay, false otherwise.
74       */
75      public boolean isBefore(TimeOfDay timeOfDay) {
76          return this.milliSeconds<timeOfDay.getMilliSeconds();
77      }
78  
79      /**
80       * Compares two TimeOfDays for equality. The result is true if and
81       * only if the argument is not null and is a TimeOfDay object that represents the same
82       * point in time, to the millisecond, as this object.
83       * @param obj the object to compare with
84       * @return true if the objects are the same; false otherwise.
85       */
86      public boolean equals (Object obj) {
87          TimeOfDay timeOfDay = (TimeOfDay) obj;
88          return this.milliSeconds==timeOfDay.getMilliSeconds();
89      }
90  
91      @Override
92      public int hashCode() {
93          return milliSeconds != null ? milliSeconds.hashCode() : 0;
94      }
95  
96      @Override
97      public String toString() {
98          return "TimeOfDayInfo{" +
99                  "milliSeconds=" + milliSeconds +
100                 '}';
101     }
102 }