Package com.atlassian.bamboo.utils
Class BambooPreconditions
java.lang.Object
com.atlassian.bamboo.utils.BambooPreconditions
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Exception>
voidcheckThat
(boolean condition, @NotNull Function<String, T> exceptionSupplier, @NotNull String errorMessage, @NotNull Object... errorMessageArguments) Check that a condition is met.static <T extends Exception>
voidcheckThat
(boolean condition, @NotNull Function<String, T> exceptionSupplier, @NotNull Supplier<String> errorMessageSupplier) Check that a condition is met.static <T extends Exception>
voidCheck that a condition is met.
-
Method Details
-
checkThat
@Contract("false, _, _, _ -> fail") public static <T extends Exception> void checkThat(boolean condition, @NotNull @NotNull Function<String, T> exceptionSupplier, @NotNull @NotNull String errorMessage, @NotNull @NotNull Object... errorMessageArguments) throws TCheck that a condition is met. If not, an exception will be thrown with the given error message.- Type Parameters:
T
- type of thrown exception- Parameters:
condition
- condition to checkexceptionSupplier
- a function which will be used to instantiate the exception using the given error messageerrorMessage
- error message to pass to thrown exceptionerrorMessageArguments
- arguments used to format the error message (usingString.format(String, Object...)
method)- Throws:
T
- if the condition is not met
-
checkThat
@Contract("false, _, _ -> fail") public static <T extends Exception> void checkThat(boolean condition, @NotNull @NotNull Function<String, T> exceptionSupplier, @NotNull @NotNull Supplier<String> errorMessageSupplier) throws TCheck that a condition is met. If not, an exception will be thrown with the given error message.- Type Parameters:
T
- type of thrown exception- Parameters:
condition
- condition to checkexceptionSupplier
- a function which will be used to instantiate the exception using the given error messageerrorMessageSupplier
- a supplier that provides error message (can be used together with TextProviderUtils.getTextSupplier())- Throws:
T
- if the condition is not met
-
checkThat
@Contract("false, _ -> fail") public static <T extends Exception> void checkThat(boolean condition, @NotNull @NotNull Supplier<T> exceptionSupplier) throws T Check that a condition is met. If not, an exception will be thrown.If an exception with additional error message is preferred, use
checkThat(boolean, Function, String, Object...)
.- Type Parameters:
T
- type of thrown exception- Parameters:
condition
- condition to checkexceptionSupplier
- supplier for the exception to throw- Throws:
T
- if the condition is not met
-