private FIELDVALUE convertDataToFieldType(BEAN bean) { TARGET target = getter.apply(bean); ValueContext valueContext = createValueContext(); return converterValidatorChain.convertToPresentation(target, valueContext); }
/** * Returns the field value run through all converters and validators, * but doesn't pass the {@link BindingValidationStatus} to any status * handler. * * @return the result of the conversion */ private Result<TARGET> doConversion() { FIELDVALUE fieldValue = field.getValue(); return converterValidatorChain.convertToModel(fieldValue, createValueContext()); }
@Override public BindingBuilder<BEAN, TARGET> asRequired( Validator<TARGET> customRequiredValidator) { checkUnbound(); field.setRequiredIndicatorVisible(true); return withValidator(customRequiredValidator); }
@Override public Result<FIELDVALUE> convertToModel(FIELDVALUE value, ValueContext context) { if (delegate == null) { return Result.ok(value); } else { return delegate.convertToModel(value, context); } }
@Override public void read(BEAN bean) { getField().setValue(convertDataToFieldType(bean)); }
@Override protected BindingBuilder<BEAN, ?> configureBinding( BindingBuilder<BEAN, ?> binding, PropertyDefinition<BEAN, ?> definition) { Class<?> actualBeanType = findBeanType(beanType, definition); BeanValidator validator = new BeanValidator(actualBeanType, definition.getTopLevelName()); if (requiredConfigurator != null) { configureRequired(binding, definition, validator); } return binding.withValidator(validator); }
public BindingImpl(BindingBuilderImpl<BEAN, FIELDVALUE, TARGET> builder, ValueProvider<BEAN, TARGET> getter, Setter<BEAN, TARGET> setter) { this.binder = builder.getBinder(); this.field = builder.field; this.statusHandler = builder.statusHandler; converterValidatorChain = ((Converter<FIELDVALUE, TARGET>) builder.converterValidatorChain); onValueChange = getField() .addValueChangeListener(this::handleFieldValueChange); this.getter = getter; this.setter = setter; readOnly = setter == null; }
@Override public Result<T> convertToModel(PRESENTATION value, ValueContext context) { Result<MODEL> model = Converter.this.convertToModel(value, context); return model.flatMap(v -> other.convertToModel(v, context)); }
private Object readResolve() { /* * When this instance is deserialized, it will be replaced with a * property set for the corresponding bean type and property name. */ return get(instanceKey.type, instanceKey.checkNestedDefinitions, new PropertyFilterDefinition(instanceKey.depth, instanceKey.ignorePackageNames)); } }
private void doRemoveBean(boolean fireStatusEvent) { changedBindings.clear(); if (bean != null) { bean = null; } getValidationStatusHandler().statusChange( BinderValidationStatus.createUnresolvedStatus(this)); if (fireStatusEvent) { fireStatusChangeEvent(false); } }
@Override public BindingBuilder<BEAN, TARGET> asRequired( ErrorMessageProvider errorMessageProvider) { return asRequired(Validator.from( value -> !Objects.equals(value, field.getEmptyValue()), errorMessageProvider)); }
/** * Gets the bound field for this status. * * @return the field */ public HasValue<?> getField() { return getBinding().getField(); } }
private Object writeReplace() { /* * Instead of serializing this actual property definition, only * serialize a DTO that when deserialized will get the corresponding * property definition from the cache. */ return new SerializedPropertyDefinition( getPropertySet().instanceKey.type, getName()); } }
private Object writeReplace() { /* * Instead of serializing this actual property definition, only * serialize a DTO that when deserialized will get the corresponding * property definition from the cache. */ return new SerializedPropertyDefinition( getPropertySet().instanceKey.type, getName()); }
/** * Creates a value context from the current state of the binding and its * field. * * @return the value context */ protected ValueContext createValueContext() { if (field instanceof Component) { return new ValueContext((Component) field, field); } return new ValueContext(null, field, findLocale()); }
@Override public Result<T> convertToModel(T value, ValueContext context) { ValidationResult validationResult = validator.apply(value, context); return new ValidationResultWrap<>(value, validationResult); }
@Override public BindingBuilder<BEAN, TARGET> withValidator( Validator<? super TARGET> validator) { checkUnbound(); Objects.requireNonNull(validator, "validator cannot be null"); converterValidatorChain = ((Converter<FIELDVALUE, TARGET>) converterValidatorChain) .chain(new ValidatorAsConverter<>(validator)); return this; }
private Object writeReplace() { /* * Instead of serializing this actual property set, only serialize a DTO * that when deserialized will get the corresponding property set from * the cache. */ return new SerializedPropertySet(instanceKey); } }