public final class NonNullValueModel extends AbstractValueModel
ValueModel
implementation that avoids null
values.
It wraps another ValueModel and returns a (non-null) default value
if the wrapped ValueModel returns null.Note that value change events fired by this model may use null as old and/or new value. This is because PropertyChangeEvents use null to indicate that the old and/or new value is not provided by the event.
Note: This class is not yet part of the binary Binding library; it comes with the Binding distributions as an extra. The API is work in progress and may change without notice; this class may even be completely removed from future distributions. If you want to use this class, you may consider copying it into your code base.
PROPERTYNAME_VALUE
Constructor and Description |
---|
NonNullValueModel(ValueModel subject,
java.lang.Object defaultValue)
Constructs an NonNullValueModel for the given ValueModel.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getValue()
Returns this model's current subject value.
|
void |
setValue(java.lang.Object newValue)
Sets the given value to the wrapped ValueModel.
|
addValueChangeListener, booleanValue, doubleValue, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, floatValue, getString, intValue, longValue, paramString, removeValueChangeListener, setValue, setValue, setValue, setValue, setValue, toString, valueString
createPropertyChangeSupport, firePropertyChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
public NonNullValueModel(ValueModel subject, java.lang.Object defaultValue)
subject
- the underlying (or wrapped) ValueModeldefaultValue
- the value used whenever the wrapped model
returns null
java.lang.NullPointerException
- if the subject or defaultValue is null
public java.lang.Object getValue()
public void setValue(java.lang.Object newValue)
null
.newValue
- the value to setCopyright © 2002-2010 JGoodies Karsten Lentzsch. All Rights Reserved.