Class Interval

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class Interval
    extends java.lang.Object
    implements java.lang.Cloneable
    A class to represent a time interval. Specially useful to calculate time distance between events constrained by temporal constraints. If the interval is open, i.e., from -infinitum to +infinitum, the representation is created by using lowerBound = Long.MIN_VALUE and upperBound = Long.MAX_VALUE.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long MAX  
      static long MIN  
    • Constructor Summary

      Constructors 
      Constructor Description
      Interval()  
      Interval​(long lowerBound, long upperBound)  
    • Constructor Detail

      • Interval

        public Interval()
      • Interval

        public Interval​(long lowerBound,
                        long upperBound)
    • Method Detail

      • intersect

        public void intersect​(Interval another)
        Calculates the value of the intersection between this Interval and another interval. This is given by the following rule: lowerBound = max( this.lowerBound, another.lowerBound ) upperBound = min( this.upperBound, another.upperBound )
        Parameters:
        another - the other interval to calculate the intersection with.
      • add

        public void add​(Interval another)
        Calculates the path addition of this interval with another interval. This is given by the following rule: lowerBound = ( this.lowerBound == MIN || another.lowerBound == MIN ) ? MIN : this.lowerBound+another.lowerBound; upperBound = ( this.upperBound == MAX || another.upperBound == MAX ) ? MAX : this.upperBound+another.upperBound;
        Parameters:
        another - the other interval to add into this interval
      • getLowerBound

        public long getLowerBound()
      • setLowerBound

        public void setLowerBound​(long lowerBound)
      • getUpperBound

        public long getUpperBound()
      • setUpperBound

        public void setUpperBound​(long upperBound)
      • clone

        public Interval clone()
        Overrides:
        clone in class java.lang.Object
      • toString

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

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

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