Class AbstractNumericOption<T extends Number>

    • Constructor Detail

      • AbstractNumericOption

        protected AbstractNumericOption​(OptionManager owner,
                                        String commandline,
                                        String property,
                                        Object defValue)
        Initializes the option. Will always output the default value.
        Parameters:
        owner - the owner of this option
        commandline - the commandline string to identify the option (no leading dash)
        property - the name of bean property
        defValue - the default value, if null then the owner's current state is used
      • AbstractNumericOption

        protected AbstractNumericOption​(OptionManager owner,
                                        String commandline,
                                        String property,
                                        Object defValue,
                                        T lower,
                                        T upper)
        Initializes the option.
        Parameters:
        owner - the owner of this option
        commandline - the commandline string to identify the option
        property - the name of bean property
        defValue - the default value, if null then the owner's current state is used
        lower - the lower bound (incl; only for numeric values), use null to use unbounded
        upper - the upper bound (incl; only for numeric values), use null to use unbounded
    • Method Detail

      • hasLowerBound

        public boolean hasLowerBound()
        Checks whether a lower bound has been defined for this option.
        Returns:
        true if lower bound exists
      • getLowerBound

        public T getLowerBound()
        Returns the lower bound for this option.
        Returns:
        the lower bound, can be null if none defined
      • hasUpperBound

        public boolean hasUpperBound()
        Checks whether a lower bound has been defined for this option.
        Returns:
        true if lower bound exists
      • getUpperBound

        public T getUpperBound()
        Returns the lower bound for this option.
        Returns:
        the lower bound, can be null if none defined
      • compareValues

        protected boolean compareValues​(Object value,
                                        Object defValue)
        Compares the two values.
        Specified by:
        compareValues in class AbstractArgumentOption
        Parameters:
        value - the value to compare against the default value
        defValue - the default value to compare against
        Returns:
        true if both are equal
      • valueOf

        public T valueOf​(String s)
                  throws Exception
        Turns the string into the appropriate number.
        Specified by:
        valueOf in class AbstractArgumentOption
        Parameters:
        s - the string to parse
        Returns:
        the generated number
        Throws:
        Exception - if parsing of string fails
      • toString

        public String toString​(Object obj)
        Returns a string representation of the specified object.
        Specified by:
        toString in class AbstractArgumentOption
        Parameters:
        obj - the object to turn into a string
        Returns:
        the string representation