Package io.guise.framework.model
Class DefaultValueModel<V>
java.lang.Object
com.globalmentor.beans.BoundPropertyObject
io.guise.framework.model.AbstractModel
io.guise.framework.model.AbstractValueModel<V>
io.guise.framework.model.DefaultValueModel<V>
- 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
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
ConstructorDescriptionDefaultValueModel
(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 TypeMethodDescriptionvoid
Clears the value by setting the value tonull
, which may be invalid according to any installed validators.getValue()
void
Resets the value to a default value, which may be invalid according to any installed validators.void
Sets the new value.Methods inherited from class io.guise.framework.model.AbstractValueModel
createPropertyVetoException, getValidator, getValueClass, isValidValue, setValidator, validateValue
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
Constructs a value model indicating the type of value it can hold. The default value is set tonull
.- Parameters:
valueClass
- The class indicating the type of value held in the model.- Throws:
NullPointerException
- if the given value class isnull
.
-
DefaultValueModel
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 isnull
.
-
-
Method Details
-
getDefaultValue
- Returns:
- The default value.
-
getValue
- Returns:
- The input value, or
null
if there is no input value.
-
setValue
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 theequals()
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 viaThrowable.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 tonull
, 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:
-