Package ml.options

Class OptionData

java.lang.Object
ml.options.OptionData
All Implemented Interfaces:
Constrainable

public class OptionData extends Object implements Constrainable
This class holds all the data for an option. This includes the prefix, the key, the separators (for value and detail options), the multiplicity, and all the other settings describing the option. The class is designed to be only a data container from a user perspective, i. e. the user has access to any data determined by the Options.check() methods, but not access to any of the other methods which are used internally for the operation of the actual check.
  • Method Details

    • isSet

      public boolean isSet()
      Check whether this option has been found on the command line

      Returns:
      A boolean indicating whether this option has been found on the command line
    • getResultCount

      public int getResultCount()
      Get the number of results found for this option, which is number of times the key matched

      Returns:
      The number of results
    • getResultValue

      public String getResultValue(int index)
      Get the value with the given index. The index can range between 0 and getResultCount() - 1. However, only for value options, a non-null value will be returned. Non-value options always return null.

      Parameters:
      index - The index for the desired value

      Returns:
      The option value with the given index
    • getResultValues

      public List<String> getResultValues()
      Return a list of all result values

      Returns:
      A list with all result values
    • getResultDetail

      public String getResultDetail(int index)
      Get the detail with the given index. The index can range between 0 and getResultCount() - 1. However, only for value options which take details, a non-null detail will be returned. Non-value options and value options which do not take details always return null.

      Parameters:
      index - The index for the desired value

      Returns:
      The option detail with the given index
    • getResultDetails

      public List<String> getResultDetails()
      Return a list of all option details

      Returns:
      A list with all option details
    • setValueText

      public OptionData setValueText(String text)
      Set the text to be used for the <value> argument of a value option. This is used in the HelpPrinter output.

      Parameters:
      text - The text used for the <value> argument of a value option

      Returns:
      The option instance itself to allow incovation chaining
    • setDetailText

      public OptionData setDetailText(String text)
      Set the text to be used for the <detail> argument of a value option. This is used in the HelpPrinter output.

      Parameters:
      text - The text used for the <detail> argument of a value option

      Returns:
      The option instance itself to allow incovation chaining
    • setHelpText

      public OptionData setHelpText(String text)
      Set the text describing the purpose of the option. This is used in the HelpPrinter output.

      Parameters:
      text - The text describing the purpose of the option

      Returns:
      The option instance itself to allow incovation chaining
    • getHelpText

      public String getHelpText()
      Return the text describing the purpose of the option

      Returns:
      The text describing the purpose of the option (or an empty string, if that text has not been set)
    • getValueText

      public String getValueText()
      Return the text to be used for the <value> argument of a value option

      Returns:
      The text to be used for the <value> argument of a value option (or a default value if this text has not been set, or if this is not a value option at all)
    • getDetailText

      public String getDetailText()
      Return the text to be used for the <detail> argument of a detail option

      Returns:
      The text to be used for the <detail> argument of a detail option (or a default value if this text has not been set, or if this is not a detail option at all)
    • addConstraint

      public void addConstraint(Constraint constraint)
      Add a constraint for this option

      Specified by:
      addConstraint in interface Constrainable
      Parameters:
      constraint - The Constraint to add
    • getConstraints

      public List<Constraint> getConstraints()
      Get the constraints defined for this option

      Specified by:
      getConstraints in interface Constrainable
      Returns:
      The defined constraints for this option (or null if no constraints have been defined)
    • getSyntax

      public String getSyntax()
      Get the command line syntax for this option. This method accounts for all characteristics of the option such as separators, multiplicity, alternate keys and the like.

      Returns:
      A string with the command line syntax
    • toString

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

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