001/* 002 * Copyright 2012 The Kuali Foundation Licensed under the 003 * Educational Community License, Version 2.0 (the "License"); you may 004 * not use this file except in compliance with the License. You may 005 * obtain a copy of the License at 006 * 007 * http://www.osedu.org/licenses/ECL-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, 010 * software distributed under the License is distributed on an "AS IS" 011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing 013 * permissions and limitations under the License. 014 */ 015 016package org.kuali.student.r2.common.dto; 017 018import java.io.Serializable; 019import java.util.List; 020 021import javax.xml.bind.annotation.XmlAccessType; 022import javax.xml.bind.annotation.XmlAccessorType; 023import javax.xml.bind.annotation.XmlAnyElement; 024import javax.xml.bind.annotation.XmlElement; 025import javax.xml.bind.annotation.XmlType; 026 027import org.kuali.student.r2.common.infc.TimeOfDay; 028 029//import javax.xml.bind.Element; 030//import java.util.List; 031 032@XmlAccessorType(XmlAccessType.FIELD) 033@XmlType(name = "TimeOfDayInfo", propOrder = {"milliSeconds", "_futureElements" }) 034public class TimeOfDayInfo implements TimeOfDay, Serializable { 035 036 @XmlElement 037 private Long milliSeconds; 038 039 @XmlAnyElement 040 private List<Object> _futureElements; 041 042 public TimeOfDayInfo() { 043 044 } 045 046 public TimeOfDayInfo(TimeOfDay timeOfDay) { 047 if(null != timeOfDay) { 048 this.milliSeconds = timeOfDay.getMilliSeconds(); 049 } 050 } 051 052 @Override 053 public Long getMilliSeconds() { 054 return this.milliSeconds; 055 } 056 057 public void setMilliSeconds(Long milliSeconds) { 058 this.milliSeconds = milliSeconds; 059 } 060 061 /** 062 * Tests if this TimeOfDay is after the specified TimeOfDay. 063 * @param timeOfDay the specified TimeOfDay 064 * @return true if this TimeOfDay is after the specified TimeOfDay, false otherwise. 065 */ 066 public boolean isAfter(TimeOfDay timeOfDay) { 067 return this.milliSeconds>timeOfDay.getMilliSeconds(); 068 } 069 070 /** 071 * Tests if this TimeOfDay is before the specified TimeOfDay. 072 * @param timeOfDay the specified TimeOfDay 073 * @return true if this TimeOfDay is before the specified TimeOfDay, false otherwise. 074 */ 075 public boolean isBefore(TimeOfDay timeOfDay) { 076 return this.milliSeconds<timeOfDay.getMilliSeconds(); 077 } 078 079 /** 080 * Compares two TimeOfDays for equality. The result is true if and 081 * only if the argument is not null and is a TimeOfDay object that represents the same 082 * point in time, to the millisecond, as this object. 083 * @param obj the object to compare with 084 * @return true if the objects are the same; false otherwise. 085 */ 086 public boolean equals (Object obj) { 087 TimeOfDay timeOfDay = (TimeOfDay) obj; 088 if (this.milliSeconds == null) { 089 if (timeOfDay == null) { 090 return true; 091 } else { 092 return false; 093 } 094 } 095 return this.milliSeconds.equals(timeOfDay.getMilliSeconds()); 096 } 097 098 @Override 099 public int hashCode() { 100 return milliSeconds != null ? milliSeconds.hashCode() : 0; 101 } 102 103 @Override 104 public String toString() { 105 return "TimeOfDayInfo{" + 106 "milliSeconds=" + milliSeconds + 107 '}'; 108 } 109}