Package org.bitcoinj.base.internal
Class Preconditions
java.lang.Object
org.bitcoinj.base.internal.Preconditions
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <X extends Throwable>
voidEnsures the truth of an expression, throwing a custom exception if untrue.static void
checkArgument
(boolean expression) Ensures the truth of an expression involving one or more parameters to the calling method.static void
checkArgument
(boolean expression, Supplier<String> messageSupplier) Ensures the truth of an expression involving one or more parameters to the calling method.static void
checkState
(boolean expression) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.static void
checkState
(boolean expression, Supplier<String> messageSupplier) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
-
Constructor Details
-
Preconditions
public Preconditions()
-
-
Method Details
-
checkArgument
public static void checkArgument(boolean expression) Ensures the truth of an expression involving one or more parameters to the calling method.- Parameters:
expression
- a boolean expression- Throws:
IllegalArgumentException
- ifexpression
is false
-
checkArgument
Ensures the truth of an expression involving one or more parameters to the calling method.- Parameters:
expression
- a boolean expressionmessageSupplier
- supplier of the detail message to be used in the event that a IllegalArgumentException is thrown- Throws:
IllegalArgumentException
- ifexpression
is false
-
checkState
public static void checkState(boolean expression) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
expression
- a boolean expression- Throws:
IllegalStateException
- ifexpression
is false
-
checkState
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
expression
- a boolean expressionmessageSupplier
- supplier of the detail message to be used in the event that a IllegalStateException is thrown- Throws:
IllegalStateException
- ifexpression
is false
-
check
public static <X extends Throwable> void check(boolean expression, Supplier<? extends X> exceptionSupplier) throws X Ensures the truth of an expression, throwing a custom exception if untrue.- Parameters:
expression
- a boolean expressionexceptionSupplier
- supplier of the exception to be thrown- Throws:
X
- ifexpression
is false
-