Class BambooPreconditions


  • public class BambooPreconditions
    extends Object
    • 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 check
        exceptionSupplier - a function which will be used to instantiate the exception using the given error message
        errorMessage - error message to pass to thrown exception
        errorMessageArguments - arguments used to format the error message (using String.format(String, Object...) method)
        Throws:
        T - if the condition is not met
        T 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 check
        exceptionSupplier - a function which will be used to instantiate the exception using the given error message
        errorMessageSupplier - a supplier that provides error message (can be used together with TextProviderUtils.getTextSupplier())
        Throws:
        T - if the condition is not met
        T 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 check
        exceptionSupplier - supplier for the exception to throw
        Throws:
        T - if the condition is not met
        T extends Exception