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
ConstructorsConstructorDescriptionBindingImpl(Binder.BindingBuilderImpl<BEAN, FIELDVALUE, TARGET> builder, ValueProvider<BEAN, TARGET> getter, Setter<BEAN, TARGET> setter) -
Method Summary
Modifier and TypeMethodDescriptionprotected ValueContextCreates a value context from the current state of the binding and its field.protected static LocaleFinds an appropriate locale to be used in conversion and validation.Returns theBinderconnected to thisBindinginstance.Used in comparison of the current value of a field with its initial value.getField()Gets the field the binding uses.Gets the getter associated with this Binding.Gets predicate for testingBinder.Binding.isApplied().Gets the setter associated with this Binding.Gets the validation status handler for this Binding.booleanChecks whether the field that the binding uses has uncommitted changes.booleanReturns whether asRequired validator is currently enabled or not.booleanReturns whether the value is converted back to the presentation in the field when a converter is used in binding.Returns if default validator of bound field is enabled.booleanGets the current read-only status for this Binding.booleanReturns if validators are currently disabled or not.voidReads the value from given item and stores it to the bound field.voidsetAsRequiredEnabled(boolean asRequiredEnabled) Enable or disable asRequired validator.voidsetConvertBackToPresentation(boolean convertBackToPresentation) Define whether the value should be converted back to the presentation in the field when a converter is used in binding.voidsetDefaultValidatorEnabled(Boolean defaultValidatorEnabled) Sets up this binding to either enable or disable the default field validator (e.g.voidsetIsAppliedPredicate(SerializablePredicate<Binder.Binding<BEAN, TARGET>> isAppliedPredicate) Sets a custom predicate for testingBinder.Binding.isApplied().voidsetReadOnly(boolean readOnly) Sets the read-only status on for this Binding.voidsetValidatorsDisabled(boolean validatorsDisabled) Define whether validators are disabled or enabled for this specific binding.voidunbind()Removes this binding from its binder and unregisters theValueChangeListenerfrom any boundHasValue, andValidationStatusChangeListenerfrom any boundHasValidator.validate(boolean fireEvent) Validates the field value and returns aValidationStatusinstance representing the outcome of the validation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.data.binder.Binder.Binding
isApplied, 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.BindingGets the field the binding uses.- Specified by:
getFieldin 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.BindingValidates the field value and returns aValidationStatusinstance representing the outcome of the validation.- Specified by:
validatein interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
fireEvent-trueto fire status event;falseto not- Returns:
- the validation result.
- See Also:
-
unbind
public void unbind()Removes this binding from its binder and unregisters theValueChangeListenerfrom any boundHasValue, andValidationStatusChangeListenerfrom any boundHasValidator. It does nothing if it is called for an already unbound binding.- Specified by:
unbindin 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 theBinderconnected to thisBindinginstance.- Returns:
- the binder
-
getValidationStatusHandler
Description copied from interface:Binder.BindingGets the validation status handler for this Binding.- Specified by:
getValidationStatusHandlerin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- the validation status handler for this binding
-
read
Description copied from interface:Binder.BindingReads the value from given item and stores it to the bound field.- Specified by:
readin interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
bean- the bean to read from
-
setReadOnly
public void setReadOnly(boolean readOnly) Description copied from interface:Binder.BindingSets 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:
setReadOnlyin interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
readOnly-trueto set binding read-only;falseto enable writes
-
isReadOnly
public boolean isReadOnly()Description copied from interface:Binder.BindingGets the current read-only status for this Binding.- Specified by:
isReadOnlyin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
trueif read-only;falseif not- See Also:
-
getGetter
Description copied from interface:Binder.BindingGets the getter associated with this Binding.- Specified by:
getGetterin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- the getter
-
getSetter
Description copied from interface:Binder.BindingGets the setter associated with this Binding.- Specified by:
getSetterin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- the setter
-
setAsRequiredEnabled
public void setAsRequiredEnabled(boolean asRequiredEnabled) Description copied from interface:Binder.BindingEnable or disable asRequired validator. The validator is enabled by default.- Specified by:
setAsRequiredEnabledin interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
asRequiredEnabled-falseif asRequired validator should be disabled,trueotherwise (default)- See Also:
-
isAsRequiredEnabled
public boolean isAsRequiredEnabled()Description copied from interface:Binder.BindingReturns whether asRequired validator is currently enabled or not.- Specified by:
isAsRequiredEnabledin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
falseif asRequired validator is disabledtrueotherwise (default)- See Also:
-
setValidatorsDisabled
public void setValidatorsDisabled(boolean validatorsDisabled) Description copied from interface:Binder.BindingDefine whether validators are disabled or enabled for this specific binding.- Specified by:
setValidatorsDisabledin interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
validatorsDisabled- A boolean value.
-
isValidatorsDisabled
public boolean isValidatorsDisabled()Description copied from interface:Binder.BindingReturns if validators are currently disabled or not.- Specified by:
isValidatorsDisabledin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- A boolean value.
-
setDefaultValidatorEnabled
Description copied from interface:Binder.BindingSets up this binding to either enable or disable the default field validator (e.g. min/max validators in DatePicker). This binding-level setting will override the Binder-level setting for this property. Defaults to null.- Specified by:
setDefaultValidatorEnabledin interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
defaultValidatorEnabled- true to enable default validator for this binding, false to disable it, null to reset (fall back to Binder-level setting)- See Also:
-
isDefaultValidatorEnabled
Description copied from interface:Binder.BindingReturns if default validator of bound field is enabled.- Specified by:
isDefaultValidatorEnabledin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- true if default validator is enabled for this binding, false if it is disabled, null if falls back to Binder-level setting
-
setConvertBackToPresentation
public void setConvertBackToPresentation(boolean convertBackToPresentation) Description copied from interface:Binder.BindingDefine 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:
setConvertBackToPresentationin interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
convertBackToPresentation- A boolean value- See Also:
-
isConvertBackToPresentation
public boolean isConvertBackToPresentation()Description copied from interface:Binder.BindingReturns whether the value is converted back to the presentation in the field when a converter is used in binding.- Specified by:
isConvertBackToPresentationin interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- A boolean value
-
hasChanges
Description copied from interface:Binder.BindingChecks whether the field that the binding uses has uncommitted changes.- Specified by:
hasChangesin 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.
-
getEqualityPredicate
Description copied from interface:Binder.BindingUsed in comparison of the current value of a field with its initial value.Once set, the value of the field that binding uses will be compared with the initial value for hasChanged.
- Specified by:
getEqualityPredicatein interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- the predicate to use for equality comparison
-
getIsAppliedPredicate
Description copied from interface:Binder.BindingGets predicate for testingBinder.Binding.isApplied(). By default, non-visible components are ignored during validation and bean writing.- Specified by:
getIsAppliedPredicatein interfaceBinder.Binding<BEAN,FIELDVALUE> - Returns:
- predicate for testing
Binder.Binding.isApplied()
-
setIsAppliedPredicate
public void setIsAppliedPredicate(SerializablePredicate<Binder.Binding<BEAN, TARGET>> isAppliedPredicate) Description copied from interface:Binder.BindingSets a custom predicate for testingBinder.Binding.isApplied(). Set to null to restore default functionality.- Specified by:
setIsAppliedPredicatein interfaceBinder.Binding<BEAN,FIELDVALUE> - Parameters:
isAppliedPredicate- custom predicate for testingBinder.Binding.isApplied()
-