com.vaadin.flow.component.internal.
Class AbstractFieldSupport<C extends Component & HasValue<AbstractField.ComponentValueChangeEvent<C,T>,T>,T>
- java.lang.Object
-
- com.vaadin.flow.component.internal.AbstractFieldSupport<C,T>
-
Type Parameters:
C
- the value change source typeT
- the value typeAll Implemented Interfaces:
public class AbstractFieldSupport<C extends Component & HasValue<AbstractField.ComponentValueChangeEvent<C,T>,T>,T> extends Object implements Serializable
Encapsulates all the logic required for a typical field implementation. This reduces the risk of implementing logic changes in
AbstractField
but not inAbstractCompositeField
, or vice versa.Since:
1.0
Author:
Vaadin Ltd
See Also:
-
-
Constructor Summary
Constructors Constructor and Description AbstractFieldSupport(C component, T defaultValue, SerializableBiPredicate<T,T> valueEquals, SerializableConsumer<T> setPresentationValue)
Creates a new field support.
-
Method Summary
All Methods Modifier and Type Method and Description Registration
addValueChangeListener(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<C,T>> listener)
Delegate method for
HasValue.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
T
getEmptyValue()
Delegate method for
HasValue.getEmptyValue()
.T
getValue()
Delegate method for
HasValue.getValue()
.void
setModelValue(T newModelValue, boolean fromClient)
Delegate method corresponding to
AbstractField.setModelValue(Object, boolean)
.void
setValue(T value)
Delegate method for
HasValue.setValue(Object)
.boolean
valueEquals(T value1, T value2)
Delegate method corresponding to
AbstractField.valueEquals(Object, Object)
.
-
-
-
Constructor Detail
-
AbstractFieldSupport
public AbstractFieldSupport(C component, T defaultValue, SerializableBiPredicate<T,T> valueEquals, SerializableConsumer<T> setPresentationValue)
Creates a new field support.
Parameters:
component
- the owning field componentdefaultValue
- the default field valuevalueEquals
- a callback for comparing valuessetPresentationValue
- a callback for setting presentation values
-
-
Method Detail
-
addValueChangeListener
public Registration addValueChangeListener(HasValue.ValueChangeListener<? super AbstractField.ComponentValueChangeEvent<C,T>> listener)
Delegate method for
HasValue.addValueChangeListener(com.vaadin.flow.component.HasValue.ValueChangeListener)
Parameters:
listener
- the listener to addReturns:
a registration for the listener
-
getValue
public T getValue()
Delegate method for
HasValue.getValue()
.Returns:
the field value
-
getEmptyValue
public T getEmptyValue()
Delegate method for
HasValue.getEmptyValue()
.Returns:
the empty value of this field
-
setValue
public void setValue(T value)
Delegate method for
HasValue.setValue(Object)
.Parameters:
value
- the value to set
-
valueEquals
public boolean valueEquals(T value1, T value2)
Delegate method corresponding to
AbstractField.valueEquals(Object, Object)
.Parameters:
value1
- the first instancevalue2
- the second instanceReturns:
true
if the instances are equal; otherwisefalse
-
setModelValue
public void setModelValue(T newModelValue, boolean fromClient)
Delegate method corresponding to
AbstractField.setModelValue(Object, boolean)
.Parameters:
newModelValue
- the new internal value to usefromClient
-true
if the new value originates from the client; otherwisefalse
-
-