Package com.atlassian.bamboo.utils
Class BambooPreconditions
- java.lang.Object
-
- com.atlassian.bamboo.utils.BambooPreconditions
-
public class BambooPreconditions extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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>
voidcheckThat(boolean condition, @NotNull Supplier<T> exceptionSupplier)
Check that a condition is met.
-
-
-
Method Detail
-
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 T extends Exception
Check 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 metT extends Exception
-
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 T extends Exception
Check 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 metT extends Exception
-
checkThat
@Contract("false, _ -> fail") public static <T extends Exception> void checkThat(boolean condition, @NotNull @NotNull Supplier<T> exceptionSupplier) throws T extends Exception
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 metT extends Exception
-
-