Package ml.options

Class 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 set
      static void add​(OptionSet optionSet, Options.Multiplicity multiplicity, java.lang.String... keys)
      Add a constraint to the given option set
      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.
      boolean isSatisfied()
      The actual check routine
      boolean supports​(Constrainable constrainable)
      Indicates whether a constraint supports a given type of Constrainable
      java.lang.String toString()
      This is the overloaded Object.toString() method
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • 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 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 of Constrainable 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 are

        Name Value Status
        keys Same as the keys parameter in add(OptionSet, Options.Multiplicity, String[]) Required
        mult Same as the multiplicity parameter in add(OptionSet, Options.Multiplicity, String[]) Optional

        Specified by:
        init in interface XMLConstraint
        Parameters:
        constrainable - The Constrainable instance to which this constraint applies
        list - 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 - The OptionSet to add this constraint to
        multiplicity - The Options.Multiplicity to use for all options tied together by these constraints. A Multiplicity 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 - The OptionSet to add this constraint to
        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.
      • supports

        public boolean supports​(Constrainable constrainable)
        Indicates whether a constraint supports a given type of Constrainable

        Specified by:
        supports in interface Constraint
        Parameters:
        constrainable -
        Returns:
        A boolean to indicate whether this Constrainable is supported. This constraint only supports OptionSet constrainables
      • isSatisfied

        public boolean isSatisfied()
        The actual check routine

        Specified by:
        isSatisfied in interface Constraint
        Returns:
        A boolean indicating whether the constraint is satisfied or not
      • toString

        public java.lang.String toString()
        This is the overloaded Object.toString() method

        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representing the instance