Class ExecutionPreconditions
- java.lang.Object
-
- com.exonum.binding.core.service.ExecutionPreconditions
-
public final class ExecutionPreconditions extends Object
Utility methods that helps verifying conditions conducted in expression while transaction execution. If the condition is not met, theExecutionPreconditionsmethod throwsExecutionException.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
All Methods Static Methods Concrete Methods 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 Object errorMessage)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, int arg1)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, int arg1, int arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, int arg1, long arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, int arg1, @Nullable Object arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, long arg1)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, long arg1, int arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, long arg1, long arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, long arg1, @Nullable Object arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, @Nullable Object arg1)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, @Nullable Object arg1, int arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, @Nullable Object arg1, long arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, @Nullable Object arg1, @Nullable Object arg2)Verifies the truth of the given expression.static voidcheckExecution(boolean expression, byte errorCode, @Nullable String errorMessageTemplate, @Nullable Object arg1, @Nullable Object arg2, @Nullable Object arg3)Verifies the truth of the given expression.
-
-
-
Method Detail
-
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 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 String errorMessageTemplate, @Nullable 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 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 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 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 String errorMessageTemplate, int arg1, @Nullable 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 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 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 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 String errorMessageTemplate, long arg1, @Nullable 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 String errorMessageTemplate, @Nullable 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 String errorMessageTemplate, @Nullable 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 String errorMessageTemplate, @Nullable 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 String errorMessageTemplate, @Nullable Object arg1, @Nullable 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 String errorMessageTemplate, @Nullable Object arg1, @Nullable Object arg2, @Nullable Object arg3)Verifies the truth of the given expression.See
checkExecution(boolean, byte, String, Object...)for details.
-
-