Package com.nomagic.magicdraw.validation
Class DefaultValidationRuleImpl
java.lang.Object
com.nomagic.magicdraw.validation.DefaultValidationRuleImpl
- All Implemented Interfaces:
ElementValidationRuleImpl,SmartListenerConfigProvider
@OpenApiAll
public class DefaultValidationRuleImpl
extends Object
implements ElementValidationRuleImpl, SmartListenerConfigProvider
The class implements validating of a model elements by using OCL or binary implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AnnotationcreateAnnotation(Element element, Constraint constraint) Default implementation creates an annotation without actions.voiddispose()Cleans up used resources of the object.protected Collection<? extends Element>getInvalidElements(Constraint constraint, Collection<? extends Element> elements) Returns invalid elements from the specified collection of elements.Map<Class<? extends Element>,Collection<SmartListenerConfig>> Returns configurations for the rule's expression.voidinit(Project project, Constraint constraint) Initializes the instance from specified parameters.protected voidSingle run specific rule data can be initialized here.final Set<Annotation>run(Project project, Constraint constraint, Collection<? extends Element> elements) Performs validation on the specified model elements by using specified constraint.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.nomagic.magicdraw.validation.ElementValidationRuleImpl
postRun, preRun, preRun
-
Constructor Details
-
DefaultValidationRuleImpl
public DefaultValidationRuleImpl()
-
-
Method Details
-
init
Initializes the instance from specified parameters.- Specified by:
initin interfaceElementValidationRuleImpl- Parameters:
project- project on which model elements the validation rule applies.constraint- a constraint object.
-
getListenerConfigurations
@CheckForNull public Map<Class<? extends Element>,Collection<SmartListenerConfig>> getListenerConfigurations()Returns configurations for the rule's expression. When it returns null - the validation rule is interested in all model element changes.- Specified by:
getListenerConfigurationsin interfaceSmartListenerConfigProvider- Returns:
- map of listener configurations by element class type
-
run
@CheckForNull public final Set<Annotation> run(Project project, Constraint constraint, Collection<? extends Element> elements) Performs validation on the specified model elements by using specified constraint.- Specified by:
runin interfaceElementValidationRuleImpl- Parameters:
project- a project of the constraint.constraint- constraint that should be used to validate model elements.elements- a collection of model elements that needs to be validated.- Returns:
- collection of
Annotationobjects that describes violations of the rule.
-
initializeSingleRun
protected void initializeSingleRun()Single run specific rule data can be initialized here. -
createAnnotation
Default implementation creates an annotation without actions. Derived classes can override the method and return anAnnotationobject with actions.- Parameters:
element- a model element for whichAnnotationobject should be created.constraint- the constraint that is violated.- Returns:
Annotationobject.
-
getInvalidElements
protected Collection<? extends Element> getInvalidElements(Constraint constraint, Collection<? extends Element> elements) Returns invalid elements from the specified collection of elements.- Parameters:
constraint- constraint that specifies validation rules.elements- a collection of elements that need to be validated.- Returns:
- a collection of invalid elements.
-
dispose
public void dispose()Cleans up used resources of the object.- Specified by:
disposein interfaceElementValidationRuleImpl
-