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 Description protectedConstraint(IConstraintSpecification specification, ValidationEngine validationEngine, org.apache.log4j.Logger logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddListener(ConstraintListener listener)Adds the given listener to the list of listeners to be notified on specific events regarding the constraint.booleanaddListener(ConstraintListener listener, IViolationFilter filter)Adds the given listener to the list of listeners to be notified on specific events regarding the constraint.protected voidaddViolation(ViolationKey key, Violation violation)java.util.Set<ConstraintListener>getListeners()Returns the listeners registered for the constraint.protected RuleSpecification<IPatternMatch>getRuleSpecification()IConstraintSpecificationgetSpecification()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 ValidationEnginegetValidationEngine()protected ViolationgetViolation(ViolationKey key)protected ViolationKeygetViolationKey(java.util.Map<java.lang.String,java.lang.Object> keyObjectMap)protected ViolationKeygetViolationKey(IPatternMatch match)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 voidnotifyListenersViolationAppeared(Violation violation)protected voidnotifyListenersViolationDisappeared(Violation violation)booleanremoveListener(ConstraintListener listener)Removes the given listener from the list of listeners to be notified on specific events regarding the constraint.protected ViolationremoveViolation(ViolationKey key)protected voidsetRuleSpecification(RuleSpecification<IPatternMatch> ruleSpecification)
-
-
-
Constructor Detail
-
Constraint
protected Constraint(IConstraintSpecification specification, ValidationEngine validationEngine, org.apache.log4j.Logger logger)
-
-
Method Detail
-
getSpecification
public IConstraintSpecification getSpecification()
Description copied from interface:IConstraintReturns the constraint specification from which the constraint was instantiated on the validation engine.- Specified by:
getSpecificationin interfaceIConstraint- 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:IConstraintReturns the violations stored by the constraint.Violations are stored if they have at least one listener registered.
- Specified by:
getStoredViolationsin interfaceIConstraint- 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:IConstraintReturns the violations retrieved from the validation engine on demand.- Specified by:
listViolationsin interfaceIConstraint- Returns:
- The Collection of violations.
-
listViolations
public java.util.Collection<IViolation> listViolations(IViolationFilter filter)
Description copied from interface:IConstraintReturns the violations retrieved from the validation engine on demand and filtered by the provided violation filter.- Specified by:
listViolationsin interfaceIConstraint- 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:IConstraintReturns the listeners registered for the constraint.- Specified by:
getListenersin interfaceIConstraint- Returns:
- The Collection of listeners registered for the constraint.
-
addListener
public boolean addListener(ConstraintListener listener)
Description copied from interface:IConstraintAdds the given listener to the list of listeners to be notified on specific events regarding the constraint.- Specified by:
addListenerin interfaceIConstraint- Parameters:
listener- The listener to be registered.
-
addListener
public boolean addListener(ConstraintListener listener, IViolationFilter filter)
Description copied from interface:IConstraintAdds the given listener to the list of listeners to be notified on specific events regarding the constraint.- Specified by:
addListenerin interfaceIConstraint- Parameters:
listener- The listener to be registered.- Returns:
trueif the listener was not registered before.
-
removeListener
public boolean removeListener(ConstraintListener listener)
Description copied from interface:IConstraintRemoves the given listener from the list of listeners to be notified on specific events regarding the constraint.- Specified by:
removeListenerin interfaceIConstraint- Parameters:
listener- The listener to be deregistered.- Returns:
trueif 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)
-
-