public class Constraint extends java.lang.Object implements IConstraint
Modifier | Constructor and Description |
---|---|
protected |
Constraint(IConstraintSpecification specification,
ValidationEngine validationEngine,
org.apache.log4j.Logger logger) |
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) |
protected Constraint(IConstraintSpecification specification, ValidationEngine validationEngine, org.apache.log4j.Logger logger)
public IConstraintSpecification getSpecification()
IConstraint
getSpecification
in interface IConstraint
protected ValidationEngine getValidationEngine()
protected RuleSpecification<IPatternMatch> getRuleSpecification()
protected void setRuleSpecification(RuleSpecification<IPatternMatch> ruleSpecification)
public java.util.Collection<IViolation> getStoredViolations()
IConstraint
Violations are stored if they have at least one listener registered.
getStoredViolations
in interface IConstraint
protected void addViolation(ViolationKey key, Violation violation)
protected Violation getViolation(ViolationKey key)
protected Violation removeViolation(ViolationKey key)
public java.util.Collection<IViolation> listViolations()
IConstraint
listViolations
in interface IConstraint
public java.util.Collection<IViolation> listViolations(IViolationFilter filter)
IConstraint
listViolations
in interface IConstraint
filter
- The violation filter instance to be used to filter the retrieved violations.public java.util.Set<ConstraintListener> getListeners()
IConstraint
getListeners
in interface IConstraint
public boolean addListener(ConstraintListener listener)
IConstraint
addListener
in interface IConstraint
listener
- The listener to be registered.public boolean addListener(ConstraintListener listener, IViolationFilter filter)
IConstraint
addListener
in interface IConstraint
listener
- The listener to be registered.true
if the listener was not registered before.public boolean removeListener(ConstraintListener listener)
IConstraint
removeListener
in interface IConstraint
listener
- The listener to be deregistered.true
if the listener was in fact registered.protected void notifyListenersViolationAppeared(Violation violation)
protected void notifyListenersViolationDisappeared(Violation violation)
protected ViolationKey getViolationKey(IPatternMatch match)
protected ViolationKey getViolationKey(java.util.Map<java.lang.String,java.lang.Object> keyObjectMap)