org.orekit.utils
Class ComparableInterval<T extends Comparable<T>>

java.lang.Object
  extended by org.orekit.utils.GenericInterval<T>
      extended by org.orekit.utils.ComparableInterval<T>
Type Parameters:
T - the nature of ending points. Must implement java.lang.Comparable
It is HIGHLY recommended this class be immutable!
All Implemented Interfaces:
Serializable, Comparable<ComparableInterval<T>>
Direct Known Subclasses:
AbsoluteDateInterval

public class ComparableInterval<T extends Comparable<T>>
extends GenericInterval<T>
implements Comparable<ComparableInterval<T>>

- Class describing an interval of Comparable data.

- The upper and lower boundaries have to be Comparable, so that the correct order can be checked.

- This class can be extended ; toString may be overriden.

Since:
3.0
Version:
$Id: ComparableInterval.java 17624 2017-05-19 09:05:47Z bignon $
Author:
Pierre Cardoso
See Also:
Serialized Form
Use sample :

For instance, an interval of Doubles ]1.0,2.0[ is created this way :

Interval interval = new Interval(IntervalEndpointType.OPEN, 1.0, 2.0, IntervalEndpointType.OPEN);

Concurrency :
matches the concurrency of the parameter type : using an immutable type is HIGHLY recommended

Constructor Summary
ComparableInterval(IntervalEndpointType lowerEndpointIn, T lowerDataIn, T upperDataIn, IntervalEndpointType upperEndpointIn)
          Constructor.
The input parameters have to be not null.
The lower and upper endpoints also have to be properly ordered.
Otherwise a MathIllegalArgumentException is thrown.
 
Method Summary
 int compareLowerEndTo(ComparableInterval<T> interval)
          Compares the lower end point with the lower end point of the given interval.
 int compareTo(ComparableInterval<T> interval)
          Compares this interval with the specified interval.
 int compareUpperEndTo(ComparableInterval<T> interval)
          Compares the upper end point with the upper end point of the given interval.
 boolean contains(Comparable<T> cmp)
          Returns true when the value belongs to the interval.
 boolean equals(Object interval)
          Checks if the instance represents the same ComparableInterval as another instance.
 int hashCode()
           
 boolean includes(ComparableInterval<T> interval)
          Returns true when this interval includes the other.
 boolean isConnectedTo(ComparableInterval<T> interval)
          Returns true when the lower point coincides with the upper point of the input interval, and one of the two points is closed (and the other one is open).
 boolean overlaps(ComparableInterval<T> interval)
          Returns true when the two intervals overlap.
 
Methods inherited from class org.orekit.utils.GenericInterval
getLowerData, getLowerEndpoint, getUpperData, getUpperEndpoint, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComparableInterval

public ComparableInterval(IntervalEndpointType lowerEndpointIn,
                          T lowerDataIn,
                          T upperDataIn,
                          IntervalEndpointType upperEndpointIn)
Constructor.
The input parameters have to be not null.
The lower and upper endpoints also have to be properly ordered.
Otherwise a MathIllegalArgumentException is thrown.

Parameters:
lowerDataIn - lower end data value
upperDataIn - upper end data value
lowerEndpointIn - lower end point state
upperEndpointIn - upper end point state
Throws:
MathIllegalArgumentException - when the interval is invalid (unchecked exception)
Since:
1.0
Method Detail

contains

public final boolean contains(Comparable<T> cmp)
Returns true when the value belongs to the interval.

Parameters:
cmp - the tested value
Returns:
true when the value belongs to the interval

overlaps

public final boolean overlaps(ComparableInterval<T> interval)
Returns true when the two intervals overlap.

Parameters:
interval - the other interval
Returns:
true when the two intervals overlap

includes

public final boolean includes(ComparableInterval<T> interval)
Returns true when this interval includes the other.

Parameters:
interval - the interval tested for inclusion
Returns:
true when the provided interval is included

isConnectedTo

public final boolean isConnectedTo(ComparableInterval<T> interval)
Returns true when the lower point coincides with the upper point of the input interval, and one of the two points is closed (and the other one is open).

Parameters:
interval - the interval tested for connection
Returns:
true when the provided interval is connected by its upper point

compareLowerEndTo

public final int compareLowerEndTo(ComparableInterval<T> interval)
Compares the lower end point with the lower end point of the given interval. It returns a negative integer if the lower end point is inferior than the lower end point of the given interval, zero if they are equal, or a positive integer if is it superior. The method also compares the lower end point type of the two intervals.

Parameters:
interval - the interval tested for lower end point comparison
Returns:
a negative integer, zero, or a positive integer

compareUpperEndTo

public final int compareUpperEndTo(ComparableInterval<T> interval)
Compares the upper end point with the upper end point of the given interval. It returns a negative integer if the upper end point is inferior than the upper end point of the given interval, zero if they are equal, or a positive integer if is it superior. The method also compares the upper end point type of the two intervals.

Parameters:
interval - the interval tested for upper end point comparison
Returns:
a negative integer, zero, or a positive integer

compareTo

public int compareTo(ComparableInterval<T> interval)
Compares this interval with the specified interval. It returns a negative integer, zero, or a positive integer.

Specified by:
compareTo in interface Comparable<ComparableInterval<T extends Comparable<T>>>
Parameters:
interval - the time interval to be compared.
Returns:
a negative integer, zero, or a positive integer
Throws:
ClassCastException - if the specified object's type prevents it from being compared to this object.

equals

public boolean equals(Object interval)
Checks if the instance represents the same ComparableInterval as another instance.

Overrides:
equals in class Object
Parameters:
interval - other interval
Returns:
true if the instance and the other are equals

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2017 CNES. All Rights Reserved.