V
- the value typepublic interface HasValue<V> extends Serializable
Modifier and Type | Interface and Description |
---|---|
static class |
HasValue.ValueChangeEvent<V>
An event fired when the value of a
HasValue changes. |
static interface |
HasValue.ValueChangeListener<V>
A listener for value change events.
|
Modifier and Type | Method and Description |
---|---|
Registration |
addValueChangeListener(HasValue.ValueChangeListener<V> listener)
Adds a value change listener.
|
default void |
clear()
Resets the value to the empty one.
|
default Validator<V> |
getDefaultValidator()
Returns a validator that checks the internal state of the HasValue.
|
default V |
getEmptyValue()
Returns the value that represents an empty value.
|
default Optional<V> |
getOptionalValue()
Returns the current value of this object, wrapped in an
Optional . |
V |
getValue()
Returns the current value of this object.
|
default boolean |
isEmpty()
Returns whether this
HasValue is considered to be empty. |
boolean |
isReadOnly()
Returns whether this
HasValue is in read-only mode or not. |
boolean |
isRequiredIndicatorVisible()
Checks whether the required indicator is visible.
|
void |
setReadOnly(boolean readOnly)
Sets the read-only mode of this
HasValue to given mode. |
void |
setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
Sets the required indicator visible or not.
|
void |
setValue(V value)
Sets the value of this object.
|
void setValue(V value)
getValue()
, fires a value change event. May throw
IllegalArgumentException
if the value is not acceptable.
Implementation note: the implementing class should document whether null values are accepted or not.
value
- the new valueIllegalArgumentException
- if the value is invalidV getValue()
Implementation note: the implementing class should document whether null values may be returned or not.
Registration addValueChangeListener(HasValue.ValueChangeListener<V> listener)
HasValue
is changed either by the user or programmatically.listener
- the value change listener, not nulldefault V getEmptyValue()
By default HasValue
is expected to support null
as empty
values. Specific implementations might not support this.
Binder#bind(HasValue, ValueProvider, Setter)
default Optional<V> getOptionalValue()
Optional
.
The Optional
will be empty if the value is null
or
isEmpty()
returns true
.
Optional
default boolean isEmpty()
HasValue
is considered to be empty.
By default this is an equality check between current value and empty value.
true
if considered empty; false
if notvoid setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
If set visible, it is visually indicated in the user interface.
requiredIndicatorVisible
- true
to make the required indicator visible,
false
if notboolean isRequiredIndicatorVisible()
true
if visible, false
if notvoid setReadOnly(boolean readOnly)
HasValue
to given mode. The user
can't change the value when in read-only mode.
A HasValue
with a visual component in read-only mode typically
looks visually different to signal to the user that the value cannot be
edited.
readOnly
- a boolean value specifying whether the component is put
read-only mode or notboolean isReadOnly()
HasValue
is in read-only mode or not.false
if the user can modify the value, true
if
not.default void clear()
This is just a shorthand for resetting the value, see the methods
setValue(Object)
and getEmptyValue()
.
setValue(Object)
,
getEmptyValue()
default Validator<V> getDefaultValidator()
Binder
and can be seen as a validation failure.Binder.validate()
Copyright © 2018 Vaadin Ltd. All rights reserved.