org.drools.time
Class Interval
java.lang.Object
org.drools.time.Interval
- All Implemented Interfaces:
- Cloneable
public class Interval
- extends Object
- implements 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 |
static long |
MAX
|
static long |
MIN
|
MIN
public static final long MIN
- See Also:
- Constant Field Values
MAX
public static final long MAX
- See Also:
- Constant Field Values
Interval
public Interval()
Interval
public Interval(long lowerBound,
long upperBound)
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 Object
toString
public String toString()
- Overrides:
toString
in class Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals
in class Object
Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.