Class RuleViolationResult


  • @OpenApiAll
    public class RuleViolationResult
    extends java.lang.Object
    Class for rule violation result storage.
    • Field Detail

      • annotation

        private final Annotation annotation
        Annotation of this violation
      • rule

        @CheckForNull
        private final Constraint rule
        Violated constraint
      • validationRuleSpecification

        @CheckForNull
        private ValidationRuleSpecification validationRuleSpecification
        Validation rule specification;
      • parentRule

        private Constraint parentRule
        Parent rule.
      • parentObject

        @CheckForNull
        private java.lang.Object parentObject
        Parent object.
      • parentRuleInitialized

        private boolean parentRuleInitialized
        Identifies whether the parentRule is initialized.
      • parentObjectInitialized

        private boolean parentObjectInitialized
        Identifies whether the parentObject is initialized.
      • systemRule

        private final boolean systemRule
    • Constructor Detail

      • RuleViolationResult

        public RuleViolationResult​(Annotation annotation,
                                   @CheckForNull
                                   Constraint rule)
        Constructor.
        Parameters:
        annotation - of this violation
        rule - violated constraint
      • RuleViolationResult

        public RuleViolationResult​(Annotation annotation,
                                   @CheckForNull
                                   Constraint rule,
                                   boolean systemRule)
        Constructor.
        Parameters:
        annotation - of this violation
        rule - violated constraint
        systemRule - is system validation rule
    • Method Detail

      • getAnnotation

        public Annotation getAnnotation()
        Returns Annotation of violation.
        Returns:
        annotation of violation.
      • getElement

        @CheckForNull
        public BaseElement getElement()
        Returns target Element
        Returns:
        target element.
      • getTargetObject

        @CheckForNull
        public java.lang.Object getTargetObject()
        Returns target object of the rule violation result.
        Returns:
        target object.
      • getErrorMessage

        public java.lang.String getErrorMessage()
        Violation message or empty String.
        Returns:
        violation message or empty String.
      • getRule

        @CheckForNull
        public Constraint getRule()
        Returns violated rule.
        Returns:
        violated rule.
      • isIgnored

        public boolean isIgnored()
        Checks if this violation result is ignored by user. User can ignore pair of violation - target element & constraint.
        Returns:
        ignored flag.
      • getConstrainedProject

        @CheckForNull
        public Project getConstrainedProject()
        Returns project of the violated constraint
      • getParentRule

        @CheckForNull
        public Constraint getParentRule()
        Returns parent rule if such is specified.
        Returns:
        parent rule or null.
      • getParentObject

        @CheckForNull
        public java.lang.Object getParentObject()
        Returns parent object that should be used for grouping the results.
        Returns:
        parent object.
      • getParentObjectExpression

        @CheckForNull
        private ElementExpression getParentObjectExpression​(Class metaType)
      • getAnnotations

        public static java.util.List<Annotation> getAnnotations​(java.util.Collection results)
        Collects annotations from a list of RuleViolationResult list.
        Parameters:
        results - list of RuleViolationResult objects
        Returns:
        list of Annotation objects
      • isSystemValidationResult

        public boolean isSystemValidationResult()
        If true validation result came from system rule, else false.
        Returns:
        true if validation result came from system rule, else false.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object