Package io.jmix.core.common.util
Class Preconditions
java.lang.Object
io.jmix.core.common.util.Preconditions
Simple static methods to be called at the start of your own methods to verify correct arguments and state.
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidcheckNotEmptyString(String value) Ensures that a string passed as a parameter to the calling method is not empty.static voidcheckNotEmptyString(String value, String errorMessage) Ensures that a string passed as a parameter to the calling method is not empty.static voidcheckNotEmptyString(String value, String errorMessageTemplate, Object... errorMessageArgs) Ensures that a string passed as a parameter to the calling method is not empty.static voidcheckNotNullArgument(Object reference) Ensures that an object reference passed as a parameter to the calling method is not null.static voidcheckNotNullArgument(Object reference, String errorMessage) Ensures that an object reference passed as a parameter to the calling method is not null.static voidcheckNotNullArgument(Object reference, String errorMessageTemplate, Object... errorMessageArgs) Ensures that an object reference passed as a parameter to the calling method is not null.static StringformatExceptionArgs(String template, Object... args) 
- 
Method Details- 
checkNotEmptyStringEnsures that a string passed as a parameter to the calling method is not empty.- Parameters:
- value- string value
- Throws:
- IllegalArgumentException- if- valueis empty
 
- 
checkNotEmptyStringEnsures that a string passed as a parameter to the calling method is not empty.- Parameters:
- value- string value
- errorMessage- the exception message to use if the check fails; will be converted to a string using- String.valueOf(Object)
- Throws:
- IllegalArgumentException- if- valueis empty
 
- 
checkNotEmptyStringpublic static void checkNotEmptyString(@Nullable String value, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) Ensures that a string passed as a parameter to the calling method is not empty.- Parameters:
- value- string value
- errorMessageTemplate- a template for the exception message should the check fail. The message is formed by replacing each- %splaceholder in the template with an argument. These are matched by position - the first- %sgets- errorMessageArgs[0], etc.- Unmatched arguments will be appended to the formatted message in square braces. Unmatched placeholders will be left as-is. 
- errorMessageArgs- the arguments to be substituted into the message template. Arguments are converted to strings using- String.valueOf(Object).
- Throws:
- IllegalArgumentException- if- valueis empty
 
- 
checkNotNullArgumentEnsures that an object reference passed as a parameter to the calling method is not null.- Parameters:
- reference- an object reference
- Throws:
- IllegalArgumentException- if- referenceis null
 
- 
checkNotNullArgumentEnsures that an object reference passed as a parameter to the calling method is not null.- Parameters:
- reference- an object reference
- errorMessage- the exception message to use if the check fails; will be converted to a string using- String.valueOf(Object)
- Throws:
- IllegalArgumentException- if- referenceis null
 
- 
checkNotNullArgumentpublic static void checkNotNullArgument(@Nullable Object reference, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) Ensures that an object reference passed as a parameter to the calling method is not null.- Parameters:
- reference- an object reference
- errorMessageTemplate- a template for the exception message should the check fail. The message is formed by replacing each- %splaceholder in the template with an argument. These are matched by position - the first- %sgets- errorMessageArgs[0], etc. Unmatched arguments will be appended to the formatted message in square braces. Unmatched placeholders will be left as-is.
- errorMessageArgs- the arguments to be substituted into the message template. Arguments are converted to strings using- String.valueOf(Object).
- Throws:
- IllegalArgumentException- if- referenceis null
 
- 
formatExceptionArgs
 
-