Class Interval


  • public class Interval
    extends java.lang.Object
    Represents the, possibly empty, possibly open-ended (end timestamp is infinite), closed-open interval [startTimestamp, endTimestamp).
    Author:
    B.F.A. Hompes
    • Constructor Detail

      • Interval

        public Interval()
        Constructor for empty interval.
      • Interval

        public Interval​(long startTimestamp)
        Constructor for interval with open end.
        Parameters:
        startTimestamp -
      • Interval

        public Interval​(long startTimestamp,
                        long endTimestamp)
        Constructor for interval with closed end.
        Parameters:
        startTimestamp -
        endTimestamp -
      • Interval

        public Interval​(Interval other)
    • Method Detail

      • getStartTimestamp

        public long getStartTimestamp()
      • setStartTimestamp

        public void setStartTimestamp​(long timestamp)
      • getEndTimestamp

        public long getEndTimestamp()
      • setEndTimestamp

        public void setEndTimestamp​(long timestamp)
      • isEmpty

        public boolean isEmpty()
      • setEmpty

        public void setEmpty​(boolean empty)
      • isOpenEnded

        public boolean isOpenEnded()
      • setOpenEnded

        public void setOpenEnded​(boolean openEnded)
      • getLength

        public long getLength()
        Get's the length of the interval.
        Returns:
        -1 in case the interval is open ended or the difference between end and start timestamp in case the interval is closed.
      • containsTimestamp

        public boolean containsTimestamp​(long timestamp)
        Checks whether this interval contains the specified timestamp.
        Parameters:
        timestamp - The timestamp
        Returns:
        True if the timestamp is contained in the interval, false otherwise.
      • containsInterval

        public boolean containsInterval​(Interval other)
        Checks whether this interval contains the specified interval.
        Parameters:
        other - The other interval
        Returns:
        True if the other interval is contained in this interval, false otherwise.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object