Interface ValidatorBuilder
public interface ValidatorBuilder
An interface joining multiple sub-interfaces building a processing message.
-
Method Summary
Modifier and TypeMethodDescription@NotNull ContextInfoBuilderbuildContextInfo(@NotNull String name) Contextual info builder with minimal required information - the name of the parameter.@NotNull ProcessingExceptionBuilderbuildException(@NotNull ProcessingMessage message) Constructor with specified message.@NotNull ProcessingExceptionBuilderbuildException(@NotNull ProcessingMessage message, @NotNull Throwable cause) Constructor with a message and concrete cause of this exception.@NotNull ProcessingExceptionBuilderbuildException(@NotNull String code, @Nullable Object... params) @NotNull ProcessingMessageBuilder<Optional<ProcessingMessage>> buildProcessingMessage(@NotNull I18nMessage message) Processing message builder from a localized message.@NotNull ProcessingMessageBuilder<Optional<ProcessingMessage>> buildProcessingMessage(@NotNull String code, @Nullable Object... params) Processing message with additional information.@NotNull Optional<ContextInfo> createContextInfo(@NotNull String name, @Nullable ContextValue context) Constructor withnameand invalidvalue.@NotNull Optional<ContextInfo> createContextInfo(@NotNull String name, @Nullable ContextValue context, @Nullable I18nMessage message) Constructor for full contextual info specification.@NotNull Optional<ProcessingException> createException(@NotNull ProcessingMessage message) Build exception with specified message.@NotNull Optional<ProcessingException> createException(@NotNull ProcessingMessage message, @NotNull Throwable cause) Build exception with a message and concrete cause of this exception.@NotNull Optional<ProcessingException> createException(@NotNull String code, @Nullable Object... params) Build exception with base code and message parameters.@NotNull Optional<ProcessingMessage> createMessage(@NotNull I18nMessage message) Builds a processing message from a localized message.@NotNull Optional<ProcessingMessage> createMessage(@NotNull String code, @Nullable Object... params) Builds a processing message with additional information.voidthrowException(@NotNull ProcessingException exception) Build exception with a message and concrete cause of this exception.voidthrowException(@NotNull ProcessingMessage message) Build exception with specified message.voidthrowException(@NotNull ProcessingMessage message, @NotNull Throwable cause) Build exception with a message and concrete cause of this exception.voidthrowException(@NotNull String code, @Nullable Object... params) Throws exception with base code and message parameters.
-
Method Details
-
buildException
@NotNull @NotNull ProcessingExceptionBuilder buildException(@NotNull @NotNull String code, @Nullable @Nullable Object... params) -
buildException
@NotNull @NotNull ProcessingExceptionBuilder buildException(@NotNull @NotNull ProcessingMessage message) Constructor with specified message.- Parameters:
message- Error message of the exception.- Returns:
- An instance of this builder.
-
buildException
@NotNull @NotNull ProcessingExceptionBuilder buildException(@NotNull @NotNull ProcessingMessage message, @NotNull @NotNull Throwable cause) Constructor with a message and concrete cause of this exception.- Parameters:
message- Response message of the exception.cause- The throwable that caused thisProcessingExceptionto get thrown.- Returns:
- An instance of this builder.
-
createException
@NotNull @NotNull Optional<ProcessingException> createException(@NotNull @NotNull String code, @Nullable @Nullable Object... params) Build exception with base code and message parameters.- Parameters:
code- Thecodethat may reference message in localization property file. When no such localized message withcodehas been found, the code itself is used as message.params- list of parameters needed for construction of localized message. If the last parameter isThrowable, it is used as cause of this exception.- Returns:
- A
ProcessingExceptionif the condition for building wastrue. OtherwiseOptional.empty()is returned.
-
createException
@NotNull @NotNull Optional<ProcessingException> createException(@NotNull @NotNull ProcessingMessage message) Build exception with specified message.- Parameters:
message- Error message of the exception.- Returns:
- A
ProcessingExceptionif the condition for building wastrue. OtherwiseOptional.empty()is returned.
-
createException
@NotNull @NotNull Optional<ProcessingException> createException(@NotNull @NotNull ProcessingMessage message, @NotNull @NotNull Throwable cause) Build exception with a message and concrete cause of this exception.- Parameters:
message- A message of the exception.cause- The throwable that caused thisProcessingExceptionto get thrown.- Returns:
- A
ProcessingExceptionif the condition for building wastrue. OtherwiseOptional.empty()is returned.
-
throwException
Throws exception with base code and message parameters.- Parameters:
code- Thecodethat may reference message in localization property file. When no such localized message withcodehas been found, the code itself is used as message.params- list of parameters needed for construction of localized message. If the last parameter isThrowable, it is used as cause of this exception.- Throws:
ProcessingException- if the condition for building wastrue. Otherwise do nothing.
-
throwException
Build exception with specified message.- Parameters:
message- Error message of the exception.- Throws:
ProcessingException- if the condition for building wastrue. Otherwise do nothing.
-
throwException
Build exception with a message and concrete cause of this exception.- Parameters:
message- A message of the exception.cause- The throwable that caused thisProcessingExceptionto get thrown.- Throws:
ProcessingException- if the condition for building wastrue. Otherwise do nothing.
-
throwException
Build exception with a message and concrete cause of this exception.- Parameters:
exception- An exception to throw.- Throws:
ProcessingException- if the condition for building wastrue. Otherwise do nothing.
-
buildProcessingMessage
@NotNull @NotNull ProcessingMessageBuilder<Optional<ProcessingMessage>> buildProcessingMessage(@NotNull @NotNull String code, @Nullable @Nullable Object... params) Processing message with additional information.- Parameters:
code- The code reference in the localization property file.params- Parameters that needs to be provided to properly format the message with all. parameters.- Returns:
- An instance of this builder.
-
buildProcessingMessage
@NotNull @NotNull ProcessingMessageBuilder<Optional<ProcessingMessage>> buildProcessingMessage(@NotNull @NotNull I18nMessage message) Processing message builder from a localized message.- Parameters:
message- A localized message.- Returns:
- An instance of this builder.
-
createMessage
@NotNull @NotNull Optional<ProcessingMessage> createMessage(@NotNull @NotNull String code, @Nullable @Nullable Object... params) Builds a processing message with additional information.- Parameters:
code- The code reference in the localization property file.params- Parameters that needs to be provided to properly format the message with all. parameters.- Returns:
- An
Optional.of(Object)holding value in the case it was built;Optional.empty()otherwise.
-
createMessage
Builds a processing message from a localized message.- Parameters:
message- A localized message.- Returns:
- An
Optional.of(Object)holding message in the case it was built;Optional.empty()otherwise.
-
buildContextInfo
Contextual info builder with minimal required information - the name of the parameter.- Parameters:
name- Name of the parameter, property or validated field. E.g. email, name.- Returns:
- The new builder instance.
-
createContextInfo
@NotNull @NotNull Optional<ContextInfo> createContextInfo(@NotNull @NotNull String name, @Nullable @Nullable ContextValue context) Constructor withnameand invalidvalue.- Parameters:
name- Constructor with the only name of the parameter.context- An incorrect value that has caused the message to be produced.- Returns:
- An
Optional.of(Object)holding value in the case it was built;Optional.empty()otherwise.
-
createContextInfo
@NotNull @NotNull Optional<ContextInfo> createContextInfo(@NotNull @NotNull String name, @Nullable @Nullable ContextValue context, @Nullable @Nullable I18nMessage message) Constructor for full contextual info specification.- Parameters:
name- Constructor with the only name of the parameter.context- An incorrect value that has caused the message to be produced.message- Additional explanatory message referring to the parameter. H.g.: "E-mail address 'info@@i18n.church' contains invalid character at position [6]."- Returns:
- An
Optional.of(Object)holding value in the case it was built;Optional.empty()otherwise.
-