com.vaadin.flow.data.binder.
Class Binder.BindingImpl<BEAN,FIELDVALUE,TARGET>
- java.lang.Object
-
- com.vaadin.flow.data.binder.Binder.BindingImpl<BEAN,FIELDVALUE,TARGET>
-
Type Parameters:
BEAN
- the bean type, must match the Binder bean typeFIELDVALUE
- the value type of the fieldTARGET
- the target data type of the binding, matches the field type unless a converter has been setAll Implemented Interfaces:
Binder.Binding<BEAN,TARGET>
,Serializable
protected static class Binder.BindingImpl<BEAN,FIELDVALUE,TARGET> extends Object implements Binder.Binding<BEAN,TARGET>
An internal implementation of
Binding
.See Also:
-
-
Constructor Summary
Constructors Constructor Description BindingImpl(Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET> builder, ValueProvider<BEAN,TARGET> getter, Setter<BEAN,TARGET> setter)
-
Method Summary
All Methods Modifier and Type Method Description protected ValueContext
createValueContext()
Creates a value context from the current state of the binding and its field.
protected static Locale
findLocale()
Finds an appropriate locale to be used in conversion and validation.
protected Binder<BEAN>
getBinder()
Returns the
Binder
connected to thisBinding
instance.HasValue<?,FIELDVALUE>
getField()
Gets the field the binding uses.
ValueProvider<BEAN,TARGET>
getGetter()
Gets the getter associated with this Binding.
Setter<BEAN,TARGET>
getSetter()
Gets the setter associated with this Binding.
BindingValidationStatusHandler
getValidationStatusHandler()
Gets the validation status handler for this Binding.
boolean
isAsRequiredEnabled()
Returns whether asRequired validator is currently enabled or not.
boolean
isConvertBackToPresentation()
Returns whether the value is converted back to the presentation in the field when a converter is used in binding.
boolean
isReadOnly()
Gets the current read-only status for this Binding.
boolean
isValidatorsDisabled()
Returns if validators are currently disabled or not.
void
read(BEAN bean)
Reads the value from given item and stores it to the bound field.
void
setAsRequiredEnabled(boolean asRequiredEnabled)
Enable or disable asRequired validator.
void
setConvertBackToPresentation(boolean convertBackToPresentation)
Define whether the value should be converted back to the presentation in the field when a converter is used in binding.
void
setReadOnly(boolean readOnly)
Sets the read-only status on for this Binding.
void
setValidatorsDisabled(boolean validatorsDisabled)
Define whether validators are disabled or enabled for this specific binding.
void
unbind()
Removes this binding from its binder and unregisters the
ValueChangeListener
from any boundHasValue
, andValidationStatusChangeListener
from any boundHasValidator
.BindingValidationStatus<TARGET>
validate(boolean fireEvent)
Validates the field value and returns a
ValidationStatus
instance representing the outcome of the validation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.data.binder.Binder.Binding
validate
-
-
-
-
Constructor Detail
-
BindingImpl
public BindingImpl(Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET> builder, ValueProvider<BEAN,TARGET> getter, Setter<BEAN,TARGET> setter)
-
-
Method Detail
-
getField
public HasValue<?,FIELDVALUE> getField()
Description copied from interface:
Binder.Binding
Gets the field the binding uses.
Specified by:
getField
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
the field for the binding
-
findLocale
protected static Locale findLocale()
Finds an appropriate locale to be used in conversion and validation.
Returns:
the found locale, not null
-
validate
public BindingValidationStatus<TARGET> validate(boolean fireEvent)
Description copied from interface:
Binder.Binding
Validates the field value and returns a
ValidationStatus
instance representing the outcome of the validation.Specified by:
validate
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Parameters:
fireEvent
-true
to fire status event;false
to notReturns:
the validation result.
See Also:
-
unbind
public void unbind()
Removes this binding from its binder and unregisters the
ValueChangeListener
from any boundHasValue
, andValidationStatusChangeListener
from any boundHasValidator
. It does nothing if it is called for an already unbound binding.Specified by:
unbind
in interfaceBinder.Binding<BEAN,FIELDVALUE>
-
createValueContext
protected ValueContext createValueContext()
Creates a value context from the current state of the binding and its field.
Returns:
the value context
-
getBinder
protected Binder<BEAN> getBinder()
Returns the
Binder
connected to thisBinding
instance.Returns:
the binder
-
getValidationStatusHandler
public BindingValidationStatusHandler getValidationStatusHandler()
Description copied from interface:
Binder.Binding
Gets the validation status handler for this Binding.
Specified by:
getValidationStatusHandler
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
the validation status handler for this binding
-
read
public void read(BEAN bean)
Description copied from interface:
Binder.Binding
Reads the value from given item and stores it to the bound field.
Specified by:
read
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Parameters:
bean
- the bean to read from
-
setReadOnly
public void setReadOnly(boolean readOnly)
Description copied from interface:
Binder.Binding
Sets the read-only status on for this Binding. Setting a Binding read-only will mark the field read-only and not write any values from the fields to the bean.
This helper method is the preferred way to control the read-only state of the bound field.
Specified by:
setReadOnly
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Parameters:
readOnly
-true
to set binding read-only;false
to enable writes
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:
Binder.Binding
Gets the current read-only status for this Binding.
Specified by:
isReadOnly
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
true
if read-only;false
if notSee Also:
-
getGetter
public ValueProvider<BEAN,TARGET> getGetter()
Description copied from interface:
Binder.Binding
Gets the getter associated with this Binding.
Specified by:
getGetter
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
the getter
-
getSetter
public Setter<BEAN,TARGET> getSetter()
Description copied from interface:
Binder.Binding
Gets the setter associated with this Binding.
Specified by:
getSetter
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
the setter
-
setAsRequiredEnabled
public void setAsRequiredEnabled(boolean asRequiredEnabled)
Description copied from interface:
Binder.Binding
Enable or disable asRequired validator. The validator is enabled by default.
Specified by:
setAsRequiredEnabled
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Parameters:
asRequiredEnabled
-false
if asRequired validator should be disabled,true
otherwise (default)See Also:
Binder.BindingBuilder.asRequired(String)
,Binder.BindingBuilder.asRequired(ErrorMessageProvider)
-
isAsRequiredEnabled
public boolean isAsRequiredEnabled()
Description copied from interface:
Binder.Binding
Returns whether asRequired validator is currently enabled or not.
Specified by:
isAsRequiredEnabled
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
false
if asRequired validator is disabledtrue
otherwise (default)See Also:
Binder.BindingBuilder.asRequired(String)
,Binder.BindingBuilder.asRequired(ErrorMessageProvider)
-
setValidatorsDisabled
public void setValidatorsDisabled(boolean validatorsDisabled)
Description copied from interface:
Binder.Binding
Define whether validators are disabled or enabled for this specific binding.
Specified by:
setValidatorsDisabled
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Parameters:
validatorsDisabled
- A boolean value.
-
isValidatorsDisabled
public boolean isValidatorsDisabled()
Description copied from interface:
Binder.Binding
Returns if validators are currently disabled or not.
Specified by:
isValidatorsDisabled
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
A boolean value.
-
setConvertBackToPresentation
public void setConvertBackToPresentation(boolean convertBackToPresentation)
Description copied from interface:
Binder.Binding
Define whether the value should be converted back to the presentation in the field when a converter is used in binding.
As of version 6.0, when a converter is used on a binding and the user input value is modified by the converter, the value from the converter is applied back to the input. It is possible to control this behavior with this API.
Specified by:
setConvertBackToPresentation
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Parameters:
convertBackToPresentation
- A boolean valueSee Also:
Binder.BindingBuilder.withConverter(Converter)
,Binder.BindingBuilder.withConverter(SerializableFunction, SerializableFunction)
,Binder.BindingBuilder.withConverter(SerializableFunction, SerializableFunction, String)
-
isConvertBackToPresentation
public boolean isConvertBackToPresentation()
Description copied from interface:
Binder.Binding
Returns whether the value is converted back to the presentation in the field when a converter is used in binding.
Specified by:
isConvertBackToPresentation
in interfaceBinder.Binding<BEAN,FIELDVALUE>
Returns:
A boolean value
-
-