Package org.jparsec.internal.util
Class Checks
- java.lang.Object
-
- org.jparsec.internal.util.Checks
-
public final class Checks extends java.lang.Object
Common 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 void
checkArgument(boolean condition, java.lang.String message)
Checks that an argument satisfies requirement.static void
checkArgument(boolean condition, java.lang.String message, java.lang.Object... args)
Checks that an argument satisfies requirement.static int
checkMax(int max)
Checks thatmax
isn't negative.static int
checkMin(int min)
Checks thatmin
isn't negative.static void
checkMinMax(int min, int max)
Checks that neithermin
ormax
is negative andmin <= max
.static int
checkNonNegative(int n, java.lang.String message)
Checks thatn
isn't negative.static <T> T
checkNotNull(T value)
Checks thatvalue
cannot be null.static void
checkNotNullState(java.lang.Object object, java.lang.String message)
Checks thatobject
is not null.static void
checkNotNullState(java.lang.Object object, java.lang.String message, java.lang.Object... args)
Checks thatobject
is not null.static void
checkState(boolean condition, java.lang.String message)
Checks a certain state.static void
checkState(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.NullPointerException
Checks thatvalue
cannot be null.- Throws:
java.lang.NullPointerException
-
checkArgument
public static void checkArgument(boolean condition, java.lang.String message) throws java.lang.IllegalArgumentException
Checks that an argument satisfies requirement.- Parameters:
condition
- the condition that has to be truemessage
- the error message ifcondition
is falseargs
- the arguments to the error message- Throws:
java.lang.IllegalArgumentException
- ifcondition
is false
-
checkArgument
public static void checkArgument(boolean condition, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalArgumentException
Checks that an argument satisfies requirement.- Parameters:
condition
- the condition that has to be truemessage
- the error message ifcondition
is falseargs
- the arguments to the error message- Throws:
java.lang.IllegalArgumentException
- ifcondition
is false
-
checkState
public static void checkState(boolean condition, java.lang.String message) throws java.lang.IllegalStateException
Checks a certain state.- Parameters:
condition
- the condition of the state that has to be truemessage
- the error message ifcondition
is falseargs
- the arguments to the error message- Throws:
java.lang.IllegalStateException
- ifcondition
is false
-
checkState
public static void checkState(boolean condition, java.lang.String message, java.lang.Object... args) throws java.lang.IllegalStateException
Checks a certain state.- Parameters:
condition
- the condition of the state that has to be truemessage
- the error message ifcondition
is falseargs
- the arguments to the error message- Throws:
java.lang.IllegalStateException
- ifcondition
is false
-
checkNotNullState
public static void checkNotNullState(java.lang.Object object, java.lang.String message)
Checks thatobject
is not null.- Parameters:
object
- the object that cannot be nullmessage
- the error message ifcondition
is falseargs
- the arguments to the error message- Throws:
java.lang.IllegalStateException
- ifobject
is null
-
checkNotNullState
public static void checkNotNullState(java.lang.Object object, java.lang.String message, java.lang.Object... args)
Checks thatobject
is not null.- Parameters:
object
- the object that cannot be nullmessage
- the error message ifcondition
is falseargs
- the arguments to the error message- Throws:
java.lang.IllegalStateException
- ifobject
is null
-
checkMinMax
public static void checkMinMax(int min, int max)
Checks that neithermin
ormax
is negative andmin <= max
.
-
checkMin
public static int checkMin(int min)
Checks thatmin
isn't negative.
-
checkMax
public static int checkMax(int max)
Checks thatmax
isn't negative.
-
checkNonNegative
public static int checkNonNegative(int n, java.lang.String message)
Checks thatn
isn't negative. Or throws anIllegalArgumentException
withmessage
.
-
-