Class Checker
- java.lang.Object
-
- org.pepstock.charba.client.commons.Checker
-
public final class Checker extends Object
Utility which provides a set o methods to check the values of numbers.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertCheck(boolean value)static voidassertCheck(boolean value, String what)static doublebetweenOrDefault(double value, double minimum, double maximum, double defaultValue)Checks if the value is between minimum and maximum passed values and returns it.static intbetweenOrDefault(int value, int minimum, int maximum, int defaultValue)Checks if the value is between minimum and maximum passed values and returns it.static doublebetweenOrMaximum(double value, double minimum, double maximum)Checks if the value is between minimum and maximum passed values and returns it.static intbetweenOrMaximum(int value, int minimum, int maximum)Checks if the value is between minimum and maximum passed values and returns it.static doublebetweenOrMinimum(double value, double minimum, double maximum)Checks if the value is between minimum and maximum passed values and returns it.static intbetweenOrMinimum(int value, int minimum, int maximum)Checks if the value is between minimum and maximum passed values and returns it.static doublecheckAndGetIfBetween(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 aIllegalArgumentException.static intcheckAndGetIfBetween(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 aIllegalArgumentException.static doublecheckAndGetIfGreaterThan(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 aIllegalArgumentException.static intcheckAndGetIfGreaterThan(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 aIllegalArgumentException.static doublecheckAndGetIfLessThan(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 aIllegalArgumentException.static intcheckAndGetIfLessThan(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 aIllegalArgumentException.static doublecheckAndGetIfNegative(double value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.static intcheckAndGetIfNegative(int value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.static doublecheckAndGetIfPositive(double value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.static intcheckAndGetIfPositive(int value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.static doublecheckAndGetIfValid(double value, String what)Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw aIllegalArgumentException.static intcheckAndGetIfValid(int value, String what)Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw aIllegalArgumentException.static <T> TcheckAndGetIfValid(T value, String what)Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw aIllegalArgumentException.static voidcheckIfBetween(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 aIllegalArgumentException.static voidcheckIfBetween(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 aIllegalArgumentException.static voidcheckIfEqualTo(double value, double target, String what)Checks if both values passed as argument are equals.
If not, throw aIllegalArgumentException.static voidcheckIfEqualTo(int value, int target, String what)Checks if both values passed as argument are equals.
If not, throw aIllegalArgumentException.static voidcheckIfGreaterThan(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 aIllegalArgumentException.static voidcheckIfGreaterThan(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 aIllegalArgumentException.static voidcheckIfLessThan(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 aIllegalArgumentException.static voidcheckIfLessThan(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 aIllegalArgumentException.static voidcheckIfNegative(double value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.static voidcheckIfNegative(int value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.static voidcheckIfNotEqualTo(double value, double target, String what)Checks if both values passed as argument are not equals.
If not, throw aIllegalArgumentException.static voidcheckIfNotEqualTo(int value, int target, String what)Checks if both values passed as argument are not equals.
If not, throw aIllegalArgumentException.static voidcheckIfPositive(double value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.static voidcheckIfPositive(int value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.static voidcheckIfValid(double value, String what)Checks if value passed as argument is valid.
If not, throw aIllegalArgumentException.static voidcheckIfValid(int value, String what)Checks if value passed as argument is valid.
If not, throw aIllegalArgumentException.static voidcheckIfValid(Object value, String what)Checks if value passed as argument is valid.
If not, throw aIllegalArgumentException.static doublegreaterThanOrDefault(double value, double threshold, double defaultValue)Checks if the value is greater than number and returns it.static intgreaterThanOrDefault(int value, int threshold, int defaultValue)Checks if the value is greater than number and returns it.static doublegreaterThanOrThreshold(double value, double threshold)Checks if the value is greater than number and returns it.static intgreaterThanOrThreshold(int value, int threshold)Checks if the value is greater than number and returns it.static doublegreaterThanOrZero(double value, double threshold)Checks if the value is greater than number and returns it.static intgreaterThanOrZero(int value, int threshold)Checks if the value is greater than number and returns it.static booleanisBetween(double value, double minimum, double maximum)Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).static booleanisBetween(int value, int minimum, int maximum)Checks if the value passed as argument is between minimum and maximum values, passed as argument (inclusive).static booleanisEqualTo(double value, double target)Checks if both values passed as argument are equals.static booleanisEqualTo(int value, int target)Checks if both values passed as argument are equals.static booleanisGreaterThan(double value, double threshold)Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).static booleanisGreaterThan(int value, int threshold)Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).static booleanisLessThan(double value, double threshold)Checks if the value passed as argument is less than the threshold passed as argument (inclusive).static booleanisLessThan(int value, int threshold)Checks if the value passed as argument is less than the threshold passed as argument (inclusive).static booleanisNegative(double value)Checks if value passed as argument is a negative number (zero is excluded).static booleanisNegative(int value)Checks if value passed as argument is a negative number (zero is excluded).static booleanisNotEqualTo(double value, double target)Checks if both values passed as argument are not equals.static booleanisNotEqualTo(int value, int target)Checks if both values passed as argument are not equals.static booleanisPositive(double value)Checks if value passed as argument is a positive number (zero is included).static booleanisPositive(int value)Checks if value passed as argument is a positive number (zero is included).static doublelessThanOrDefault(double value, double threshold, double defaultValue)Checks if the value is less than number and returns it.static intlessThanOrDefault(int value, int threshold, int defaultValue)Checks if the value is less than number and returns it.static doublelessThanOrThreshold(double value, double threshold)Checks if the value is less than number and returns it.static intlessThanOrThreshold(int value, int threshold)Checks if the value is less than number and returns it.static doublelessThanOrZero(double value, double threshold)Checks if the value is less than number and returns it.static intlessThanOrZero(int value, int threshold)Checks if the value is less than number and returns it.static doublenegativeOrDefault(double value, double defaultValue)Checks if the value is a negative number and returns it.static intnegativeOrDefault(int value, int defaultValue)Checks if the value is a negative number and returns it.static doublenegativeOrZero(double value)Checks if the value is a negative number and returns it.static intnegativeOrZero(int value)Checks if the value is a negative number and returns it.static doublepositiveOrDefault(double value, double defaultValue)Checks if the value is a positive number and returns it.static intpositiveOrDefault(int value, int defaultValue)Checks if the value is a positive number and returns it.static doublepositiveOrZero(double value)Checks if the value is a positive number and returns it.static intpositiveOrZero(int value)Checks if the value is a positive number and returns it.static doublevalidOrDefault(double value, double defaultValue)Checks if the value is a consistent number and returns it.static intvalidOrDefault(int value, int defaultValue)Checks if the value is a consistent number and returns it.static <T> TvalidOrDefault(T value, T defaultValue)Checks if the value is a consistent object and returns it.static doublevalidOrZero(double value)Checks if the value is a consistent number and returns it.static intvalidOrZero(int value)Checks if the value is a consistent number and returns it.
-
-
-
Method Detail
-
assertCheck
public static void assertCheck(boolean value)
- Parameters:
value- value to be checked
-
assertCheck
public static void assertCheck(boolean value, String what)- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
validOrZero
public static int validOrZero(int value)
Checks if the value is a consistent number and returns it. If not a consistent number, returns 0.- Parameters:
value- value to be checked- Returns:
- the value passed as argument if is a consistent number or 0.
-
validOrDefault
public static int validOrDefault(int value, int defaultValue)Checks if the value is a consistent number and returns it. If not a consistent number, returns the default.- Parameters:
value- value to be checkeddefaultValue- value to return if the value is not a consistent number- Returns:
- the value passed as argument if is a consistent number or the default.
-
positiveOrZero
public static int positiveOrZero(int value)
Checks if the value is a positive number and returns it. If not a positive number, returns 0.- Parameters:
value- value to be checked- Returns:
- the value passed as argument if is a positive number or 0.
-
positiveOrDefault
public static int positiveOrDefault(int value, int defaultValue)Checks if the value is a positive number and returns it. If not a positive number, returns the default.- Parameters:
value- value to be checkeddefaultValue- value to return if the value is not a positive number- Returns:
- the value passed as argument if is a positive number or the default.
-
negativeOrZero
public static int negativeOrZero(int value)
Checks if the value is a negative number and returns it. If not a negative number, returns 0.- Parameters:
value- value to be checked- Returns:
- the value passed as argument if is a negative number or 0.
-
negativeOrDefault
public static int negativeOrDefault(int value, int defaultValue)Checks if the value is a negative number and returns it. If not a negative number, returns the default.- Parameters:
value- value to be checkeddefaultValue- value to return if the value is not a negative number- Returns:
- the value passed as argument if is a negative number or the default.
-
greaterThanOrZero
public static int greaterThanOrZero(int value, int threshold)Checks if the value is greater than number and returns it. If not greater than, returns 0.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is greater than the number or 0.
-
greaterThanOrThreshold
public static int greaterThanOrThreshold(int value, int threshold)Checks if the value is greater than number and returns it. If not greater than, returns the threshold.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is greater than the number or the threshold.
-
greaterThanOrDefault
public static int greaterThanOrDefault(int value, int threshold, int defaultValue)Checks if the value is greater than number and returns it. If not greater than, returns the default.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuedefaultValue- value to return if the value is not greater than the number- Returns:
- the value passed as argument if is greater than the number or the default.
-
lessThanOrZero
public static int lessThanOrZero(int value, int threshold)Checks if the value is less than number and returns it. If not less than, returns 0.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is less than the number or 0.
-
lessThanOrThreshold
public static int lessThanOrThreshold(int value, int threshold)Checks if the value is less than number and returns it. If not less than, returns the threshold.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is less than the number or the threshold.
-
lessThanOrDefault
public static int lessThanOrDefault(int value, int threshold, int defaultValue)Checks if the value is less than number and returns it. If not less than, returns the default.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuedefaultValue- value to return if the value is not less than the number- Returns:
- the value passed as argument if is less than the number or the default.
-
betweenOrMaximum
public static int betweenOrMaximum(int value, int minimum, int maximum)Checks if the value is between minimum and maximum passed values and returns it. If not between, returns the maximum.- Parameters:
value- value to be checkedminimum- minimum limit to compare to the valuemaximum- maximum limit to compare to the value- Returns:
- the value passed as argument if is between minimum and maximum passed values or the maximum.
-
betweenOrMinimum
public static int betweenOrMinimum(int value, int minimum, int maximum)Checks if the value is between minimum and maximum passed values and returns it. If not between, returns the minimum.- Parameters:
value- value to be checkedminimum- minimum limit to compare to the valuemaximum- maximum limit to compare to the value- Returns:
- the value passed as argument if is between minimum and maximum passed values or the minimum.
-
betweenOrDefault
public 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. If not between, returns the default.- Parameters:
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 maximum- Returns:
- the value passed as argument if is between minimum and maximum passed values or the default.
-
validOrZero
public static double validOrZero(double value)
Checks if the value is a consistent number and returns it. If not a consistent number, returns 0.- Parameters:
value- value to be checked- Returns:
- the value passed as argument if is a consistent number or 0.
-
validOrDefault
public static double validOrDefault(double value, double defaultValue)Checks if the value is a consistent number and returns it. If not a consistent number, returns the default.- Parameters:
value- value to be checkeddefaultValue- value to return if the value is not a consistent number- Returns:
- the value passed as argument if is a consistent number or the default.
-
positiveOrZero
public static double positiveOrZero(double value)
Checks if the value is a positive number and returns it. If not a positive number, returns 0.- Parameters:
value- value to be checked- Returns:
- the value passed as argument if is a positive number or 0.
-
positiveOrDefault
public static double positiveOrDefault(double value, double defaultValue)Checks if the value is a positive number and returns it. If not a positive number, returns the default.- Parameters:
value- value to be checkeddefaultValue- value to return if the value is not a positive number- Returns:
- the value passed as argument if is a positive number or the default.
-
negativeOrZero
public static double negativeOrZero(double value)
Checks if the value is a negative number and returns it. If not a negative number, returns 0.- Parameters:
value- value to be checked- Returns:
- the value passed as argument if is a negative number or 0.
-
negativeOrDefault
public static double negativeOrDefault(double value, double defaultValue)Checks if the value is a negative number and returns it. If not a negative number, returns the default.- Parameters:
value- value to be checkeddefaultValue- value to return if the value is not a negative number- Returns:
- the value passed as argument if is a negative number or the default.
-
greaterThanOrZero
public static double greaterThanOrZero(double value, double threshold)Checks if the value is greater than number and returns it. If not greater than, returns 0.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is greater than the number or 0.
-
greaterThanOrThreshold
public static double greaterThanOrThreshold(double value, double threshold)Checks if the value is greater than number and returns it. If not greater than, returns the threshold.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is greater than the number or the threshold.
-
greaterThanOrDefault
public static double greaterThanOrDefault(double value, double threshold, double defaultValue)Checks if the value is greater than number and returns it. If not greater than, returns the default.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuedefaultValue- value to return if the value is not greater than the number- Returns:
- the value passed as argument if is greater than the number or the default.
-
lessThanOrZero
public static double lessThanOrZero(double value, double threshold)Checks if the value is less than number and returns it. If not less than, returns 0.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is less than the number or 0.
-
lessThanOrThreshold
public static double lessThanOrThreshold(double value, double threshold)Checks if the value is less than number and returns it. If not less than, returns the threshold.- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
- the value passed as argument if is less than the number or the threshold.
-
lessThanOrDefault
public static double lessThanOrDefault(double value, double threshold, double defaultValue)Checks if the value is less than number and returns it. If not less than, returns the default.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuedefaultValue- value to return if the value is not less than the number- Returns:
- the value passed as argument if is less than the number or the default.
-
betweenOrMaximum
public static double betweenOrMaximum(double value, double minimum, double maximum)Checks if the value is between minimum and maximum passed values and returns it. If not between, returns the maximum.- Parameters:
value- value to be checkedminimum- minimum limit to compare to the valuemaximum- maximum limit to compare to the value- Returns:
- the value passed as argument if is between minimum and maximum passed values or the maximum.
-
betweenOrMinimum
public static double betweenOrMinimum(double value, double minimum, double maximum)Checks if the value is between minimum and maximum passed values and returns it. If not between, returns the minimum.- Parameters:
value- value to be checkedminimum- minimum limit to compare to the valuemaximum- maximum limit to compare to the value- Returns:
- the value passed as argument if is between minimum and maximum passed values or the minimum.
-
betweenOrDefault
public 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. If not between, returns the default.- Parameters:
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 maximum- Returns:
- the value passed as argument if is between minimum and maximum passed values or the default.
-
checkIfValid
public static void checkIfValid(int value, String what)Checks if value passed as argument is valid.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
checkAndGetIfValid
public static int checkAndGetIfValid(int value, String what)Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isPositive
public static boolean isPositive(int value)
Checks if value passed as argument is a positive number (zero is included).- Parameters:
value- value to be checked- Returns:
trueif the value is positive number (zero is included)
-
checkIfPositive
public static void checkIfPositive(int value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
checkAndGetIfPositive
public static int checkAndGetIfPositive(int value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isNegative
public static boolean isNegative(int value)
Checks if value passed as argument is a negative number (zero is excluded).- Parameters:
value- value to be checked- Returns:
trueif the value is positive number (zero is excluded)
-
checkIfNegative
public static void checkIfNegative(int value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
checkAndGetIfNegative
public static int checkAndGetIfNegative(int value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isNotEqualTo
public static boolean isNotEqualTo(int value, int target)Checks if both values passed as argument are not equals.- Parameters:
value- value to be checkedtarget- value to be compared to the value- Returns:
trueif the arguments are not equals
-
checkIfNotEqualTo
public static void checkIfNotEqualTo(int value, int target, String what)Checks if both values passed as argument are not equals.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedtarget- value to be compared to the valuewhat- name of the value to put in the exception message
-
isEqualTo
public static boolean isEqualTo(int value, int target)Checks if both values passed as argument are equals.- Parameters:
value- value to be checkedtarget- value to be compared to the value- Returns:
trueif the arguments are equals
-
checkIfEqualTo
public static void checkIfEqualTo(int value, int target, String what)Checks if both values passed as argument are equals.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedtarget- value to be compared to the valuewhat- name of the value to put in the exception message
-
isGreaterThan
public static boolean isGreaterThan(int value, int threshold)Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
trueif the value is greater than the threshold (inclusive)
-
checkIfGreaterThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message
-
checkAndGetIfGreaterThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isLessThan
public static boolean isLessThan(int value, int threshold)Checks if the value passed as argument is less than the threshold passed as argument (inclusive).- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
trueif the value is less than the threshold (inclusive)
-
checkIfLessThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message
-
checkAndGetIfLessThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isBetween
public 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).- Parameters:
value- value to be checkedminimum- minimum limit to compare to the valuemaximum- maximum limit to compare to the value- Returns:
trueif the value passed as argument is between minimum and maximum values, passed as argument (inclusive)
-
checkIfBetween
public 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 aIllegalArgumentException.- Parameters:
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 message
-
checkAndGetIfBetween
public 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 aIllegalArgumentException.- Parameters:
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 message- Returns:
- the value passed as argument
-
checkIfValid
public static void checkIfValid(double value, String what)Checks if value passed as argument is valid.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
checkAndGetIfValid
public static double checkAndGetIfValid(double value, String what)Checks if value passed as argument is valid and, if valid, returns the argument.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isPositive
public static boolean isPositive(double value)
Checks if value passed as argument is a positive number (zero is included).- Parameters:
value- value to be checked- Returns:
trueif the value is positive number (zero is included)
-
checkIfPositive
public static void checkIfPositive(double value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
checkAndGetIfPositive
public static double checkAndGetIfPositive(double value, String what)Checks if value passed as argument is a positive number (zero is included).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isNegative
public static boolean isNegative(double value)
Checks if value passed as argument is a negative number (zero is excluded).- Parameters:
value- value to be checked- Returns:
trueif the value is positive number (zero is excluded)
-
checkIfNegative
public static void checkIfNegative(double value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
checkAndGetIfNegative
public static double checkAndGetIfNegative(double value, String what)Checks if value passed as argument is a negative number (zero is excluded).
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isNotEqualTo
public static boolean isNotEqualTo(double value, double target)Checks if both values passed as argument are not equals.- Parameters:
value- value to be checkedtarget- value to be compared to the value- Returns:
trueif the arguments are not equals
-
checkIfNotEqualTo
public static void checkIfNotEqualTo(double value, double target, String what)Checks if both values passed as argument are not equals.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedtarget- value to be compared to the valuewhat- name of the value to put in the exception message
-
isEqualTo
public static boolean isEqualTo(double value, double target)Checks if both values passed as argument are equals.- Parameters:
value- value to be checkedtarget- value to be compared to the value- Returns:
trueif the arguments are equals
-
checkIfEqualTo
public static void checkIfEqualTo(double value, double target, String what)Checks if both values passed as argument are equals.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedtarget- value to be compared to the valuewhat- name of the value to put in the exception message
-
isGreaterThan
public static boolean isGreaterThan(double value, double threshold)Checks if the value passed as argument is greater than the threshold passed as argument (inclusive).- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
trueif the value is greater than the threshold (inclusive)
-
checkIfGreaterThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message
-
checkAndGetIfGreaterThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isLessThan
public static boolean isLessThan(double value, double threshold)Checks if the value passed as argument is less than the threshold passed as argument (inclusive).- Parameters:
value- value to be checkedthreshold- value to be compared to the value- Returns:
trueif the value is less than the threshold (inclusive)
-
checkIfLessThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message
-
checkAndGetIfLessThan
public 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 aIllegalArgumentException.- Parameters:
value- value to be checkedthreshold- value to be compared to the valuewhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
isBetween
public 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).- Parameters:
value- value to be checkedminimum- minimum limit to compare to the valuemaximum- maximum limit to compare to the value- Returns:
trueif the value passed as argument is between minimum and maximum values, passed as argument (inclusive
-
checkIfBetween
public 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 aIllegalArgumentException.- Parameters:
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 message
-
checkAndGetIfBetween
public 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 aIllegalArgumentException.- Parameters:
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 message- Returns:
- the value passed as argument
-
validOrDefault
public static <T> T validOrDefault(T value, T defaultValue)Checks if the value is a consistent object and returns it. If not a consistent object, returns the default.- Type Parameters:
T- type of the object to check- Parameters:
value- value to be checkeddefaultValue- value to return if the value is not a consistent object- Returns:
- the value passed as argument if is a consistent object or the default.
-
checkIfValid
public static void checkIfValid(Object value, String what)
Checks if value passed as argument is valid.
If not, throw aIllegalArgumentException.- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message
-
checkAndGetIfValid
public 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 aIllegalArgumentException.- Type Parameters:
T- type of the value to be checked- Parameters:
value- value to be checkedwhat- name of the value to put in the exception message- Returns:
- the value passed as argument
-
-