Class RangeArgumentChoice<T extends Comparable<T>>

java.lang.Object
net.sourceforge.argparse4j.impl.choice.RangeArgumentChoice<T>
Type Parameters:
T - The type to compare.
All Implemented Interfaces:
ArgumentChoice

public class RangeArgumentChoice<T extends Comparable<T>> extends Object implements ArgumentChoice

Choices from given range.

The given value will be checked if it is in range [min, max], inclusive. The min and max are specified in constructor arguments.

  • Constructor Details

    • RangeArgumentChoice

      public RangeArgumentChoice(T min, T max)
      Creates object using range [min, max], inclusive.
      Parameters:
      min - The lowerbound of the range, inclusive.
      max - The upperbound of the range, inclusive.
  • Method Details

    • contains

      public boolean contains(Object val)
      Description copied from interface: ArgumentChoice

      Returns true iff val is valid choice according to this object's constraint.

      If the objects derived from RuntimeException are thrown because of invalid input from command line, subclass must catch these exceptions and return false.

      Specified by:
      contains in interface ArgumentChoice
      Parameters:
      val - The attribute value.
      Returns:
      true or false.
    • textualFormat

      public String textualFormat()
      Description copied from interface: ArgumentChoice

      Return textual representation of this choice.

      This string will be used in help and error messages.

      Specified by:
      textualFormat in interface ArgumentChoice
      Returns:
      The textual representation of this choice.
    • toString

      public String toString()
      Overrides:
      toString in class Object