Class DefaultValueModel<V>

java.lang.Object
com.globalmentor.beans.BoundPropertyObject
Type Parameters:
V - The type of value contained in the model.
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, com.globalmentor.model.MutableValued<V>, com.globalmentor.model.Valued<V>, Model, ValueModel<V>
Direct Known Subclasses:
DefaultTreeNodeModel, Table.DefaultCellValueModel, ValuePrototype

public class DefaultValueModel<V> extends AbstractValueModel<V>
A default implementation of a model representing a value.
Author:
Garret Wilson
  • Field Summary

    Fields inherited from class com.globalmentor.beans.BoundPropertyObject

    NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS

    Fields inherited from interface io.guise.framework.model.ValueModel

    VALIDATOR_PROPERTY, VALUE_PROPERTY
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultValueModel(Class<V> valueClass)
    Constructs a value model indicating the type of value it can hold.
    DefaultValueModel(Class<V> valueClass, V defaultValue)
    Constructs a value model indicating the type of value it can hold, along with an initial value.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the value by setting the value to null, which may be invalid according to any installed validators.
     
     
    void
    Resets the value to a default value, which may be invalid according to any installed validators.
    void
    setValue(V newValue)
    Sets the new value.

    Methods inherited from class io.guise.framework.model.AbstractModel

    getEventListenerManager, getPlainText

    Methods inherited from class com.globalmentor.beans.BoundPropertyObject

    addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    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
  • Constructor Details

    • DefaultValueModel

      public DefaultValueModel(Class<V> valueClass)
      Constructs a value model indicating the type of value it can hold. The default value is set to null.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      Throws:
      NullPointerException - if the given value class is null.
    • DefaultValueModel

      public DefaultValueModel(Class<V> valueClass, V defaultValue)
      Constructs a value model indicating the type of value it can hold, along with an initial value.
      Parameters:
      valueClass - The class indicating the type of value held in the model.
      defaultValue - The default value, which will not be validated.
      Throws:
      NullPointerException - if the given value class is null.
  • Method Details

    • getDefaultValue

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

      public V getValue()
      Returns:
      The input value, or null if there is no input value.
    • setValue

      public void setValue(V newValue) throws PropertyVetoException
      Description copied from interface: ValueModel
      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().
      Parameters:
      newValue - The new value.
      Throws:
      PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.
      See Also:
    • clearValue

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

      public void resetValue()
      Description copied from interface: ValueModel
      Resets the value to a default value, which may be invalid according to any installed validators. No validation occurs.
      See Also: