Class ExecutionPreconditions
public final class ExecutionPreconditions
extends java.lang.Object
ExecutionPreconditions method
throws ExecutionException.
Consider the following example:
void checkEnoughMoney(long balance, long amount) {
if(balance < amount) {
throw new ExecutionException((byte)3, "Not enough money. Operation amount is " + amount
+ ", but actual balance was " + balance);
}
}
which can be replaced using ExecutionPreconditions:
checkExecution(amount <= balance, (byte)3,
"Not enough money. Operation amount is %s, but actual balance was %s",
amount, balance);
- See Also:
ExecutionException
-
Method Summary
Modifier and Type Method Description static voidcheckExecution(boolean expression, byte errorCode)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.Object errorMessage)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1, int arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1, long arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1, @Nullable java.lang.Object arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1, int arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1, long arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1, @Nullable java.lang.Object arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object... errorMessageArgs)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, int arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, long arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, @Nullable java.lang.Object arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, @Nullable java.lang.Object arg2, @Nullable java.lang.Object arg3)Verifies the truth of the given expression.
-
Method Details
-
checkExecution
public static void checkExecution(boolean expression, byte errorCode)Verifies the truth of the given expression.- Parameters:
expression- a boolean expressionerrorCode- execution error code- Throws:
ExecutionException- ifexpressionis false
-
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.Object errorMessage)Verifies the truth of the given expression.- Parameters:
expression- a boolean expressionerrorCode- execution error codeerrorMessage- execution error description to use if the check fails- Throws:
ExecutionException- ifexpressionis false
-
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object... errorMessageArgs)Verifies the truth of the given expression.- Parameters:
expression- a boolean expressionerrorCode- execution error codeerrorMessageTemplate- execution error description template to use if the check fails. The template could have placeholders%swhich will be replaced by arguments resolved by positionerrorMessageArgs- arguments to be used in the template. Each argument will be converted to string usingString.valueOf(Object)- Throws:
ExecutionException- ifexpressionis false
-
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1, int arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1, long arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, int arg1, @Nullable java.lang.Object arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1, int arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1, long arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, long arg1, @Nullable java.lang.Object arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, int arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, long arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, @Nullable java.lang.Object arg2)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details. -
checkExecution
public static void checkExecution(boolean expression, byte errorCode, @Nullable java.lang.String errorMessageTemplate, @Nullable java.lang.Object arg1, @Nullable java.lang.Object arg2, @Nullable java.lang.Object arg3)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details.
-