Package com.vaadin.data
Class Binder.BindingImpl<BEAN,FIELDVALUE,TARGET>
- java.lang.Object
-
- com.vaadin.data.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 ofBinding.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BindingImpl(Binder.BindingBuilderImpl<BEAN,FIELDVALUE,TARGET> builder, ValueProvider<BEAN,TARGET> getter, Setter<BEAN,TARGET> setter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ValueContextcreateValueContext()Creates a value context from the current state of the binding and its field.protected LocalefindLocale()Finds an appropriate locale to be used in conversion and validation.protected Binder<BEAN>getBinder()Returns theBinderconnected to thisBindinginstance.SerializableBiPredicate<TARGET,TARGET>getEqualityPredicate()Used in comparison of the current value of a field with its initial value.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.BindingValidationStatusHandlergetValidationStatusHandler()Gets the validation status handler for this Binding.booleanhasChanges()Checks whether the field that the binding uses has uncommitted changes.booleanisAsRequiredEnabled()Returns whether asRequired validator is currently enabled or not.booleanisConvertBackToPresentation()Returns whether the value is converted back to the presentation in the field when a converter is used in binding.booleanisReadOnly()Gets the current read-only status for this Binding.booleanisValidatorsDisabled()Returns if validators are currently disabled or notvoidread(BEAN bean)Reads 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.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.BindingValidationStatus<TARGET>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, wait
-
Methods inherited from interface com.vaadin.data.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.BindingGets the field the binding uses.- Specified by:
getFieldin interfaceBinder.Binding<BEAN,FIELDVALUE>- Returns:
- the field for the binding
-
findLocale
protected 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.BindingValidates the field value and returns aValidationStatusinstance representing the outcome of the validation. Note: Calling this method will not trigger the value update in the bean automatically. This method will attempt to temporarily apply all current changes to the bean and run full bean validation for it. The changes are reverted after bean validation.- Specified by:
validatein interfaceBinder.Binding<BEAN,FIELDVALUE>- Parameters:
fireEvent-trueto fire status event;falseto not- Returns:
- the validation result.
- See Also:
Binder.Binding.validate(),Binder.validate()
-
unbind
public void unbind()
Removes this binding from its binder and unregisters theValueChangeListenerfrom any boundHasValue. It does nothing if it is called for an already unbound binding.- Specified by:
unbindin interfaceBinder.Binding<BEAN,FIELDVALUE>- Since:
- 8.2
-
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 theBinderconnected to thisBindinginstance.- Returns:
- the binder
-
getValidationStatusHandler
public BindingValidationStatusHandler 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
public void read(BEAN bean)
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:
Binder.Binding.setReadOnly(boolean)
-
getGetter
public ValueProvider<BEAN,TARGET> getGetter()
Description copied from interface:Binder.BindingGets the getter associated with this Binding.- Specified by:
getGetterin interfaceBinder.Binding<BEAN,FIELDVALUE>- Returns:
- the getter
-
getSetter
public Setter<BEAN,TARGET> 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:
Binder.BindingBuilder.asRequired(String),Binder.BindingBuilder.asRequired(ErrorMessageProvider)
-
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:
Binder.BindingBuilder.asRequired(String),Binder.BindingBuilder.asRequired(ErrorMessageProvider)
-
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
-
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.- Specified by:
setConvertBackToPresentationin interfaceBinder.Binding<BEAN,FIELDVALUE>- Parameters:
convertBackToPresentation- A boolean value
-
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
public boolean hasChanges() throws IllegalStateExceptionDescription copied from interface:Binder.BindingChecks whether the field that the binding uses has uncommitted changes.- Specified by:
hasChangesin interfaceBinder.Binding<BEAN,FIELDVALUE>- Returns:
trueif the field the binding uses has uncommitted changes, otherwisefalse.- Throws:
IllegalStateException- if the binding is no longer attached to a Binder.
-
getEqualityPredicate
public SerializableBiPredicate<TARGET,TARGET> 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
-
-