Class PropertiesQuestion.IntConstraints

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean custom
      Is the user allowed to supply their own value or are they required to use one of the suggestions?
      protected int[] suggestions
      Suggested values for this value's response.
    • Constructor Summary

      Constructors 
      Constructor Description
      IntConstraints()  
      IntConstraints​(int... suggestions)
      Construct with suggested values for the user.
      IntConstraints​(int min, int max)
      Construct with defined upper and lower value boundaries.
      IntConstraints​(int min, int max, int... suggestions)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLowerBound()
      Get the lower bound which specifies the minimum possible value to be considered a valid response from the user.
      int[] getSuggestions()
      Get the suggested values.
      int getUpperBound()
      Get the upper bound which specifies the maximum possible value to be considered a valid response from the user.
      boolean isCustomValuesAllowed()
      Are custom user values allowed?
      java.lang.String isValid​(int v)
      Is the given value valid for this field?
      java.lang.String isValid​(java.lang.String v)
      Is the given value valid for this field? The basic check for validity is to see if the given string can be parsed as an integer value in the current locale.
      void setBounds​(int min, int max)
      Set the max/min possible value that should be considered valid.
      void setCustomValuesAllowed​(boolean state)
      Are user specified values allowed? If not, there must be suggestions present.
      void setSuggestions​(int... sugs)
      Supply some possible values that the user may want to select from.
      • Methods inherited from class java.lang.Object

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

      • suggestions

        protected int[] suggestions
        Suggested values for this value's response.
      • custom

        protected boolean custom
        Is the user allowed to supply their own value or are they required to use one of the suggestions?
    • Constructor Detail

      • IntConstraints

        public IntConstraints()
      • IntConstraints

        public IntConstraints​(int min,
                              int max)
        Construct with defined upper and lower value boundaries.
        Parameters:
        min - Minimum valid response value (inclusive).
        max - Maximum valid response value (inclusive).
      • IntConstraints

        public IntConstraints​(int... suggestions)
        Construct with suggested values for the user.
        Parameters:
        suggestions - Predefined values for the user to choose from.
        See Also:
        setCustomValuesAllowed(boolean)
      • IntConstraints

        public IntConstraints​(int min,
                              int max,
                              int... suggestions)
        Parameters:
        min - Minimum valid response value (inclusive).
        max - Maximum valid response value (inclusive).
        suggestions - Predefined values for the user to choose from.
        See Also:
        setBounds(int, int)
    • Method Detail

      • setBounds

        public void setBounds​(int min,
                              int max)
        Set the max/min possible value that should be considered valid. The range in inclusive. The defaults are the MIN and MAX values for the integer type, except the minimum value itself, which is reserved.
        See Also:
        getLowerBound(), getUpperBound()
      • getLowerBound

        public int getLowerBound()
        Get the lower bound which specifies the minimum possible value to be considered a valid response from the user.
        Returns:
        Minimum boundary (inclusive).
      • getUpperBound

        public int getUpperBound()
        Get the upper bound which specifies the maximum possible value to be considered a valid response from the user.
        Returns:
        Maximum boundary (inclusive).
      • getSuggestions

        public int[] getSuggestions()
        Get the suggested values. Not a copy, do not alter the array.
      • setSuggestions

        public void setSuggestions​(int... sugs)
        Supply some possible values that the user may want to select from.
      • setCustomValuesAllowed

        public void setCustomValuesAllowed​(boolean state)
        Are user specified values allowed? If not, there must be suggestions present.
        Throws:
        java.lang.IllegalStateException - If no suggestions have been provided.
        See Also:
        setSuggestions(int...)
      • isValid

        public java.lang.String isValid​(java.lang.String v)
        Is the given value valid for this field? The basic check for validity is to see if the given string can be parsed as an integer value in the current locale.
        Overrides:
        isValid in class PropertiesQuestion.ValueConstraints
        Parameters:
        v - The value to check.
        Returns:
        Null if the valid is valid, a localized reason string otherwise.
        See Also:
        PropertiesQuestion.getInvalidKeys()
      • isValid

        public java.lang.String isValid​(int v)
        Is the given value valid for this field?
        Returns:
        Null if the valid is valid, a localized reason string otherwise.