Record Class ValidationReport

java.lang.Object
java.lang.Record
ch.nexsol.gateway.validation.ValidationReport
Record Components:
errors - the contract violations, in the order they were found

public record ValidationReport(List<String> errors) extends Record
Outcome of validating one message against a contract: the list of the ways it breaks that contract, empty when it honours it.
  • Constructor Details

    • ValidationReport

      public ValidationReport(List<String> errors)
      Creates a report.
      Parameters:
      errors - the contract violations
  • Method Details

    • empty

      public static ValidationReport empty()
      Returns the report of a message that honours its contract.
      Returns:
      an empty report
    • of

      public static ValidationReport of(String... errors)
      Returns a report holding the given violations.
      Parameters:
      errors - the contract violations
      Returns:
      the report
    • and

      public ValidationReport and(ValidationReport other)
      Returns a report holding the violations of both reports.
      Parameters:
      other - the report to merge into this one
      Returns:
      the merged report
    • isValid

      public boolean isValid()
      Returns whether the message honours its contract.
      Returns:
      true when no violation was found
    • describe

      public String describe()
      Renders the violations as a single line, suitable for a log message or an audit attribute.
      Returns:
      the violations joined by "; "
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • errors

      public List<String> errors()
      Returns the value of the errors record component.
      Returns:
      the value of the errors record component