Class PropertiesQuestion.FloatConstraints

    • 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 float[] suggestions
      Current value set for the suggested response values.
    • Constructor Summary

      Constructors 
      Constructor Description
      FloatConstraints()  
      FloatConstraints​(float... suggestions)
      Construct with suggestions for the user.
      FloatConstraints​(float min, float max)  
      FloatConstraints​(float min, float max, float... suggestions)
      Construct with both min, max and suggested values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float getLowerBound()
      Get the lower bound which specifies the minimum possible value to be considered a valid response from the user.
      float getResolution()
      Get the resolution for responses to this question.
      float[] getSuggestions()
      Get the suggested values.
      float 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​(float 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 floating point value in the current locale.
      void setBounds​(float min, float 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 setResolution​(float resolution)
      Set the resolution for responses to this question.
      void setSuggestions​(float... 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

      • 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

      • FloatConstraints

        public FloatConstraints()
      • FloatConstraints

        public FloatConstraints​(float min,
                                float max)
        Parameters:
        min - Minimum valid response value.
        max - Maximum valid response value
        See Also:
        setBounds(float, float)
      • FloatConstraints

        public FloatConstraints​(float... suggestions)
        Construct with suggestions for the user.
        Parameters:
        suggestions - Values to suggest to the user. Array should be of length greater than zero.
      • FloatConstraints

        public FloatConstraints​(float min,
                                float max,
                                float... suggestions)
        Construct with both min, max and suggested values.
        Parameters:
        min - Minimum valid response value.
        max - Maximum valid response value
        suggestions - Values to suggest to the user. Array should be of length greater than zero.
        See Also:
        getSuggestions()
    • Method Detail

      • setBounds

        public void setBounds​(float min,
                              float 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 float datatype.
        Parameters:
        min - Minimum valid response value.
        max - Maximum valid response value.
      • getLowerBound

        public float 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 float 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 float[] getSuggestions()
        Get the suggested values. Not a copy, do not alter the array.
        Returns:
        Suggested response values currently set for this question. Null if none have been set.
        See Also:
        setSuggestions(float...)
      • setSuggestions

        public void setSuggestions​(float... sugs)
        Supply some possible values that the user may want to select from.
        Parameters:
        sugs - Suggested values to present the user for this question. Should be an array of length greater than zero.
        See Also:
        getSuggestions()
      • 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(float...)
      • setResolution

        public void setResolution​(float resolution)
        Set the resolution for responses to this question. Responses may be rounded to the nearest multiple of the resolution.
        Parameters:
        resolution - the resolution for responses to this question
        See Also:
        getResolution(), PropertiesQuestion.setValue(java.lang.String)
      • 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 floating point 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​(float v)
        Is the given value valid for this field?
        Returns:
        Null if the valid is valid, a localized reason string otherwise.