Package gaiasky.util.gaia.time
Class Gti
java.lang.Object
gaiasky.util.gaia.time.Gti
- All Implemented Interfaces:
java.lang.Comparable<Gti>
public class Gti extends java.lang.Object implements java.lang.Comparable<Gti>
A GTI (Good Time Interval), is a
-
Constructor Summary
Constructors Constructor Description Gti(long start, long end)
Constructor taking both start and end times. -
Method Summary
Modifier and Type Method Description int
compareTo(Gti o)
boolean
equals(java.lang.Object t)
This is the method that determines if two time intervals are identical one of them will typically contain one time and the other one a start and an end, but we have to also consider that both may have start/end times only.Duration
getDuration()
Return the duration of the GTIlong
getEnd()
Return the end time.long
getStart()
Return the start time.int
hashCode()
This is needed in order to have the search working in the HashMap In order to choose the bucket we don't need more than one second accuracy.boolean
isInside(long time)
Is an instant within the GTI; that is has a time later than or equal to the start time and earlier than or equal to the end time of the GTIboolean
isLessThan(Gti i)
Is this GTI X '<' than the GTI passed in Y? If X starts before Y it is less than Y.void
setEnd(long end)
Set the end timevoid
setStart(long start)
Set the start timejava.lang.String
toString()
Return a useful string representationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
Gti
public Gti(long start, long end) throws java.lang.RuntimeExceptionConstructor taking both start and end times.- Parameters:
start
- the time defining the beginning of the object validity.end
- the time defining the end of the object validity.- Throws:
java.lang.RuntimeException
- Start is later than end
-
-
Method Details
-
equals
public boolean equals(java.lang.Object t)This is the method that determines if two time intervals are identical one of them will typically contain one time and the other one a start and an end, but we have to also consider that both may have start/end times only.- Overrides:
equals
in classjava.lang.Object
- Parameters:
t
- the GTI Object to be compared with- Returns:
- boolean
-
hashCode
public int hashCode()This is needed in order to have the search working in the HashMap In order to choose the bucket we don't need more than one second accuracy.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- int
- See Also:
Object.hashCode()
-
getEnd
public long getEnd()Return the end time.- Returns:
- the time defining the end of the object validity
-
getStart
public long getStart()Return the start time.- Returns:
- the time defining the beginning of the object validity
-
setEnd
public void setEnd(long end) throws java.lang.RuntimeExceptionSet the end time- Parameters:
end
- the time defining the end of the object validity- Throws:
java.lang.RuntimeException
-
setStart
public void setStart(long start) throws java.lang.RuntimeExceptionSet the start time- Parameters:
start
- the time defining the beginning of the object validity- Throws:
java.lang.RuntimeException
-
getDuration
Return the duration of the GTI- Returns:
- Duration object
-
isInside
public boolean isInside(long time)Is an instant within the GTI; that is has a time- later than or equal to the start time and
- earlier than or equal to the end time
- Parameters:
time
- instant to check- Returns:
- true if inside
-
isLessThan
Is this GTI X '<' than the GTI passed in Y? If X starts before Y it is less than Y. If X and Y start at the same time, X is les than Y if it ends before Y If X and Y are the same X is not less than Y- Parameters:
i
- GTI to test- Returns:
- true if this GTI is earlier than the GTI passed in.
-
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<Gti>
- Parameters:
o
-- Returns:
- int
-
toString
public java.lang.String toString()Return a useful string representation- Overrides:
toString
in classjava.lang.Object
- Returns:
- String
-