public enum Range extends java.lang.Enum<Range>
isValid(String)
method returns true
if the supplied
value is of the correct number type, and lies within the defined range, it
returns false
otherwise.
Note that for floating point numbers, the values NaN and
+/-Infinity will always return false
.
That is, values must be real.
Since the different Range
s define ranges for various number
types, the getMinimum()
and getMaximum()
methods return
instances of the generic Number
type.
The caller is responsible for casting, if needed.
RangeVerifier
Enum Constant and Description |
---|
FLOAT
32-bit floating point numbers in the range
[-Float.MAX_VALUE, Float.MAX_VALUE].
|
FLOAT_0_OR_POSITIVE
32-bit floating point numbers in the range [0, Float.MAX_VALUE].
|
FLOAT_0in_TO_1ex
0 inclusive, 1 exclusive, [0, 1) . |
FLOAT_0in_TO_1in
0 inclusive, 1 inclusive, [0, 1] . |
FLOAT_POSITIVE
32-bit floating point numbers in the range
[Float.MIN_VALUE, Float.MAX_VALUE].
|
INT
Integers in the range [Integer.MIN_VALUE, Integer.MAX_VALUE].
|
INT_0_OR_POSITIVE
Odd and even integers in the range [0, Integer.MAX_VALUE].
|
INT_0_OR_POSITIVE_EVEN
Even integers in the range [0, Integer.MAX_VALUE].
|
INT_0_OR_POSITIVE_ODD
Odd integers in the range [0, Integer.MAX_VALUE].
|
INT_POSITIVE
Integers in the range [1, Integer.MAX_VALUE].
|
INT_POSITIVE_EVEN
Even integers in the range [1, Integer.MAX_VALUE].
|
INT_POSITIVE_ODD
Odd integers in the range [1, Integer.MAX_VALUE].
|
VALID_GAUSSIAN_ORDER
Integers 0, 1 and 2.
|
Modifier and Type | Method and Description |
---|---|
abstract java.lang.Number |
getMaximum()
Return the maximum for the
Range . |
abstract java.lang.Number |
getMinimum()
Return the maximum for the
Range . |
abstract boolean |
isValid(java.lang.String theInput)
Parses the
String supplied as parameter, and
indicates whether the supplied value lies within the defined
range. |
static Range |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static Range[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Range INT_0_OR_POSITIVE
public static final Range INT_0_OR_POSITIVE_ODD
public static final Range INT_0_OR_POSITIVE_EVEN
public static final Range INT_POSITIVE
public static final Range INT_POSITIVE_ODD
public static final Range INT_POSITIVE_EVEN
public static final Range INT
public static final Range FLOAT_0_OR_POSITIVE
public static final Range FLOAT_0in_TO_1ex
0
inclusive, 1
exclusive, [0, 1) .public static final Range FLOAT_0in_TO_1in
0
inclusive, 1
inclusive, [0, 1] .public static final Range FLOAT_POSITIVE
public static final Range FLOAT
public static final Range VALID_GAUSSIAN_ORDER
public static Range[] values()
for (Range c : Range.values()) System.out.println(c);
public static Range valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified namejava.lang.NullPointerException
- if the argument is nullpublic abstract java.lang.Number getMinimum()
Range
.
Note, the caller is responsible for any casting, if needed.
public abstract java.lang.Number getMaximum()
Range
.
Note, the caller is responsible for any casting, if needed.
public abstract boolean isValid(java.lang.String theInput)
String
supplied as parameter, and
indicates whether the supplied value lies within the defined
range.
This method always returns false
when a parsing
error occurs.
Also, for floating point numbers, this method always returns
false
for the values NaN
and
+/-Infinity
, as they are considered invalid.theInput
- A Sting
representation of the number to
test.true
if the parameter is successfully
parsed as the defined number type, and lies within the
defined range, false
otherwise.