public final class Checker extends Object
Modifier and Type | Method and Description |
---|---|
static void |
assertCheck(boolean value)
|
static void |
assertCheck(boolean value,
String what)
|
static double |
betweenOrDefault(double value,
double minimum,
double maximum,
double defaultValue)
Checks if the value is between minimum and maximum passed values and returns it.
|
static int |
betweenOrDefault(int value,
int minimum,
int maximum,
int defaultValue)
Checks if the value is between minimum and maximum passed values and returns it.
|
static double |
betweenOrMaximum(double value,
double minimum,
double maximum)
Checks if the value is between minimum and maximum passed values and returns it.
|
static int |
betweenOrMaximum(int value,
int minimum,
int maximum)
Checks if the value is between minimum and maximum passed values and returns it.
|
static double |
betweenOrMinimum(double value,
double minimum,
double maximum)
Checks if the value is between minimum and maximum passed values and returns it.
|
static int |
betweenOrMinimum(int value,
int minimum,
int maximum)
Checks if the value is between minimum and maximum passed values and returns it.
|
static double |
checkAndGetIfBetween(double value,
double minimum,
double maximum,
String what)
Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static int |
checkAndGetIfBetween(int value,
int minimum,
int maximum,
String what)
Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static double |
checkAndGetIfGreaterThan(double value,
double threshold,
String what)
Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static int |
checkAndGetIfGreaterThan(int value,
int threshold,
String what)
Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static double |
checkAndGetIfLessThan(double value,
double threshold,
String what)
Checks if the value passed as argument is less than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static int |
checkAndGetIfLessThan(int value,
int threshold,
String what)
Checks if the value passed as argument is less than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static double |
checkAndGetIfNegative(double value,
String what)
Checks if value passed as argument is a negative number (zero is excluded).
If not, throw a IllegalArgumentException . |
static int |
checkAndGetIfNegative(int value,
String what)
Checks if value passed as argument is a negative number (zero is excluded).
If not, throw a IllegalArgumentException . |
static double |
checkAndGetIfPositive(double value,
String what)
Checks if value passed as argument is a positive number (zero is included).
If not, throw a IllegalArgumentException . |
static int |
checkAndGetIfPositive(int value,
String what)
Checks if value passed as argument is a positive number (zero is included).
If not, throw a IllegalArgumentException . |
static double |
checkAndGetIfValid(double value,
String what)
Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw a IllegalArgumentException . |
static int |
checkAndGetIfValid(int value,
String what)
Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw a IllegalArgumentException . |
static <T> T |
checkAndGetIfValid(T value,
String what)
Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw a IllegalArgumentException . |
static void |
checkIfBetween(double value,
double minimum,
double maximum,
String what)
Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static void |
checkIfBetween(int value,
int minimum,
int maximum,
String what)
Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static void |
checkIfEqualTo(double value,
double target,
String what)
Checks if both values passed as argument are equals.
If not, throw a IllegalArgumentException . |
static void |
checkIfEqualTo(int value,
int target,
String what)
Checks if both values passed as argument are equals.
If not, throw a IllegalArgumentException . |
static void |
checkIfGreaterThan(double value,
double threshold,
String what)
Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static void |
checkIfGreaterThan(int value,
int threshold,
String what)
Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static void |
checkIfLessThan(double value,
double threshold,
String what)
Checks if the value passed as argument is less than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static void |
checkIfLessThan(int value,
int threshold,
String what)
Checks if the value passed as argument is less than the threshold passed as argument (inclusive).
If not, throw a IllegalArgumentException . |
static void |
checkIfNegative(double value,
String what)
Checks if value passed as argument is a negative number (zero is excluded).
If not, throw a IllegalArgumentException . |
static void |
checkIfNegative(int value,
String what)
Checks if value passed as argument is a negative number (zero is excluded).
If not, throw a IllegalArgumentException . |
static void |
checkIfNotEqualTo(double value,
double target,
String what)
Checks if both values passed as argument are not equals.
If not, throw a IllegalArgumentException . |
static void |
checkIfNotEqualTo(int value,
int target,
String what)
Checks if both values passed as argument are not equals.
If not, throw a IllegalArgumentException . |
static void |
checkIfPositive(double value,
String what)
Checks if value passed as argument is a positive number (zero is included).
If not, throw a IllegalArgumentException . |
static void |
checkIfPositive(int value,
String what)
Checks if value passed as argument is a positive number (zero is included).
If not, throw a IllegalArgumentException . |
static void |
checkIfValid(double value,
String what)
Checks if value passed as argument is valid.
If not, throw a IllegalArgumentException . |
static void |
checkIfValid(int value,
String what)
Checks if value passed as argument is valid.
If not, throw a IllegalArgumentException . |
static void |
checkIfValid(Object value,
String what)
Checks if value passed as argument is valid.
If not, throw a IllegalArgumentException . |
static double |
greaterThanOrDefault(double value,
double threshold,
double defaultValue)
Checks if the value is greater than number and returns it.
|
static int |
greaterThanOrDefault(int value,
int threshold,
int defaultValue)
Checks if the value is greater than number and returns it.
|
static double |
greaterThanOrThreshold(double value,
double threshold)
Checks if the value is greater than number and returns it.
|
static int |
greaterThanOrThreshold(int value,
int threshold)
Checks if the value is greater than number and returns it.
|
static double |
greaterThanOrZero(double value,
double threshold)
Checks if the value is greater than number and returns it.
|
static int |
greaterThanOrZero(int value,
int threshold)
Checks if the value is greater than number and returns it.
|
static boolean |
isBetween(double value,
double minimum,
double maximum)
Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).
|
static boolean |
isBetween(int value,
int minimum,
int maximum)
Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).
|
static boolean |
isEqualTo(double value,
double target)
Checks if both values passed as argument are equals.
|
static boolean |
isEqualTo(int value,
int target)
Checks if both values passed as argument are equals.
|
static boolean |
isGreaterThan(double value,
double threshold)
Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).
|
static boolean |
isGreaterThan(int value,
int threshold)
Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).
|
static boolean |
isLessThan(double value,
double threshold)
Checks if the value passed as argument is less than the threshold passed as argument (inclusive).
|
static boolean |
isLessThan(int value,
int threshold)
Checks if the value passed as argument is less than the threshold passed as argument (inclusive).
|
static boolean |
isNegative(double value)
Checks if value passed as argument is a negative number (zero is excluded).
|
static boolean |
isNegative(int value)
Checks if value passed as argument is a negative number (zero is excluded).
|
static boolean |
isNotEqualTo(double value,
double target)
Checks if both values passed as argument are not equals.
|
static boolean |
isNotEqualTo(int value,
int target)
Checks if both values passed as argument are not equals.
|
static boolean |
isPositive(double value)
Checks if value passed as argument is a positive number (zero is included).
|
static boolean |
isPositive(int value)
Checks if value passed as argument is a positive number (zero is included).
|
static double |
lessThanOrDefault(double value,
double threshold,
double defaultValue)
Checks if the value is less than number and returns it.
|
static int |
lessThanOrDefault(int value,
int threshold,
int defaultValue)
Checks if the value is less than number and returns it.
|
static double |
lessThanOrThreshold(double value,
double threshold)
Checks if the value is less than number and returns it.
|
static int |
lessThanOrThreshold(int value,
int threshold)
Checks if the value is less than number and returns it.
|
static double |
lessThanOrZero(double value,
double threshold)
Checks if the value is less than number and returns it.
|
static int |
lessThanOrZero(int value,
int threshold)
Checks if the value is less than number and returns it.
|
static double |
negativeOrDefault(double value,
double defaultValue)
Checks if the value is a negative number and returns it.
|
static int |
negativeOrDefault(int value,
int defaultValue)
Checks if the value is a negative number and returns it.
|
static double |
negativeOrZero(double value)
Checks if the value is a negative number and returns it.
|
static int |
negativeOrZero(int value)
Checks if the value is a negative number and returns it.
|
static double |
positiveOrDefault(double value,
double defaultValue)
Checks if the value is a positive number and returns it.
|
static int |
positiveOrDefault(int value,
int defaultValue)
Checks if the value is a positive number and returns it.
|
static double |
positiveOrZero(double value)
Checks if the value is a positive number and returns it.
|
static int |
positiveOrZero(int value)
Checks if the value is a positive number and returns it.
|
static double |
validOrDefault(double value,
double defaultValue)
Checks if the value is a consistent number and returns it.
|
static int |
validOrDefault(int value,
int defaultValue)
Checks if the value is a consistent number and returns it.
|
static <T> T |
validOrDefault(T value,
T defaultValue)
Checks if the value is a consistent object and returns it.
|
static double |
validOrZero(double value)
Checks if the value is a consistent number and returns it.
|
static int |
validOrZero(int value)
Checks if the value is a consistent number and returns it.
|
public static void assertCheck(boolean value)
value
- value to be checkedpublic static void assertCheck(boolean value, String what)
value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static int validOrZero(int value)
value
- value to be checkedpublic static int validOrDefault(int value, int defaultValue)
value
- value to be checkeddefaultValue
- value to return if the value is not a consistent numberpublic static int positiveOrZero(int value)
value
- value to be checkedpublic static int positiveOrDefault(int value, int defaultValue)
value
- value to be checkeddefaultValue
- value to return if the value is not a positive numberpublic static int negativeOrZero(int value)
value
- value to be checkedpublic static int negativeOrDefault(int value, int defaultValue)
value
- value to be checkeddefaultValue
- value to return if the value is not a negative numberpublic static int greaterThanOrZero(int value, int threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static int greaterThanOrThreshold(int value, int threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static int greaterThanOrDefault(int value, int threshold, int defaultValue)
value
- value to be checkedthreshold
- value to be compared to the valuedefaultValue
- value to return if the value is not greater than the numberpublic static int lessThanOrZero(int value, int threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static int lessThanOrThreshold(int value, int threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static int lessThanOrDefault(int value, int threshold, int defaultValue)
value
- value to be checkedthreshold
- value to be compared to the valuedefaultValue
- value to return if the value is not less than the numberpublic static int betweenOrMaximum(int value, int minimum, int maximum)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuepublic static int betweenOrMinimum(int value, int minimum, int maximum)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuepublic static int betweenOrDefault(int value, int minimum, int maximum, int defaultValue)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuedefaultValue
- value to return if the value is not between minimum and maximumpublic static double validOrZero(double value)
value
- value to be checkedpublic static double validOrDefault(double value, double defaultValue)
value
- value to be checkeddefaultValue
- value to return if the value is not a consistent numberpublic static double positiveOrZero(double value)
value
- value to be checkedpublic static double positiveOrDefault(double value, double defaultValue)
value
- value to be checkeddefaultValue
- value to return if the value is not a positive numberpublic static double negativeOrZero(double value)
value
- value to be checkedpublic static double negativeOrDefault(double value, double defaultValue)
value
- value to be checkeddefaultValue
- value to return if the value is not a negative numberpublic static double greaterThanOrZero(double value, double threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static double greaterThanOrThreshold(double value, double threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static double greaterThanOrDefault(double value, double threshold, double defaultValue)
value
- value to be checkedthreshold
- value to be compared to the valuedefaultValue
- value to return if the value is not greater than the numberpublic static double lessThanOrZero(double value, double threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static double lessThanOrThreshold(double value, double threshold)
value
- value to be checkedthreshold
- value to be compared to the valuepublic static double lessThanOrDefault(double value, double threshold, double defaultValue)
value
- value to be checkedthreshold
- value to be compared to the valuedefaultValue
- value to return if the value is not less than the numberpublic static double betweenOrMaximum(double value, double minimum, double maximum)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuepublic static double betweenOrMinimum(double value, double minimum, double maximum)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuepublic static double betweenOrDefault(double value, double minimum, double maximum, double defaultValue)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuedefaultValue
- value to return if the value is not between minimum and maximumpublic static void checkIfValid(int value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static int checkAndGetIfValid(int value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static boolean isPositive(int value)
value
- value to be checkedtrue
if the value is positive number (zero is included)public static void checkIfPositive(int value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static int checkAndGetIfPositive(int value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static boolean isNegative(int value)
value
- value to be checkedtrue
if the value is positive number (zero is excluded)public static void checkIfNegative(int value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static int checkAndGetIfNegative(int value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static boolean isNotEqualTo(int value, int target)
value
- value to be checkedtarget
- value to be compared to the valuetrue
if the arguments are not equalspublic static void checkIfNotEqualTo(int value, int target, String what)
IllegalArgumentException
.value
- value to be checkedtarget
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isEqualTo(int value, int target)
value
- value to be checkedtarget
- value to be compared to the valuetrue
if the arguments are equalspublic static void checkIfEqualTo(int value, int target, String what)
IllegalArgumentException
.value
- value to be checkedtarget
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isGreaterThan(int value, int threshold)
value
- value to be checkedthreshold
- value to be compared to the valuetrue
if the value is greater than the threshold (inclusive)public static void checkIfGreaterThan(int value, int threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static int checkAndGetIfGreaterThan(int value, int threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isLessThan(int value, int threshold)
value
- value to be checkedthreshold
- value to be compared to the valuetrue
if the value is less than the threshold (inclusive)public static void checkIfLessThan(int value, int threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static int checkAndGetIfLessThan(int value, int threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isBetween(int value, int minimum, int maximum)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuetrue
if the value passed as argument is between minimum and maximum values, passed as argument (inclusive)public static void checkIfBetween(int value, int minimum, int maximum, String what)
IllegalArgumentException
.value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuewhat
- name of the value to put in the exception messagepublic static int checkAndGetIfBetween(int value, int minimum, int maximum, String what)
IllegalArgumentException
.value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuewhat
- name of the value to put in the exception messagepublic static void checkIfValid(double value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static double checkAndGetIfValid(double value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static boolean isPositive(double value)
value
- value to be checkedtrue
if the value is positive number (zero is included)public static void checkIfPositive(double value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static double checkAndGetIfPositive(double value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static boolean isNegative(double value)
value
- value to be checkedtrue
if the value is positive number (zero is excluded)public static void checkIfNegative(double value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static double checkAndGetIfNegative(double value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static boolean isNotEqualTo(double value, double target)
value
- value to be checkedtarget
- value to be compared to the valuetrue
if the arguments are not equalspublic static void checkIfNotEqualTo(double value, double target, String what)
IllegalArgumentException
.value
- value to be checkedtarget
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isEqualTo(double value, double target)
value
- value to be checkedtarget
- value to be compared to the valuetrue
if the arguments are equalspublic static void checkIfEqualTo(double value, double target, String what)
IllegalArgumentException
.value
- value to be checkedtarget
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isGreaterThan(double value, double threshold)
value
- value to be checkedthreshold
- value to be compared to the valuetrue
if the value is greater than the threshold (inclusive)public static void checkIfGreaterThan(double value, double threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static double checkAndGetIfGreaterThan(double value, double threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isLessThan(double value, double threshold)
value
- value to be checkedthreshold
- value to be compared to the valuetrue
if the value is less than the threshold (inclusive)public static void checkIfLessThan(double value, double threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static double checkAndGetIfLessThan(double value, double threshold, String what)
IllegalArgumentException
.value
- value to be checkedthreshold
- value to be compared to the valuewhat
- name of the value to put in the exception messagepublic static boolean isBetween(double value, double minimum, double maximum)
value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuetrue
if the value passed as argument is between minimum and maximum values, passed as argument (inclusivepublic static void checkIfBetween(double value, double minimum, double maximum, String what)
IllegalArgumentException
.value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuewhat
- name of the value to put in the exception messagepublic static double checkAndGetIfBetween(double value, double minimum, double maximum, String what)
IllegalArgumentException
.value
- value to be checkedminimum
- minimum limit to compare to the valuemaximum
- maximum limit to compare to the valuewhat
- name of the value to put in the exception messagepublic static <T> T validOrDefault(T value, T defaultValue)
T
- type of the object to checkvalue
- value to be checkeddefaultValue
- value to return if the value is not a consistent objectpublic static void checkIfValid(Object value, String what)
IllegalArgumentException
.value
- value to be checkedwhat
- name of the value to put in the exception messagepublic static <T> T checkAndGetIfValid(T value, String what)
IllegalArgumentException
.T
- type of the value to be checkedvalue
- value to be checkedwhat
- name of the value to put in the exception message