Package ml.options
Class ExclusiveConstraint
java.lang.Object
ml.options.ExclusiveConstraint
- All Implemented Interfaces:
Constraint
,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 -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Add a constraint to the given option set using the default multiplicity defined for this setstatic void
add
(OptionSet optionSet, Options.Multiplicity multiplicity, String... keys) Add a constraint to the given option setvoid
init
(Constrainable constrainable, List<org.jdom.Element> list) This method is used to initialize this constraint based on data read from an XML configuration file.boolean
The actual check routineboolean
supports
(Constrainable constrainable) Indicates whether a constraint supports a given type ofConstrainable
toString()
This is the overloadedObject.toString()
method
-
Constructor Details
-
ExclusiveConstraint
public ExclusiveConstraint()The public no-org constructor. This is a prereq for all constraints since it is used for initialization based on XML data.
-
-
Method Details
-
init
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
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
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
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
This is the overloadedObject.toString()
method
-