Representation of the Contains Constraint. Evaluates to true only if the left side fact is defined in the match context. If the left side is not defined, this will evaluate to False. Contains is typically used to check membership of a value in a group fact.
ContainsConstraint(): Constructs a default constraint.
Exactly match the left and right sides of operation.
If possible, performs a regular expresion matching by treating the right side of the operation as a regular expression.This is only considered for String arguments.
If possible, performs a glob-style matching by treating the right side of the operation as a glob expression. This is only considered for String arguments.
See BinaryConstraint.
Overrides: validate in class BinaryConstraint.
getMatchMode, setMatchMode
See BinaryConstraint.
getFact, getFactValue, getReason, getValue, setFact, setFactValue, setReason, setValue
See Constraint.
Example of building a ContainsConstraint to constrain that a resource belongs to a group:
c = ContainsConstraint() c.setFact("resource.groups") c.setValue("webserver-group")
This constraint can be used independently or added to a AndConstraint>, OrConstraint, NotConstraint to combine with other constraints.
Javadoc: ContainsConstraint