Interface ValidatorBuilder


public interface ValidatorBuilder
An interface joining multiple sub-interfaces building a processing message.
  • 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 this ProcessingException to 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 - The code that may reference message in localization property file. When no such localized message with code has been found, the code itself is used as message.
      params - list of parameters needed for construction of localized message. If the last parameter is Throwable, it is used as cause of this exception.
      Returns:
      A ProcessingException if the condition for building was true. Otherwise Optional.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 ProcessingException if the condition for building was true. Otherwise Optional.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 this ProcessingException to get thrown.
      Returns:
      A ProcessingException if the condition for building was true. Otherwise Optional.empty() is returned.
    • throwException

      void throwException(@NotNull @NotNull String code, @Nullable @Nullable Object... params)
      Throws exception with base code and message parameters.
      Parameters:
      code - The code that may reference message in localization property file. When no such localized message with code has been found, the code itself is used as message.
      params - list of parameters needed for construction of localized message. If the last parameter is Throwable, it is used as cause of this exception.
      Throws:
      ProcessingException - if the condition for building was true. Otherwise do nothing.
    • throwException

      void throwException(@NotNull @NotNull ProcessingMessage message)
      Build exception with specified message.
      Parameters:
      message - Error message of the exception.
      Throws:
      ProcessingException - if the condition for building was true. Otherwise do nothing.
    • throwException

      void throwException(@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 this ProcessingException to get thrown.
      Throws:
      ProcessingException - if the condition for building was true. Otherwise do nothing.
    • throwException

      void throwException(@NotNull @NotNull ProcessingException exception)
      Build exception with a message and concrete cause of this exception.
      Parameters:
      exception - An exception to throw.
      Throws:
      ProcessingException - if the condition for building was true. 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

      @NotNull @NotNull Optional<ProcessingMessage> createMessage(@NotNull @NotNull I18nMessage message)
      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

      @NotNull @NotNull ContextInfoBuilder buildContextInfo(@NotNull @NotNull String name)
      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 with name and invalid value.
      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.