Class Gti

java.lang.Object
gaiasky.util.gaia.time.Gti
All Implemented Interfaces:
Comparable<Gti>

public class Gti extends Object implements 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​(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.
    Return the duration of the GTI
    long
    Return the end time.
    long
    Return the start time.
    int
    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 GTI
    boolean
    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 time
    void
    setStart​(long start)
    Set the start time
    Return a useful string representation

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Gti

      public Gti(long start, long end) throws RuntimeException
      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

      public boolean equals(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 class 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 class 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 RuntimeException
      Set the end time
      Parameters:
      end - the time defining the end of the object validity
      Throws:
      RuntimeException
    • setStart

      public void setStart(long start) throws RuntimeException
      Set the start time
      Parameters:
      start - the time defining the beginning of the object validity
      Throws:
      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
      of the GTI
      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:
      compareTo in interface Comparable<Gti>
      Parameters:
      o -
      Returns:
      int
    • toString

      public String toString()
      Return a useful string representation
      Overrides:
      toString in class Object
      Returns:
      String