Package org.jparsec.internal.util
Class Checks
java.lang.Object
org.jparsec.internal.util.Checks
Common facilities to check precondition, postcondition and invariants.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkArgument
(boolean condition, String message) Checks that an argument satisfies requirement.static void
checkArgument
(boolean condition, String message, 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, String message) Checks thatn
isn't negative.static <T> T
checkNotNull
(T value) Checks thatvalue
cannot be null.static void
checkNotNullState
(Object object, String message) Checks thatobject
is not null.static void
checkNotNullState
(Object object, String message, Object... args) Checks thatobject
is not null.static void
checkState
(boolean condition, String message) Checks a certain state.static void
checkState
(boolean condition, String message, Object... args) Checks a certain state.
-
Constructor Details
-
Checks
public Checks()
-
-
Method Details
-
checkNotNull
Checks thatvalue
cannot be null.- Throws:
NullPointerException
-
checkArgument
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:
IllegalArgumentException
- ifcondition
is false
-
checkArgument
public static void checkArgument(boolean condition, String message, Object... args) throws 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:
IllegalArgumentException
- ifcondition
is false
-
checkState
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:
IllegalStateException
- ifcondition
is false
-
checkState
public static void checkState(boolean condition, String message, Object... args) throws 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:
IllegalStateException
- ifcondition
is false
-
checkNotNullState
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:
IllegalStateException
- ifobject
is null
-
checkNotNullState
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:
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
-