Package org.jparsec.internal.util
Class Checks
- java.lang.Object
-
- org.jparsec.internal.util.Checks
-
public final class Checks extends java.lang.ObjectCommon facilities to check precondition, postcondition and invariants.
-
-
Constructor Summary
Constructors Constructor Description Checks()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckArgument(boolean condition, java.lang.String message)Checks that an argument satisfies requirement.static voidcheckArgument(boolean condition, java.lang.String message, java.lang.Object... args)Checks that an argument satisfies requirement.static intcheckMax(int max)Checks thatmaxisn't negative.static intcheckMin(int min)Checks thatminisn't negative.static voidcheckMinMax(int min, int max)Checks that neitherminormaxis negative andmin <= max.static intcheckNonNegative(int n, java.lang.String message)Checks thatnisn't negative.static <T> TcheckNotNull(T value)Checks thatvaluecannot be null.static voidcheckNotNullState(java.lang.Object object, java.lang.String message)Checks thatobjectis not null.static voidcheckNotNullState(java.lang.Object object, java.lang.String message, java.lang.Object... args)Checks thatobjectis not null.static voidcheckState(boolean condition, java.lang.String message)Checks a certain state.static voidcheckState(boolean condition, java.lang.String message, java.lang.Object... args)Checks a certain state.
-
-
-
Method Detail
-
checkNotNull
public static <T> T checkNotNull(T value) throws java.lang.NullPointerExceptionChecks thatvaluecannot be null.- Throws:
java.lang.NullPointerException
-
checkArgument
public static void checkArgument(boolean condition, java.lang.String message) throws java.lang.IllegalArgumentExceptionChecks that an argument satisfies requirement.- Parameters:
condition- the condition that has to be truemessage- the error message ifconditionis falseargs- the arguments to the error message- Throws:
java.lang.IllegalArgumentException- ifconditionis false
-
checkArgument
public static void checkArgument(boolean condition, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentExceptionChecks that an argument satisfies requirement.- Parameters:
condition- the condition that has to be truemessage- the error message ifconditionis falseargs- the arguments to the error message- Throws:
java.lang.IllegalArgumentException- ifconditionis false
-
checkState
public static void checkState(boolean condition, java.lang.String message) throws java.lang.IllegalStateExceptionChecks a certain state.- Parameters:
condition- the condition of the state that has to be truemessage- the error message ifconditionis falseargs- the arguments to the error message- Throws:
java.lang.IllegalStateException- ifconditionis false
-
checkState
public static void checkState(boolean condition, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalStateExceptionChecks a certain state.- Parameters:
condition- the condition of the state that has to be truemessage- the error message ifconditionis falseargs- the arguments to the error message- Throws:
java.lang.IllegalStateException- ifconditionis false
-
checkNotNullState
public static void checkNotNullState(java.lang.Object object, java.lang.String message)Checks thatobjectis not null.- Parameters:
object- the object that cannot be nullmessage- the error message ifconditionis falseargs- the arguments to the error message- Throws:
java.lang.IllegalStateException- ifobjectis null
-
checkNotNullState
public static void checkNotNullState(java.lang.Object object, java.lang.String message, java.lang.Object... args)Checks thatobjectis not null.- Parameters:
object- the object that cannot be nullmessage- the error message ifconditionis falseargs- the arguments to the error message- Throws:
java.lang.IllegalStateException- ifobjectis null
-
checkMinMax
public static void checkMinMax(int min, int max)Checks that neitherminormaxis negative andmin <= max.
-
checkMin
public static int checkMin(int min)
Checks thatminisn't negative.
-
checkMax
public static int checkMax(int max)
Checks thatmaxisn't negative.
-
checkNonNegative
public static int checkNonNegative(int n, java.lang.String message)Checks thatnisn't negative. Or throws anIllegalArgumentExceptionwithmessage.
-
-