Class AbstractNumericOption<T extends Number>

    • Field Detail

      • m_LowerBound

        protected T extends Number m_LowerBound
        the lower bound for numeric values.
      • m_UpperBound

        protected T extends Number m_UpperBound
        the upper bound for numeric values.
    • Constructor Detail

      • AbstractNumericOption

        protected AbstractNumericOption​(OptionManager owner,
                                        String commandline,
                                        String property,
                                        Object defValue,
                                        UserMode minUserMode)
        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,
                                        boolean outputDefValue,
                                        UserMode minUserMode)
        Initializes the option.
        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
        outputDefValue - whether to output the default value or not
      • AbstractNumericOption

        protected AbstractNumericOption​(OptionManager owner,
                                        String commandline,
                                        String property,
                                        Object defValue,
                                        T lower,
                                        T upper,
                                        UserMode minUserMode)
        Initializes the option. Will always output the default value.
        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
        minUserMode - the minimum user mode before showing this option
      • AbstractNumericOption

        protected AbstractNumericOption​(OptionManager owner,
                                        String commandline,
                                        String property,
                                        Object defValue,
                                        boolean outputDefValue,
                                        T lower,
                                        T upper,
                                        UserMode minUserMode)
        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
        outputDefValue - whether to output the default value or not
        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
        minUserMode - the minimum user mode before showing this option
    • 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
      • checkBounds

        protected T checkBounds​(T number)
        Checks whether the number is within the specified bounds (if any).
        Parameters:
        number - the number to check
        Returns:
        the default value for this option, if the bounds were defined and the value was outside
      • isValid

        public boolean isValid​(T number)
        Checks whether the number is within the specified bounds (if any). If not, uses the owner's logger to output a warning message.
        Parameters:
        number - the number to check
        Returns:
        the default value for this option, if the bounds were defined and the value was outside
      • 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