org.eclipse.viatra.addon.validation.core

## Class Constraint

- java.lang.Object
- - org.eclipse.viatra.addon.validation.core.Constraint

- All Implemented Interfaces:
    IConstraint

      public class Constraint
      extends java.lang.Object
      implements IConstraint

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Constraint(IConstraintSpecification specification, ValidationEngine validationEngine, org.apache.log4j.Logger logger)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addListener(ConstraintListener listener)` Adds the given listener to the list of listeners to be notified on specific events regarding the constraint.
    `boolean` | `addListener(ConstraintListener listener, IViolationFilter filter)` Adds the given listener to the list of listeners to be notified on specific events regarding the constraint.
    `protected void` | `addViolation(ViolationKey key, Violation violation)`
    `java.util.Set<ConstraintListener>` | `getListeners()` Returns the listeners registered for the constraint.
    `protected RuleSpecification<IPatternMatch>` | `getRuleSpecification()`
    `IConstraintSpecification` | `getSpecification()` Returns the constraint specification from which the constraint was instantiated on the validation engine.
    `java.util.Collection<IViolation>` | `getStoredViolations()` Returns the violations stored by the constraint.
    `protected ValidationEngine` | `getValidationEngine()`
    `protected Violation` | `getViolation(ViolationKey key)`
    `protected ViolationKey` | `getViolationKey(IPatternMatch match)`
    `protected ViolationKey` | `getViolationKey(java.util.Map<java.lang.String,java.lang.Object> keyObjectMap)`
    `java.util.Collection<IViolation>` | `listViolations()` Returns the violations retrieved from the validation engine on demand.
    `java.util.Collection<IViolation>` | `listViolations(IViolationFilter filter)` Returns the violations retrieved from the validation engine on demand and filtered by the provided violation filter.
    `protected void` | `notifyListenersViolationAppeared(Violation violation)`
    `protected void` | `notifyListenersViolationDisappeared(Violation violation)`
    `boolean` | `removeListener(ConstraintListener listener)` Removes the given listener from the list of listeners to be notified on specific events regarding the constraint.
    `protected Violation` | `removeViolation(ViolationKey key)`
    `protected void` | `setRuleSpecification(RuleSpecification<IPatternMatch> ruleSpecification)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Constraint

          protected Constraint(IConstraintSpecification specification,
                               ValidationEngine validationEngine,
                               org.apache.log4j.Logger logger)

  - ### Method Detail

    - #### getSpecification

          public IConstraintSpecification getSpecification()

      Description copied from interface: `IConstraint`
      Returns the constraint specification from which the constraint was instantiated on the validation engine.
      Specified by:
        `getSpecification` in interface `IConstraint`
      Returns:
        The constraint specification.

    - #### getValidationEngine

          protected ValidationEngine getValidationEngine()

    - #### getRuleSpecification

          protected RuleSpecification<IPatternMatch> getRuleSpecification()

    - #### setRuleSpecification

          protected void setRuleSpecification(RuleSpecification<IPatternMatch> ruleSpecification)

    - #### getStoredViolations

          public java.util.Collection<IViolation> getStoredViolations()

      Description copied from interface: `IConstraint`
      Returns the violations stored by the constraint.

      Violations are stored if they have at least one listener registered.

      Specified by:
        `getStoredViolations` in interface `IConstraint`
      Returns:
        The Collection of stored Violations.

    - #### addViolation

          protected void addViolation(ViolationKey key,
                                      Violation violation)

    - #### getViolation

          protected Violation getViolation(ViolationKey key)

    - #### removeViolation

          protected Violation removeViolation(ViolationKey key)

    - #### listViolations

          public java.util.Collection<IViolation> listViolations()

      Description copied from interface: `IConstraint`
      Returns the violations retrieved from the validation engine on demand.
      Specified by:
        `listViolations` in interface `IConstraint`
      Returns:
        The Collection of violations.

    - #### listViolations

          public java.util.Collection<IViolation> listViolations(IViolationFilter filter)

      Description copied from interface: `IConstraint`
      Returns the violations retrieved from the validation engine on demand and filtered by the provided violation filter.
      Specified by:
        `listViolations` in interface `IConstraint`
      Parameters:
        `filter` - The violation filter instance to be used to filter the retrieved violations.
      Returns:
        The Collection of violations after applying the filter.

    - #### getListeners

          public java.util.Set<ConstraintListener> getListeners()

      Description copied from interface: `IConstraint`
      Returns the listeners registered for the constraint.
      Specified by:
        `getListeners` in interface `IConstraint`
      Returns:
        The Collection of listeners registered for the constraint.

    - #### addListener

          public boolean addListener(ConstraintListener listener)

      Description copied from interface: `IConstraint`
      Adds the given listener to the list of listeners to be notified on specific events regarding the constraint.
      Specified by:
        `addListener` in interface `IConstraint`
      Parameters:
        `listener` - The listener to be registered.

    - #### addListener

          public boolean addListener(ConstraintListener listener,
                                     IViolationFilter filter)

      Description copied from interface: `IConstraint`
      Adds the given listener to the list of listeners to be notified on specific events regarding the constraint.
      Specified by:
        `addListener` in interface `IConstraint`
      Parameters:
        `listener` - The listener to be registered.
      Returns:
        `true` if the listener was not registered before.

    - #### removeListener

          public boolean removeListener(ConstraintListener listener)

      Description copied from interface: `IConstraint`
      Removes the given listener from the list of listeners to be notified on specific events regarding the constraint.
      Specified by:
        `removeListener` in interface `IConstraint`
      Parameters:
        `listener` - The listener to be deregistered.
      Returns:
        `true` if the listener was in fact registered.

    - #### notifyListenersViolationAppeared

          protected void notifyListenersViolationAppeared(Violation violation)

    - #### notifyListenersViolationDisappeared

          protected void notifyListenersViolationDisappeared(Violation violation)

    - #### getViolationKey

          protected ViolationKey getViolationKey(IPatternMatch match)

    - #### getViolationKey

          protected ViolationKey getViolationKey(java.util.Map<java.lang.String,java.lang.Object> keyObjectMap)