Package org.axonframework.common
Class BuilderUtils
java.lang.Object
org.axonframework.common.BuilderUtils
Utility class containing reusable functionality for implementing the Builder Pattern in (infrastructure) components.
- Since:
- 4.0
- Author:
- Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringassertNonBlank(String string, String exceptionMessage) Assert that the givenstringis not null or blank.static voidassertNonEmpty(String string, String exceptionMessage) Assert that the givenstringis not null and does not equal an empty String.static <T> voidassertNonNull(T value, String exceptionMessage) Assert that the givenvalueis non null.static voidassertPositive(int i, String exceptionMessage) Assert that the givenvalueis positive, meaning greater than, or equal to, zero.static voidassertPositive(long l, String exceptionMessage) Assert that the givenvalueis positive, meaning greater than, or equal to, zero.static voidassertStrictPositive(int i, String exceptionMessage) Assert that the givenvalueis strictly positive, meaning greater than zero.static voidassertStrictPositive(long l, String exceptionMessage) Assert that the givenvalueis strictly positive, meaning greater than zero.static <T> voidassertThat(T value, Predicate<T> assertion, String exceptionMessage)
-
Method Details
-
assertThat
public static <T> void assertThat(T value, Predicate<T> assertion, String exceptionMessage) throws AxonConfigurationException Assert that the givenvaluewill result totruethrough theassertionPredicate. If not, anAxonConfigurationExceptionis thrown containing the providedexceptionMessage.- Type Parameters:
T- a generic specifying the type of thevalue, which is the input for theassertion- Parameters:
value- aTspecifying the value to assertassertion- aPredicateto testvalueagainstexceptionMessage- The message for the exception.- Throws:
AxonConfigurationException- if thevalueasserts tofalseby theassertion
-
assertNonNull
public static <T> void assertNonNull(T value, String exceptionMessage) throws AxonConfigurationException Assert that the givenvalueis non null. If not, anAxonConfigurationExceptionis thrown containing the providedexceptionMessage.- Type Parameters:
T- a generic specifying the type of thevalue, which is the input for theassertion- Parameters:
value- aTspecifying the value to assertexceptionMessage- The message for the exception.- Throws:
AxonConfigurationException- if thevalueequalsnull
-
assertPositive
Assert that the givenvalueis positive, meaning greater than, or equal to, zero. If not, anAxonConfigurationExceptionis thrown containing the provided {code exceptionMessage}.- Parameters:
i- the value to assertexceptionMessage- the message for the exception
-
assertPositive
Assert that the givenvalueis positive, meaning greater than, or equal to, zero. If not, anAxonConfigurationExceptionis thrown containing the provided {code exceptionMessage}.- Parameters:
l- the value to assertexceptionMessage- the message for the exception
-
assertStrictPositive
Assert that the givenvalueis strictly positive, meaning greater than zero. If not, anAxonConfigurationExceptionis thrown containing the provided {code exceptionMessage}.- Parameters:
i- the value to assertexceptionMessage- the message for the exception.
-
assertStrictPositive
Assert that the givenvalueis strictly positive, meaning greater than zero. If not, anAxonConfigurationExceptionis thrown containing the provided {code exceptionMessage}.- Parameters:
l- the value to assertexceptionMessage- the message for the exception.
-
assertNonEmpty
Assert that the givenstringis not null and does not equal an empty String. If not, anAxonConfigurationExceptionis thrown containing the providedexceptionMessage.- Parameters:
string- the value to assertexceptionMessage- the message for the exception.
-
assertNonBlank
Assert that the givenstringis not null or blank. If the assertion is not satisfied, anAxonConfigurationExceptionis thrown containing the providedexceptionMessage.- Parameters:
string- The value to assert.exceptionMessage- The message for the exception.- Returns:
- The given
stringwhen it was notnullor blank.
-