Class DefaultValidationResult.Builder

  • Enclosing class:
    DefaultValidationResult

    public static class DefaultValidationResult.Builder
    extends Object

    A builder class for creating instances of DefaultValidationResult.

    In order to create a new DefaultValidationResult instance, create a builder, call its addErrorMessage() methods, and finally invoke the build() method. This can look as follows:

     DefaultValidationResult vres = new DefaultValidationResult.Builder()
             .addErrorMessage(msg1).addErrorMessage(msg2).build();
     

    • Constructor Detail

      • Builder

        public Builder()
        Creates a new instance of Builder
    • Method Detail

      • addValidationMessage

        public DefaultValidationResult.Builder addValidationMessage​(ValidationMessage msg)
        Adds an object with a validation message to this instance. If the message has the level ERROR, this also means that the validation failed.
        Parameters:
        msg - the message object (must not be null)
        Returns:
        a reference to this builder
        Throws:
        IllegalArgumentException - if the message is null
      • addValidationMessages

        public DefaultValidationResult.Builder addValidationMessages​(Collection<ValidationMessage> msgs)
        Adds all messages stored in the given collection to this object.
        Parameters:
        msgs - the collection with the messages to add (must not be null)
        Returns:
        a reference to this builder
        Throws:
        IllegalArgumentException - if the collection with the messages is null or one of its elements is null
      • build

        public DefaultValidationResult build()
        Returns the DefaultValidationResult defined by this builder.
        Returns:
        the DefaultValidationResult created by this builder
      • reset

        public final void reset()
        Resets this builder. After that definition of a new validation result object can be started.