com.novell.zos.jdl
Class ContainsConstraint
java.lang.Object
com.novell.zos.jdl.Constraint
com.novell.zos.jdl.BinaryConstraint
com.novell.zos.jdl.ContainsConstraint
public class ContainsConstraint
- extends BinaryConstraint
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.
Use 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_OR
Means any one of the left and right side values compare. |
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 java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
COMPARE_MODE_AND
public static final int COMPARE_MODE_AND
- Means all the left and right side values must compare.
This is the default.
- See Also:
- Constant Field Values
COMPARE_MODE_OR
public static final int COMPARE_MODE_OR
- Means any one of the left and right side values compare.
- See Also:
- Constant Field Values
ContainsConstraint
public ContainsConstraint()
setCompareMode
public void setCompareMode(int mode)
- Set comparison mode of this constraint.
Use 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.
- Parameters:
mode
- compare mode
getCompareMode
public int getCompareMode()
- Retrieve the compare mode of this constraint.
- Returns:
- compare mode
COMPARE_MODE_AND
or COMPARE_MODE_OR
Copyright (c) 2009 Novell, Inc. All rights reserved.