Class BuilderUtils

java.lang.Object
org.axonframework.common.BuilderUtils

public final class BuilderUtils extends Object
Utility class containing reusable functionality for implementing the Builder Pattern in (infrastructure) components.
Since:
4.0
Author:
Steven van Beelen
  • Method Details

    • assertThat

      public static <T> void assertThat(T value, Predicate<T> assertion, String exceptionMessage) throws AxonConfigurationException
      Assert that the given value will result to true through the assertion Predicate. If not, an AxonConfigurationException is thrown containing the provided exceptionMessage.
      Type Parameters:
      T - a generic specifying the type of the value, which is the input for the assertion
      Parameters:
      value - a T specifying the value to assert
      assertion - a Predicate to test value against
      exceptionMessage - The message for the exception.
      Throws:
      AxonConfigurationException - if the value asserts to false by the assertion
    • assertNonNull

      public static <T> void assertNonNull(T value, String exceptionMessage) throws AxonConfigurationException
      Assert that the given value is non null. If not, an AxonConfigurationException is thrown containing the provided exceptionMessage.
      Type Parameters:
      T - a generic specifying the type of the value, which is the input for the assertion
      Parameters:
      value - a T specifying the value to assert
      exceptionMessage - The message for the exception.
      Throws:
      AxonConfigurationException - if the value equals null
    • assertPositive

      public static void assertPositive(int i, String exceptionMessage)
      Assert that the given value is positive, meaning greater than, or equal to, zero. If not, an AxonConfigurationException is thrown containing the provided {code exceptionMessage}.
      Parameters:
      i - the value to assert
      exceptionMessage - the message for the exception
    • assertPositive

      public static void assertPositive(long l, String exceptionMessage)
      Assert that the given value is positive, meaning greater than, or equal to, zero. If not, an AxonConfigurationException is thrown containing the provided {code exceptionMessage}.
      Parameters:
      l - the value to assert
      exceptionMessage - the message for the exception
    • assertStrictPositive

      public static void assertStrictPositive(int i, String exceptionMessage)
      Assert that the given value is strictly positive, meaning greater than zero. If not, an AxonConfigurationException is thrown containing the provided {code exceptionMessage}.
      Parameters:
      i - the value to assert
      exceptionMessage - the message for the exception.
    • assertStrictPositive

      public static void assertStrictPositive(long l, String exceptionMessage)
      Assert that the given value is strictly positive, meaning greater than zero. If not, an AxonConfigurationException is thrown containing the provided {code exceptionMessage}.
      Parameters:
      l - the value to assert
      exceptionMessage - the message for the exception.
    • assertNonEmpty

      public static void assertNonEmpty(String string, String exceptionMessage)
      Assert that the given string is not null and does not equal an empty String. If not, an AxonConfigurationException is thrown containing the provided exceptionMessage.
      Parameters:
      string - the value to assert
      exceptionMessage - the message for the exception.
    • assertNonBlank

      public static String assertNonBlank(String string, String exceptionMessage)
      Assert that the given string is not null or blank. If the assertion is not satisfied, an AxonConfigurationException is thrown containing the provided exceptionMessage.
      Parameters:
      string - The value to assert.
      exceptionMessage - The message for the exception.
      Returns:
      The given string when it was not null or blank.