Package 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 set
- All 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
ConstructorDescriptionBindingImpl
(Binder.BindingBuilderImpl<BEAN, FIELDVALUE, TARGET> builder, ValueProvider<BEAN, TARGET> getter, Setter<BEAN, TARGET> setter) -
Method Summary
Modifier and TypeMethodDescriptionprotected ValueContext
Creates a value context from the current state of the binding and its field.protected static Locale
Finds an appropriate locale to be used in conversion and validation.Returns theBinder
connected to thisBinding
instance.getField()
Gets the field the binding uses.Gets the getter associated with this Binding.Gets the setter associated with this Binding.Gets the validation status handler for this Binding.boolean
Checks whether the field that the binding uses has uncommitted changes.boolean
Returns whether asRequired validator is currently enabled or not.boolean
Returns whether the value is converted back to the presentation in the field when a converter is used in binding.boolean
Gets the current read-only status for this Binding.boolean
Returns if validators are currently disabled or not.void
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 theValueChangeListener
from any boundHasValue
, andValidationStatusChangeListener
from any boundHasValidator
.validate
(boolean fireEvent) Validates the field value and returns aValidationStatus
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 Details
-
BindingImpl
public BindingImpl(Binder.BindingBuilderImpl<BEAN, FIELDVALUE, TARGET> builder, ValueProvider<BEAN, TARGET> getter, Setter<BEAN, TARGET> setter)
-
-
Method Details
-
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
Finds an appropriate locale to be used in conversion and validation.- Returns:
- the found locale, not null
-
validate
Description copied from interface:Binder.Binding
Validates the field value and returns aValidationStatus
instance representing the outcome of the validation.- Specified by:
validate
in interfaceBinder.Binding<BEAN,
FIELDVALUE> - Parameters:
fireEvent
-true
to fire status event;false
to not- Returns:
- the validation result.
- See Also:
-
unbind
public void unbind()Removes this binding from its binder and unregisters theValueChangeListener
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
Creates a value context from the current state of the binding and its field.- Returns:
- the value context
-
getBinder
Returns theBinder
connected to thisBinding
instance.- Returns:
- the binder
-
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
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 not- See Also:
-
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
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:
-
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:
-
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 value- See Also:
-
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
-
hasChanges
Description copied from interface:Binder.Binding
Checks whether the field that the binding uses has uncommitted changes.- Specified by:
hasChanges
in interfaceBinder.Binding<BEAN,
FIELDVALUE> - Returns:
- true if the field the binding uses has uncommitted changes, otherwise false.
- Throws:
IllegalStateException
- if the binding is no longer attached to a Binder.
-