Interface ValidationRule

All Known Implementing Classes:
DiagramValidator, OpenedDiagramValidator

@OpenApiAll public interface ValidationRule
Defines interface for all validation rules. This interface should be implemented by classes that:
  1. Want to control whether validation should occur.
  2. Want to control what should be validated.

The implementing class must have a public no-arg constructor. If implementing class is designed for validating model elements then implementer of the class must honor project properties:
  1. Validation scope
  2. Exclude elements from read-only modules
In other words implementer of the class is responsible for correctly implement validating of elements from the specified validation scope and validating or not validating of elements from read-only modules. Also it is responsibility of implementer to detect changes of these properties and providing appropriate validation results. If you need to implement model element validation rule it is more convenient to do by implementing ElementValidationRuleImpl interface.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method will be invoked when instance of the ValidationRule will become no longer needed.
    void
    init(Project project, Constraint constraint)
    This is the first method that is invoked on the implementation of the ValidationRule interface.
    boolean
    Returns whether the validation rule needs to run.
    run(Project project, Constraint constraint)
    Run the validation.
  • Method Details

    • init

      void init(Project project, @CheckForNull Constraint constraint)
      This is the first method that is invoked on the implementation of the ValidationRule interface. Implementation can initialize internal state if required.
      Parameters:
      project - a project of the constraint
      constraint - a constraint object
    • needsRun

      boolean needsRun()
      Returns whether the validation rule needs to run.
      Returns:
      true if validation rule needs to run, otherwise false
    • run

      Set<Annotation> run(Project project, @CheckForNull Constraint constraint)
      Run the validation.
      Parameters:
      project - a project of the constraint
      constraint - a constraint object
      Returns:
      set of Annotation objects
    • dispose

      void dispose()
      This method will be invoked when instance of the ValidationRule will become no longer needed.