Class RangeArgumentChoice<T extends java.lang.Comparable<T>>

  • Type Parameters:
    T - The type to compare.
    All Implemented Interfaces:
    ArgumentChoice

    public class RangeArgumentChoice<T extends java.lang.Comparable<T>>
    extends java.lang.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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private T max_  
      private T min_  
    • Constructor Summary

      Constructors 
      Constructor Description
      RangeArgumentChoice​(T min, T max)
      Creates object using range [min, max], inclusive.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(java.lang.Object val)
      Returns true iff val is valid choice according to this object's constraint.
      java.lang.String textualFormat()
      Return textual representation of this choice.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • min_

        private final T extends java.lang.Comparable<T> min_
      • max_

        private final T extends java.lang.Comparable<T> max_
    • Constructor Detail

      • RangeArgumentChoice

        public RangeArgumentChoice​(T min,
                                   T max)
        Creates object using range [min, max], inclusive.
        Parameters:
        min - The lower bound of the range, inclusive.
        max - The upper bound of the range, inclusive.
    • Method Detail

      • contains

        public boolean contains​(java.lang.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 java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object