Package org.bitcoinj.base.internal
Class Preconditions
- java.lang.Object
-
- org.bitcoinj.base.internal.Preconditions
-
public class Preconditions extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Preconditions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <X extends java.lang.Throwable>
voidcheck(boolean expression, java.util.function.Supplier<? extends X> exceptionSupplier)
Ensures 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, java.util.function.Supplier<java.lang.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, java.util.function.Supplier<java.lang.String> messageSupplier)
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.
-
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- ifexpression
is false
-
checkArgument
public static void checkArgument(boolean expression, java.util.function.Supplier<java.lang.String> messageSupplier)
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:
java.lang.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:
java.lang.IllegalStateException
- ifexpression
is false
-
checkState
public static void checkState(boolean expression, java.util.function.Supplier<java.lang.String> messageSupplier)
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:
java.lang.IllegalStateException
- ifexpression
is false
-
check
public static <X extends java.lang.Throwable> void check(boolean expression, java.util.function.Supplier<? extends X> exceptionSupplier) throws X extends java.lang.Throwable
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 falseX extends java.lang.Throwable
-
-