Interface ValueModel<V>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String VALIDATOR_PROPERTY
      The validator bound property.
      static java.lang.String VALUE_PROPERTY
      The value bound property.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clearValue()
      Clears the value by setting the value to null, which may be invalid according to any installed validators.
      V getDefaultValue()  
      Validator<V> getValidator()  
      V getValue()  
      java.lang.Class<V> getValueClass()  
      boolean isValidValue()
      Determines whether the value of this model is valid.
      void resetValue()
      Resets the value to a default value, which may be invalid according to any installed validators.
      void setValidator​(Validator<V> newValidator)
      Sets the validator.
      void setValue​(V newValue)
      Sets the new value.
      void validateValue()
      Validates the value of this model, throwing an exception if the model is not valid.
      • Methods inherited from interface com.globalmentor.beans.PropertyBindable

        addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
      • Methods inherited from interface com.globalmentor.beans.PropertyConstrainable

        addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
    • Field Detail

      • VALIDATOR_PROPERTY

        static final java.lang.String VALIDATOR_PROPERTY
        The validator bound property.
      • VALUE_PROPERTY

        static final java.lang.String VALUE_PROPERTY
        The value bound property.
    • Method Detail

      • getDefaultValue

        V getDefaultValue()
        Returns:
        The default value.
      • getValue

        V getValue()
        Specified by:
        getValue in interface com.globalmentor.model.Valued<V>
        Returns:
        The input value, or null if there is no input value.
      • setValue

        void setValue​(V newValue)
               throws java.beans.PropertyVetoException
        Sets the new value. This is a bound property that only fires a change event when the new value is different via the equals() method. If a validator is installed, the value will first be validated before the current value is changed. Validation always occurs if a validator is installed, even if the value is not changing. If the value change is vetoed by the installed validator, the validation exception will be accessible via Throwable.getCause().
        Specified by:
        setValue in interface com.globalmentor.model.MutableValued<V>
        Parameters:
        newValue - The new value.
        Throws:
        java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.
        See Also:
        getValidator(), VALUE_PROPERTY
      • clearValue

        void clearValue()
        Clears the value by setting the value to null, which may be invalid according to any installed validators. No validation occurs.
        See Also:
        VALUE_PROPERTY
      • resetValue

        void resetValue()
        Resets the value to a default value, which may be invalid according to any installed validators. No validation occurs.
        See Also:
        VALUE_PROPERTY
      • getValidator

        Validator<V> getValidator()
        Returns:
        The validator for this model, or null if no validator is installed.
      • setValidator

        void setValidator​(Validator<V> newValidator)
        Sets the validator. This is a bound property
        Parameters:
        newValidator - The validator for this model, or null if no validator should be used.
        See Also:
        VALIDATOR_PROPERTY
      • isValidValue

        boolean isValidValue()
        Determines whether the value of this model is valid.
        Returns:
        Whether the value of this model is valid.
      • validateValue

        void validateValue()
                    throws ValidationException
        Validates the value of this model, throwing an exception if the model is not valid.
        Throws:
        ValidationException - if the value of this model is not valid.
      • getValueClass

        java.lang.Class<V> getValueClass()
        Returns:
        The class representing the type of value this model can hold.