Package gaiasky.util.gaia.time
Class Gti
- java.lang.Object
-
- gaiasky.util.gaia.time.Gti
-
-
Constructor Summary
Constructors Constructor Description Gti(long start, long end)Constructor taking both start and end times.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Gti o)booleanequals(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.DurationgetDuration()Return the duration of the GTIlonggetEnd()Return the end time.longgetStart()Return the start time.inthashCode()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.booleanisInside(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 GTIbooleanisLessThan(Gti i)Is this GTI X '<' than the GTI passed in Y? If X starts before Y it is less than Y.voidsetEnd(long end)Set the end timevoidsetStart(long start)Set the start timejava.lang.StringtoString()Return a useful string representation
-
-
-
Constructor Detail
-
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 Detail
-
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:
equalsin 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:
hashCodein 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
public Duration 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
public boolean isLessThan(Gti i)
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
public int compareTo(Gti o)
- Specified by:
compareToin interfacejava.lang.Comparable<Gti>- Parameters:
o-- Returns:
- int
-
toString
public java.lang.String toString()
Return a useful string representation- Overrides:
toStringin classjava.lang.Object- Returns:
- String
-
-