Class DefaultValidationRuleImpl

    • Constructor Detail

      • DefaultValidationRuleImpl

        public DefaultValidationRuleImpl()
    • Method Detail

      • init

        public void init​(Project project,
                         Constraint constraint)
        Initializes the instance from specified parameters.
        Specified by:
        init in interface ElementValidationRuleImpl
        Parameters:
        project - project on which model elements the validation rule applies.
        constraint - a constraint object.
      • getListenerConfigurations

        @CheckForNull
        public java.util.Map<java.lang.Class<? extends Element>,​java.util.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:
        getListenerConfigurations in interface SmartListenerConfigProvider
        Returns:
        map of listener configurations by element class type
      • run

        @CheckForNull
        public final java.util.Set<Annotation> run​(Project project,
                                                   Constraint constraint,
                                                   java.util.Collection<? extends Element> elements)
        Performs validation on the specified model elements by using specified constraint.
        Specified by:
        run in interface ElementValidationRuleImpl
        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 Annotation objects that describes violations of the rule.
      • initializeSingleRun

        protected void initializeSingleRun()
        Single run specific rule data can be initialized here.
      • createAnnotation

        protected Annotation createAnnotation​(Element element,
                                              Constraint constraint)
        Default implementation creates an annotation without actions. Derived classes can override the method and return an Annotation object with actions.
        Parameters:
        element - a model element for which Annotation object should be created.
        constraint - the constraint that is violated.
        Returns:
        Annotation object.
      • getInvalidElements

        protected java.util.Collection<? extends Element> getInvalidElements​(Constraint constraint,
                                                                             java.util.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.