Package gaiasky.util.gaia.time
Class Gti
java.lang.Object
gaiasky.util.gaia.time.Gti
- All Implemented Interfaces:
Comparable<Gti>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
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.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 timetoString()
Return a useful string representation
-
Constructor Details
-
Gti
Constructor 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:
RuntimeException
- Start is later than end
-
-
Method Details
-
equals
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. -
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. -
getEnd
public long getEnd()Return the end time.- Returns:
- the time defining the end of the object validity
-
setEnd
Set the end time- Parameters:
end
- the time defining the end of the object validity- Throws:
RuntimeException
-
getStart
public long getStart()Return the start time.- Returns:
- the time defining the beginning of the object validity
-
setStart
Set the start time- Parameters:
start
- the time defining the beginning of the object validity- Throws:
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 interfaceComparable<Gti>
- Parameters:
o
-- Returns:
- int
-
toString
Return a useful string representation
-