Interface ValidationReport

All Known Implementing Classes:
EmptyValidationReport, ImmutableValidationReport, MergedValidationReport

public interface ValidationReport
A report of validation errors that occurred during validation.

A report consists of a collection of messages with a given level. Any message with a level of ValidationReport.Level.ERROR indicates a validation failure.

  • Method Details

    • empty

      static ValidationReport empty()
      Return an empty report.
      Returns:
      an immutable empty report
    • singleton

      Return an unmodifiable report that contains a single message.
      Parameters:
      message - The message to add to the report
      Returns:
      An unmodifiable validation report with a single message
    • from

      Return an unmodifiable report containing all the provided messages
      Parameters:
      messages - The messages to add to the report
      Returns:
      an unmodifiable report containing all the provided messages
    • from

      static ValidationReport from(ValidationReport.Message... messages)
      Return an unmodifiable report containing all the provided messages
      Parameters:
      messages - The messages to add to the report
      Returns:
      an unmodifiable report containing all the provided messages
    • hasErrors

      default boolean hasErrors()
      Return if this validation report contains errors.
      Returns:
      true if a validation error exists; false otherwise.
    • sortedValidationLevels

      default Set<ValidationReport.Level> sortedValidationLevels()
      Return sorted set of levels found during validation
      Returns:
      sorted set of levels, e.g. [ERROR, IGNORE]
    • getMessages

      Get the validation messages on this report.
      Returns:
      The messages recorded on this report
    • merge

      Merges the given validation report with this one, and return a new, unmodifiable report containing the messages from both reports.
      Parameters:
      other - The validation report to merge with this one
      Returns:
      A new, unmodifiable validation report containing all the messages from this report and the other report
    • withAdditionalContext

      ValidationReport withAdditionalContext(ValidationReport.MessageContext context)
      Apply the given additional message context to each message in this validation report, returning a new unmodifiable report.
      Parameters:
      context - The additional context to apply to each message in the report
      Returns:
      A new, unmodifiable validation report containing all of the messages from this report, enhanced with the additional supplied context