@OpenApiAll public abstract class DiagramValidator extends java.lang.Object implements ValidationRule
Constructor and Description |
---|
DiagramValidator() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
acceptDiagram(DiagramPresentationElement diagram) |
void |
dispose()
Unregisters all listeners that were registered and releases other resources.
|
abstract java.util.Set<Annotation> |
getAnnotations(Project project,
Constraint constraint)
|
protected java.util.Collection<DiagramPresentationElement> |
getDiagrams() |
protected java.util.stream.Stream<DiagramPresentationElement> |
getDiagramsStream() |
protected java.util.List<PresentationElement> |
getPresentationElements(Element element) |
protected Project |
getProject()
Get the project.
|
void |
init(Project project,
Constraint constraint)
This is the first method that is invoked on the implementation of
the
ValidationRule interface. |
boolean |
isElementInScope(Element element)
If DiagramValidator is to be used in passive validation, then model part to validate can be selected.
|
boolean |
needsRun()
Returns whether the validation rule needs to run.
|
protected boolean |
needsRun(java.beans.PropertyChangeEvent event)
Check if validator needs to re-run after given change event occurred.
|
java.util.Set<Annotation> |
run(Project project,
Constraint constraint)
Run the validation.
|
protected void |
setNeedsRun(boolean run)
Sets flag if this validator has to be re-run, meaning if
getAnnotations(Project, Constraint) method should be called again. |
(package private) void |
setScopeProvider(com.nomagic.magicdraw.validation.ScopeProvider scopeProvider) |
public void init(Project project, Constraint constraint)
ValidationRule
ValidationRule
interface. Implementation can initialize
internal state if required.init
in interface ValidationRule
project
- a project of the constraint.constraint
- a constraint object.protected boolean needsRun(java.beans.PropertyChangeEvent event)
event
- event occurred.public final java.util.Set<Annotation> run(Project project, Constraint constraint)
ValidationRule
run
in interface ValidationRule
project
- a project of the constraint.constraint
- a constraint object.Annotation
objects.public abstract java.util.Set<Annotation> getAnnotations(Project project, Constraint constraint)
Annotation
object for each Element
or PresentationElement
which should be annotated.
Only the elements represented in diagrams returned by getDiagrams()
method should be analyzed.project
- currently active projectconstraint
- a validation rule or a legend item. Use this element to construct Annotation
objects.public boolean needsRun()
ValidationRule
needsRun
in interface ValidationRule
protected void setNeedsRun(boolean run)
getAnnotations(Project, Constraint)
method should be called again.
Actual re-run is done by the validation engine.run
- true to mark validator for rerunpublic void dispose()
dispose
in interface ValidationRule
protected Project getProject()
protected final java.util.stream.Stream<DiagramPresentationElement> getDiagramsStream()
getDiagrams()
method. Convenience method.protected final java.util.Collection<DiagramPresentationElement> getDiagrams()
getAnnotations(Project, Constraint)
method.protected boolean acceptDiagram(DiagramPresentationElement diagram)
getDiagrams()
methodprotected java.util.List<PresentationElement> getPresentationElements(Element element)
element
- element to get presentation elements forvoid setScopeProvider(com.nomagic.magicdraw.validation.ScopeProvider scopeProvider)
public boolean isElementInScope(Element element)
element
- element which is used in any of the diagrams in scope