@EqualityReference public final class RangeCheck extends Object
Functions for enforcing range constraints at run time.
The functions are intended for use in the manner of assertions. That is,
the program should behave identically if all of the checks are removed. The
functions raise RangeCheckException upon failure. Exceptions of
this type are not intended to be caught and handled; they indicate
program bugs.
RangeCheckException| Modifier and Type | Field and Description |
|---|---|
static RangeInclusiveD |
NATURAL_DOUBLE
The inclusive range of numbers greater than or equal to
0,
[0, . |
static RangeInclusiveL |
NATURAL_INTEGER
The inclusive range of natural integers,
[0, . |
static RangeInclusiveD |
POSITIVE_DOUBLE
The inclusive range of numbers greater than or equal to
1,
[1, . |
static RangeInclusiveL |
POSITIVE_INTEGER
The inclusive range of positive integers,
[1, . |
| Modifier and Type | Method and Description |
|---|---|
static long |
checkGreater(long x,
String x_name,
long in_lower,
String lower_name)
Assert that
x (named x_name) is greater than
in_lower (named lower_name). |
static BigInteger |
checkGreaterBig(BigInteger x,
String x_name,
BigInteger in_lower,
String lower_name)
Assert that
x (named x_name) is greater than
in_lower (named lower_name). |
static double |
checkGreaterDouble(double x,
String x_name,
double in_lower,
String lower_name)
Assert that
x (named x_name) is greater than
in_lower (named lower_name). |
static long |
checkGreaterEqual(long x,
String x_name,
long in_lower,
String lower_name)
Assert that
x (named x_name) is greater than or
equal to in_lower (named lower_name). |
static BigInteger |
checkGreaterEqualBig(BigInteger x,
String x_name,
BigInteger in_lower,
String lower_name)
Assert that
x (named x_name) is greater than or
equal to in_lower (named lower_name). |
static double |
checkGreaterEqualDouble(double x,
String x_name,
double in_lower,
String lower_name)
Assert that
x (named x_name) is greater than or
equal to in_lower (named lower_name). |
static long |
checkIncludedIn(long x,
String x_name,
RangeInclusiveL range,
String range_name)
Assert that
x (named x_name) is included in the
given range range (named range_name). |
static BigInteger |
checkIncludedInBig(BigInteger x,
String x_name,
RangeInclusiveB range,
String range_name)
Assert that
x (named x_name) is included in the
given range range (named range_name). |
static long |
checkLess(long x,
String x_name,
long in_upper,
String upper_name)
Assert that
x (named x_name) is less than
in_upper (named upper_name). |
static BigInteger |
checkLessBig(BigInteger x,
String x_name,
BigInteger in_upper,
String upper_name)
Assert that
x (named x_name) is less than
in_upper (named upper_name). |
static double |
checkLessDouble(double x,
String x_name,
double in_upper,
String upper_name)
Assert that
x (named x_name) is less than
in_upper (named upper_name). |
static long |
checkLessEqual(long x,
String x_name,
long in_upper,
String upper_name)
Assert that
x (named x_name) is less than or
equal to in_upper (named upper_name). |
static BigInteger |
checkLessEqualBig(BigInteger x,
String x_name,
BigInteger in_upper,
String upper_name)
Assert that
x (named x_name) is less than or
equal to in_upper (named upper_name). |
static double |
checkLessEqualDouble(double x,
String x_name,
double in_upper,
String upper_name)
Assert that
x (named x_name) is less than or
equal to in_upper (named upper_name). |
static RangeInclusiveL |
checkRangeIncludedIn(RangeInclusiveL inner,
String inner_name,
RangeInclusiveL outer,
String outer_name)
Assert that
inner (named inner_name) is
included in the given range outer (named
outer_name). |
static RangeInclusiveB |
checkRangeIncludedInBig(RangeInclusiveB inner,
String inner_name,
RangeInclusiveB outer,
String outer_name)
Assert that
inner (named inner_name) is
included in the given range outer (named
outer_name). |
public static final RangeInclusiveD NATURAL_DOUBLE
0,
[0, Double.MAX_VALUE].public static final RangeInclusiveL NATURAL_INTEGER
[0, Integer.MAX_VALUE].public static final RangeInclusiveD POSITIVE_DOUBLE
1,
[1, Double.MAX_VALUE].public static final RangeInclusiveL POSITIVE_INTEGER
[1, Integer.MAX_VALUE].public static long checkGreater(long x,
String x_name,
long in_lower,
String lower_name)
Assert that x (named x_name) is greater than
in_lower (named lower_name).
x - The checked valuein_lower - The lower boundx_name - The name of the checked valuelower_name - The name of the lower boundpublic static BigInteger checkGreaterBig(BigInteger x, String x_name, BigInteger in_lower, String lower_name)
Assert that x (named x_name) is greater than
in_lower (named lower_name).
x - The checked valuein_lower - The lower boundx_name - The name of the checked valuelower_name - The name of the lower boundpublic static double checkGreaterDouble(double x,
String x_name,
double in_lower,
String lower_name)
Assert that x (named x_name) is greater than
in_lower (named lower_name).
x - The checked valuein_lower - The lower boundx_name - The name of the checked valuelower_name - The name of the lower boundpublic static long checkGreaterEqual(long x,
String x_name,
long in_lower,
String lower_name)
Assert that x (named x_name) is greater than or
equal to in_lower (named lower_name).
x - The checked valuein_lower - The lower boundx_name - The name of xlower_name - The name of the lower boundpublic static BigInteger checkGreaterEqualBig(BigInteger x, String x_name, BigInteger in_lower, String lower_name)
Assert that x (named x_name) is greater than or
equal to in_lower (named lower_name).
x - The checked valuein_lower - The lower boundx_name - The name of the checked valuelower_name - The name of the lower boundpublic static double checkGreaterEqualDouble(double x,
String x_name,
double in_lower,
String lower_name)
Assert that x (named x_name) is greater than or
equal to in_lower (named lower_name).
x - The checked valuein_lower - The lower boundx_name - The name of xlower_name - The name of the lower boundpublic static long checkIncludedIn(long x,
String x_name,
RangeInclusiveL range,
String range_name)
Assert that x (named x_name) is included in the
given range range (named range_name).
x - The checked valuex_name - The name of the checked valuerange - The inclusive rangerange_name - The name of the inclusive rangepublic static BigInteger checkIncludedInBig(BigInteger x, String x_name, RangeInclusiveB range, String range_name)
Assert that x (named x_name) is included in the
given range range (named range_name).
x - The checked valuex_name - The name of the checked valuerange - The inclusive rangerange_name - The name of the inclusive rangepublic static long checkLess(long x,
String x_name,
long in_upper,
String upper_name)
Assert that x (named x_name) is less than
in_upper (named upper_name).
x - The checked valuein_upper - The upper boundx_name - The name of the checked valueupper_name - The name of the upper boundpublic static BigInteger checkLessBig(BigInteger x, String x_name, BigInteger in_upper, String upper_name)
Assert that x (named x_name) is less than
in_upper (named upper_name).
x - The checked valuein_upper - The upper boundx_name - The name of the checked valueupper_name - The name of the upper boundpublic static double checkLessDouble(double x,
String x_name,
double in_upper,
String upper_name)
Assert that x (named x_name) is less than
in_upper (named upper_name).
x - The checked valuein_upper - The upper boundx_name - The name of the checked valueupper_name - The name of the upper boundpublic static long checkLessEqual(long x,
String x_name,
long in_upper,
String upper_name)
Assert that x (named x_name) is less than or
equal to in_upper (named upper_name).
x - The checked valuein_upper - The upper boundx_name - The name of xupper_name - The name of the upper boundpublic static BigInteger checkLessEqualBig(BigInteger x, String x_name, BigInteger in_upper, String upper_name)
Assert that x (named x_name) is less than or
equal to in_upper (named upper_name).
x - The checked valuein_upper - The upper boundx_name - The name of the checked valueupper_name - The name of the upper boundpublic static double checkLessEqualDouble(double x,
String x_name,
double in_upper,
String upper_name)
Assert that x (named x_name) is less than or
equal to in_upper (named upper_name).
x - The checked valuein_upper - The upper boundx_name - The name of xupper_name - The name of the upper boundpublic static RangeInclusiveL checkRangeIncludedIn(RangeInclusiveL inner, String inner_name, RangeInclusiveL outer, String outer_name)
Assert that inner (named inner_name) is
included in the given range outer (named
outer_name).
inner - The checked rangeinner_name - The name of the checked rangeouter - The outer rangeouter_name - The name of the outer rangepublic static RangeInclusiveB checkRangeIncludedInBig(RangeInclusiveB inner, String inner_name, RangeInclusiveB outer, String outer_name)
Assert that inner (named inner_name) is
included in the given range outer (named
outer_name).
inner - The checked rangeinner_name - The name of the checked rangeouter - The outer rangeouter_name - The name of the outer rangeCopyright © 2014 <code@io7m.com> http://io7m.com