public final class Ranges
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static float |
requireRange(float value,
float minimum,
float maximum)
Returns
value , but only if it is within the range of minimum (inclusive) and maximum (inclusive). |
static float |
requireRange(float value,
float minimum,
float maximum,
java.lang.String message)
Returns
value , but only if it is within the range of minimum (inclusive) and maximum (inclusive). |
public static float requireRange(float value, float minimum, float maximum)
value
, but only if it is within the range of minimum
(inclusive) and maximum
(inclusive).
If it is not within said range, an IllegalArgumentException
will be thrown.
Calling this method is equivalent to calling Ranges.requireRange(value, minimum, maximum, null)
.
value
- the value to verifyminimum
- the minimum value allowed (inclusive)maximum
- the maximum value allowed (inclusive)value
, but only if it is within the range of minimum
(inclusive) and maximum
(inclusive)java.lang.IllegalArgumentException
- thrown if, and only if, value
is less than minimum
or greater than maximum
public static float requireRange(float value, float minimum, float maximum, java.lang.String message)
value
, but only if it is within the range of minimum
(inclusive) and maximum
(inclusive).
If it is not within said range, an IllegalArgumentException
will be thrown.
The message
parameter will be the detail message of the thrown IllegalArgumentException
. It may be null
.
value
- the value to verifyminimum
- the minimum value allowed (inclusive)maximum
- the maximum value allowed (inclusive)message
- the detail message to the IllegalArgumentException
value
, but only if it is within the range of minimum
(inclusive) and maximum
(inclusive)java.lang.IllegalArgumentException
- thrown if, and only if, value
is less than minimum
or greater than maximum