Package ml.options
Class ExclusiveConstraint
- java.lang.Object
-
- ml.options.ExclusiveConstraint
-
- All Implemented Interfaces:
Constraint
,XMLConstraint
public class ExclusiveConstraint extends java.lang.Object implements XMLConstraint
A constraint combining one or more options such that just one of them can occur. This type of constraint can only be added to an option set as it combines one or more options.Constraints of this kind are also accounted for in the
DefaultHelpPrinter
to format the output provided.
-
-
Constructor Summary
Constructors Constructor Description ExclusiveConstraint()
The public no-org constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
add(OptionSet optionSet, java.lang.String... keys)
Add a constraint to the given option set using the default multiplicity defined for this setstatic void
add(OptionSet optionSet, Options.Multiplicity multiplicity, java.lang.String... keys)
Add a constraint to the given option setvoid
init(Constrainable constrainable, java.util.List<org.jdom.Element> list)
This method is used to initialize this constraint based on data read from an XML configuration file.boolean
isSatisfied()
The actual check routineboolean
supports(Constrainable constrainable)
Indicates whether a constraint supports a given type ofConstrainable
java.lang.String
toString()
This is the overloadedObject.toString()
method
-
-
-
Method Detail
-
init
public void init(Constrainable constrainable, java.util.List<org.jdom.Element> list)
This method is used to initialize this constraint based on data read from an XML configuration file. The method is invoked internally during setup with the instance ofConstrainable
to which the constraint applies and a list of JDOM elements, which contain the details about the constraint itself.This method initializes the constraint and attaches it to the list of constraints of the
Constrainable
instance.The parameters expected in the XML
<param>
tags for this constraint areName Value Status keys Same as the keys
parameter inadd(OptionSet, Options.Multiplicity, String[])
Required mult Same as the multiplicity
parameter inadd(OptionSet, Options.Multiplicity, String[])
Optional - Specified by:
init
in interfaceXMLConstraint
- Parameters:
constrainable
- TheConstrainable
instance to which this constraint applieslist
- A list of JDOM elements to be used to initialize the constraint. Specifically, these are tags of the form<param name="..." value="..." />
containing key/value pairs with information.
-
add
public static void add(OptionSet optionSet, Options.Multiplicity multiplicity, java.lang.String... keys)
Add a constraint to the given option set- Parameters:
optionSet
- TheOptionSet
to add this constraint tomultiplicity
- TheOptions.Multiplicity
to use for all options tied together by these constraints. AMultiplicity
defined previously for any option contained in this constraint is overridden.keys
- The keys of the options to tie together by this constraint. At least two keys must be given here, and the corresponding options must already be defined in the set.
-
add
public static void add(OptionSet optionSet, java.lang.String... keys)
Add a constraint to the given option set using the default multiplicity defined for this set- Parameters:
optionSet
- TheOptionSet
to add this constraint tokeys
- The keys of the options to tie together by this constraint. At least two keys must be given here, and the corresponding options must already be defined in the set.
-
supports
public boolean supports(Constrainable constrainable)
Indicates whether a constraint supports a given type ofConstrainable
- Specified by:
supports
in interfaceConstraint
- Parameters:
constrainable
-- Returns:
- A boolean to indicate whether this
Constrainable
is supported. This constraint only supportsOptionSet
constrainables
-
isSatisfied
public boolean isSatisfied()
The actual check routine- Specified by:
isSatisfied
in interfaceConstraint
- Returns:
- A boolean indicating whether the constraint is satisfied or not
-
toString
public java.lang.String toString()
This is the overloadedObject.toString()
method- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representing the instance
-
-