@Override public BindingBuilder<BEAN, TARGET> withValidationStatusHandler( BindingValidationStatusHandler handler) { checkUnbound(); Objects.requireNonNull(handler, "handler cannot be null"); if (isStatusHandlerChanged) { throw new IllegalStateException("A " + BindingValidationStatusHandler.class.getSimpleName() + " has already been set"); } isStatusHandlerChanged = true; statusHandler = handler; return this; }
@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; }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Binding<BEAN, TARGET> bind(String propertyName) { Objects.requireNonNull(propertyName, "Property name cannot be null"); checkUnbound(); PropertyDefinition<BEAN, ?> definition = getBinder().propertySet .getProperty(propertyName) .orElseThrow(() -> new IllegalArgumentException( "Could not resolve property name " + propertyName + " from " + getBinder().propertySet)); ValueProvider<BEAN, ?> getter = definition.getGetter(); Setter<BEAN, ?> setter = definition.getSetter().orElse(null); if (setter == null) { getLogger().fine(() -> propertyName + " does not have an accessible setter"); } BindingBuilder<BEAN, ?> finalBinding = withConverter( createConverter(definition.getType()), false); finalBinding = getBinder().configureBinding(finalBinding, definition); try { Binding binding = ((BindingBuilder) finalBinding).bind(getter, setter); getBinder().boundProperties.put(propertyName, binding); return binding; } finally { getBinder().incompleteMemberFieldBindings.remove(getField()); } }
Converter<TARGET, NEWTARGET> converter, boolean resetNullRepresentation) { checkUnbound(); Objects.requireNonNull(converter, "converter cannot be null");
@Override public Binding<BEAN, TARGET> bind(ValueProvider<BEAN, TARGET> getter, Setter<BEAN, TARGET> setter) { checkUnbound(); Objects.requireNonNull(getter, "getter cannot be null"); BindingImpl<BEAN, FIELDVALUE, TARGET> binding = new BindingImpl<>( this, getter, setter); getBinder().bindings.add(binding); if (getBinder().getBean() != null) { binding.initFieldValue(getBinder().getBean()); } if (setter == null) { binding.getField().setReadOnly(true); } getBinder().fireStatusChangeEvent(false); bound = true; getBinder().incompleteBindings.remove(getField()); return binding; }
@Override public BindingBuilder<BEAN, TARGET> asRequired( Validator<TARGET> customRequiredValidator) { checkUnbound(); field.setRequiredIndicatorVisible(true); return withValidator(customRequiredValidator); }