Class AbstractValidationResult

java.lang.Object
io.github.mmm.validation.AbstractValidationResult
All Implemented Interfaces:
Localizable, LocalizableObject, Composable<ValidationResult>, ValidationResult, Iterable<ValidationResult>
Direct Known Subclasses:
ComposedValidationFailure, ValidationFailure

public abstract class AbstractValidationResult extends Object implements ValidationResult
Abstract base implementation of ValidationResult.
Since:
1.0.0
  • Constructor Details

    • AbstractValidationResult

      public AbstractValidationResult(String code, String source)
      The constructor.
      Parameters:
      code - the code.
      source - the optional source.
  • Method Details

    • isValid

      public final boolean isValid()
      Specified by:
      isValid in interface ValidationResult
      Returns:
      true if the validation was successful, false otherwise. A successful ValidationResult is always empty. All other methods will not return any resonable result.
    • getSource

      public String getSource()
      Specified by:
      getSource in interface ValidationResult
      Returns:
      the optional validation source describing the origin of the value that has been validated. May be null. If present this may be the filename where the value was read from, an XPath where the value was located in an XML document, the label of a widget of the UI containing the value, etc. This will help to find the problem easier.
    • getCode

      public String getCode()
      Specified by:
      getCode in interface ValidationResult
      Returns:
      the failure code or null if valid. For a single ValidationFailure this will be the ID of the failing Validator. The code is a stable identifier that indicates the type of the failure. It can be used for automated testing in order to make the test-cases independent from the actual message texts so they are maintainable and will not break e.g. if typos are fixed in the messages.
      See Also:
    • appendCode

      protected void appendCode(Appendable buffer, boolean space)
      Parameters:
      buffer - the Appendable where to append the code.
      space - to append an extra space.
    • toString

      public String toString()
      Overrides:
      toString in class Object