public class Interval extends java.lang.Object implements java.lang.Comparable<Interval>
IntervalUnion
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ID
Class identification name with source code version and date.
|
Constructor and Description |
---|
Interval(double min,
double max)
Creates a new interval with the indicated minimum and maximum values.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkValues(java.lang.String label,
double[] values,
Interval allowed)
Checks whether the input values are appropriate for a particular interval.
|
int |
compareTo(Interval i)
Compares this interval with another interval for order.
|
boolean |
contains(double value)
Determines whether an indicated value is within the closed interval.
|
boolean |
equals(java.lang.Object o)
Indicates whether some other object is "equal to" this one.
|
java.lang.String |
format(int decimalPlaces) |
double |
getMax()
Gets the interval's maximum value.
|
double |
getMin()
Gets the interval's minimum value.
|
int |
hashCode()
Returns a hash code value for this interval.
|
double[] |
toArray() |
java.lang.String |
toString()
Gets a string representation for this interval.
|
static Interval |
valueOf(java.lang.String text,
Interval allowed) |
public static final java.lang.String ID
public Interval(double min, double max)
The minimum value, min, must be less than the maximum value, max. If not, an exception is thrown.
java.lang.IllegalArgumentException
- if min is equal to or greater
than max.public double getMin()
public double getMax()
public boolean contains(double value)
Because the interval is a closed interval, the minimum
and maximum
values are included in the test.
In other words, this test evaluates the following:
min ≤ value ≤ max
value
- the value to be tested.public java.lang.String format(int decimalPlaces)
public double[] toArray()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the object to which this object is compared.public int compareTo(Interval i)
This interval is less than the input interval if its getMin()
value
is less. It is greater than the input interval if its minimum is greater
than. If the two intervals have the same minimum, their maximum values are
similarly compared.
compareTo
in interface java.lang.Comparable<Interval>
i
- the interval to be compared.public static void checkValues(java.lang.String label, double[] values, Interval allowed)
If any of these rules is violated, an exception is thrown.
label
- a label used in forming exception messages.values
- the values to check.allowed
- the allowed values.java.lang.NullPointerException
- if values is null.java.lang.IllegalArgumentException
- if values are bad.Copyright \ (C) Arizona Board of Regents on behalf of the \ Planetary Image Research Laboratory, Lunar and \ Planetary Laboratory at the University of Arizona