Class ValidationResult


  • public class ValidationResult
    extends Object
    Validation result. Can generally be thought of a collection of validation messages. Allows for quick an painless accumulation of the messages. Also provides ability to combine validation results
    • Constructor Detail

      • ValidationResult

        public ValidationResult()
        Creates empty validation result
    • Method Detail

      • fromMessageIf

        public static final ValidationResult fromMessageIf​(Control target,
                                                           String text,
                                                           Severity severity,
                                                           boolean condition)
        Factory method to create validation result out of one message. Messages with Severity.OK will be ignored.
        Parameters:
        target - validation target
        text - message text
        severity - message severity
        condition - condition on which message will be added to validation result
        Returns:
        New instance of validation result
      • fromErrorIf

        public static final ValidationResult fromErrorIf​(Control target,
                                                         String text,
                                                         boolean condition)
        Factory method to create validation result out of one error
        Parameters:
        target - validation target
        text - message text
        condition - condition on which message will be added to validation result
        Returns:
        New instance of validation result
      • fromWarningIf

        public static final ValidationResult fromWarningIf​(Control target,
                                                           String text,
                                                           boolean condition)
        Factory method to create validation result out of one warning
        Parameters:
        target - validation target
        text - message text
        condition - condition on which message will be added to validation result
        Returns:
        New instance of validation result
      • fromInfoIf

        public static final ValidationResult fromInfoIf​(Control target,
                                                        String text,
                                                        boolean condition)
        Factory method to create validation result out of one info
        Parameters:
        target - validation target
        text - message text
        condition - condition on which message will be added to validation result
        Returns:
        New instance of validation result
      • fromError

        public static final ValidationResult fromError​(Control target,
                                                       String text)
        Factory method to create validation result out of one error
        Parameters:
        target - validation target
        text - message text
        Returns:
        New instance of validation result
      • fromWarning

        public static final ValidationResult fromWarning​(Control target,
                                                         String text)
        Factory method to create validation result out of one warning
        Parameters:
        target - validation target
        text - message text
        Returns:
        New instance of validation result
      • fromInfo

        public static final ValidationResult fromInfo​(Control target,
                                                      String text)
        Factory method to create validation result out of one info
        Parameters:
        target - validation target
        text - message text
        Returns:
        New instance of validation result
      • fromMessages

        public static final ValidationResult fromMessages​(ValidationMessage... messages)
        Factory method to create validation result out of several messages
        Parameters:
        messages -
        Returns:
        New instance of validation result
      • fromMessages

        public static final ValidationResult fromMessages​(Collection<? extends ValidationMessage> messages)
        Factory method to create validation result out of collection of messages
        Parameters:
        messages -
        Returns:
        New instance of validation result
      • fromResults

        public static final ValidationResult fromResults​(ValidationResult... results)
        Factory method to create validation result out of several validation results
        Parameters:
        results - results
        Returns:
        New instance of validation result, combining all into one
      • fromResults

        public static final ValidationResult fromResults​(Collection<ValidationResult> results)
        Factory method to create validation result out of collection of validation results
        Parameters:
        results - results
        Returns:
        New instance of validation result, combining all into one
      • copy

        public ValidationResult copy()
        Creates a copy of validation result
        Returns:
        copy of validation result
      • add

        public ValidationResult add​(ValidationMessage message)
        Add one message to validation result. Messages with Severity.OK will be ignored.
        Parameters:
        message - validation message
        Returns:
        updated validation result
      • addMessageIf

        public ValidationResult addMessageIf​(Control target,
                                             String text,
                                             Severity severity,
                                             boolean condition)
        Add one message to validation result with condition. Messages with Severity.OK will be ignored.
        Parameters:
        target - validation target
        text - message text
        severity - message severity
        condition - condition on which message will be added
        Returns:
        updated validation result
      • addErrorIf

        public ValidationResult addErrorIf​(Control target,
                                           String text,
                                           boolean condition)
        Add one error to validation result with condition
        Parameters:
        target - validation target
        text - message text
        condition - condition on which error will be added
        Returns:
        updated validation result
      • addWarningIf

        public ValidationResult addWarningIf​(Control target,
                                             String text,
                                             boolean condition)
        Add one warning to validation result with condition
        Parameters:
        target - validation target
        text - message text
        condition - condition on which warning will be added
        Returns:
        updated validation result
      • addInfoIf

        public ValidationResult addInfoIf​(Control target,
                                          String text,
                                          boolean condition)
        Add one info to validation result with condition
        Parameters:
        target - validation target
        text - message text
        condition - condition on which info will be added
        Returns:
        updated validation result
      • combine

        public ValidationResult combine​(ValidationResult validationResult)
        Combine validation result with another. This will create a new instance of combined validation result
        Parameters:
        validationResult -
        Returns:
        new instance of combined validation result
      • combineAll

        public ValidationResult combineAll​(Collection<ValidationResult> validationResults)
        Combine validation result with others. This will create a new instance of combined validation result
        Parameters:
        validationResults -
        Returns:
        new instance of combined validation result
      • combineAll

        public ValidationResult combineAll​(ValidationResult... validationResults)
        Combine validation result with others. This will create a new instance of combined validation result
        Parameters:
        validationResults -
        Returns:
        new instance of combined validation result
      • getErrors

        public Collection<ValidationMessage> getErrors()
        Retrieve errors represented by validation result
        Returns:
        an unmodifiable collection of errors
      • getWarnings

        public Collection<ValidationMessage> getWarnings()
        Retrieve warnings represented by validation result
        Returns:
        an unmodifiable collection of warnings
      • getInfos

        public Collection<ValidationMessage> getInfos()
        Retrieve infos represented by validation result
        Returns:
        an unmodifiable collection of infos
      • getMessages

        public Collection<ValidationMessage> getMessages()
        Retrieve all messages represented by validation result
        Returns:
        an unmodifiable collection of messages