public final class Bounds extends Object implements IEquatable<Bounds>, IEquatableEpsilon<Bounds>, ImmutableValueType
Constructor and Description |
---|
Bounds()
Initializes a new instance.
|
Bounds(double lowerBound,
double upperBound)
Holds the values which form the bounds of a range of real numbers.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
equals(Bounds left,
Bounds right)
Returns
true if the two instances are exactly equal. |
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
boolean |
equalsEpsilon(Bounds other,
double epsilon)
Indicates whether each value of another instance of this type
is within the required tolerance of the corresponding value of this instance.
|
boolean |
equalsType(Bounds other)
Indicates whether another instance of this type is exactly equal to this instance.
|
boolean |
getIsFinite()
Gets a value indicating whether this instance has a finite value as either the lower or upper bound.
|
boolean |
getIsUnbounded()
Gets a value indicating whether this instance ranges from
Double.NEGATIVE_INFINITY to Double.POSITIVE_INFINITY . |
boolean |
getIsUndefined()
Gets a value indicating whether any of the values for this instance have the value
Double.NaN . |
double |
getLowerBound()
Gets the minimal value defining the range of numbers.
|
static Bounds |
getUnbounded()
Gets a set of
Bounds representing the full range of real values from negative infinity to positive infinity. |
static Bounds |
getUndefined()
Gets a set of
Bounds with values of Double.NaN . |
double |
getUpperBound()
Gets the maximal value defining the range of numbers.
|
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
static boolean |
notEquals(Bounds left,
Bounds right)
Returns
true if the two instances are not exactly equal. |
String |
toString()
Returns the string representation of the value of this instance.
|
public Bounds()
public Bounds(double lowerBound, double upperBound)
lowerBound
- The minimal value defining the range of numbers.upperBound
- The maximal value defining the range of numbers.ArgumentException
- Thrown when the upperBound
is less than the lowerBound
or when
one value is Double.NaN
and the other is not.@Nonnull public static Bounds getUnbounded()
Bounds
representing the full range of real values from negative infinity to positive infinity.
Use IsUnbounded
(get
) to test whether a Bounds
instance is unbounded
since it will return true
if the values range from Double.NEGATIVE_INFINITY
to Double.POSITIVE_INFINITY
.
@Nonnull public static Bounds getUndefined()
Bounds
with values of Double.NaN
.
Use IsUndefined
(get
) to test whether a Bounds
instance
is undefined since it will return true
if any of the values
are Double.NaN
.
public final double getLowerBound()
public final double getUpperBound()
public boolean equals(Object obj)
equals
in class Object
obj
- The object to compare to this instance.true
if obj
is an instance of this type and represents the same value as this instance; otherwise false
.Object.hashCode()
,
HashMap
public final boolean equalsType(@Nonnull Bounds other)
equalsType
in interface IEquatable<Bounds>
other
- The instance to compare to this instance.true
if other
represents the same value as this instance; otherwise false
.public final boolean equalsEpsilon(@Nonnull Bounds other, double epsilon)
equalsEpsilon
in interface IEquatableEpsilon<Bounds>
other
- The set of Bounds
to compare to this instance.epsilon
- The limit at which the absolute differences between the values will not be considered equal.true
if the absolute differences are less than or equal to epsilon
; otherwise false
.public int hashCode()
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public String toString()
public static boolean equals(@Nonnull Bounds left, @Nonnull Bounds right)
true
if the two instances are exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
represents the same value as right
; otherwise false
.public static boolean notEquals(@Nonnull Bounds left, @Nonnull Bounds right)
true
if the two instances are not exactly equal.left
- The instance to compare to right
.right
- The instance to compare to left
.true
if left
does not represent the same value as right
; otherwise false
.public final boolean getIsFinite()
public final boolean getIsUnbounded()
Double.NEGATIVE_INFINITY
to Double.POSITIVE_INFINITY
.public final boolean getIsUndefined()
Double.NaN
.