Class 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

      All Methods Instance Methods Concrete Methods 
      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 GTI
      long 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 GTI
      boolean 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 time
      void setStart​(long start)
      Set the start time
      java.lang.String toString()
      Return a useful string representation
      • Methods inherited from class java.lang.Object

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

      • Gti

        public Gti​(long start,
                   long end)
            throws java.lang.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:
        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:
        equals in class java.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 class java.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.RuntimeException
        Set 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.RuntimeException
        Set 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
        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 java.lang.Comparable<Gti>
        Parameters:
        o -
        Returns:
        int
      • toString

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