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