|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.novell.zos.jdl.Constraint com.novell.zos.jdl.BinaryConstraint com.novell.zos.jdl.ContainsConstraint
public class ContainsConstraint
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.
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.
setCompareMode()
when the right hand side (the value) is a List or array
and you want to specify to check for all or any one is contained in the fact. The default
is COMPARE_MODE_AND
which means that all elements in the List or array must match.
Example of checking if a resource name matches any one of a list of names:
contains = ContainsConstraint() contains.setFact("resource.id") contains.setValue( ["web1", "web2", "web3"]) contains.setCompareMode(ContainsConstraint.COMPARE_MODE_OR)
Field Summary | |
---|---|
static int |
COMPARE_MODE_AND
Means all the left and right side values must compare. |
static int |
COMPARE_MODE_EXACT
Indicates that a list or array on the RHS is expected to match a single element of a list/array on the LHS |
static int |
COMPARE_MODE_OR
Means any one of the left and right side values compare. |
Fields inherited from class com.novell.zos.jdl.BinaryConstraint |
---|
MATCH_MODE_EXACT, MATCH_MODE_GLOB, MATCH_MODE_REGEXP |
Constructor Summary | |
---|---|
ContainsConstraint()
|
Method Summary | |
---|---|
int |
getCompareMode()
Retrieve the compare mode of this constraint. |
void |
setCompareMode(int mode)
Set comparison mode of this constraint. |
Methods inherited from class com.novell.zos.jdl.BinaryConstraint |
---|
getMatchMode, setMatchMode |
Methods inherited from class com.novell.zos.jdl.Constraint |
---|
getFact, getFactValue, getReason, getValue, setFact, setFactValue, setReason, setValue |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int COMPARE_MODE_AND
public static final int COMPARE_MODE_OR
public static final int COMPARE_MODE_EXACT
Constructor Detail |
---|
public ContainsConstraint()
Method Detail |
---|
public void setCompareMode(int mode)
COMPARE_MODE_AND
(the default) to mean all the left and right side values must compare.
Use COMPARE_MODE_OR
to mean any one of the left and right side values compare.
Use COMPARE_MODE_EXACT
to indicate that a right side array/list should match a single element of a array/list on the left side
mode
- compare modepublic int getCompareMode()
COMPARE_MODE_AND
or COMPARE_MODE_OR
or COMPARE_MODE_EXACT
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |