Binder implements Serializable { public void readBean(BEAN bean) { checkBindingsCompleted("readBean"); if (bean == null) { clearFields(); } else { changedBindings.clear(); getBindings().forEach(binding -> { if (binding.getField() != null) { binding.initFieldValue(bean, false); } }); getValidationStatusHandler().statusChange( BinderValidationStatus.createUnresolvedStatus(this)); fireStatusChangeEvent(false); } } protected  Binder(PropertySet<BEAN> propertySet);  Binder(Class<BEAN> beanType);  Binder();  Binder(Class<BEAN> beanType, boolean scanNestedDefinitions); static Binder<BEAN> withPropertySet(
            PropertySet<BEAN> propertySet); BEAN getBean(); BindingBuilder<BEAN, FIELDVALUE> forField(
            HasValue<?, FIELDVALUE> field); BindingBuilder<BEAN, FIELDVALUE> forMemberField(
            HasValue<?, FIELDVALUE> field); Binding<BEAN, FIELDVALUE> bind(
            HasValue<?, FIELDVALUE> field,
            ValueProvider<BEAN, FIELDVALUE> getter,
            Setter<BEAN, FIELDVALUE> setter); Binding<BEAN, FIELDVALUE> bind(
            HasValue<?, FIELDVALUE> field, String propertyName); void setBean(BEAN bean); void removeBean(); void readBean(BEAN bean); void writeBean(BEAN bean); void writeBeanAsDraft(BEAN bean); void writeBeanAsDraft(BEAN bean, boolean forced); boolean writeBeanIfValid(BEAN bean); Binder<BEAN> withValidator(Validator<? super BEAN> validator); Binder<BEAN> withValidator(SerializablePredicate<BEAN> predicate,
            String message); Binder<BEAN> withValidator(SerializablePredicate<BEAN> predicate,
            ErrorMessageProvider errorMessageProvider); BinderValidationStatus<BEAN> validate(); boolean isValid(); void setStatusLabel(HasText statusLabel); Optional<HasText> getStatusLabel(); void setValidationStatusHandler(
            BinderValidationStatusHandler<BEAN> statusHandler); BinderValidationStatusHandler<BEAN> getValidationStatusHandler(); Registration addStatusChangeListener(StatusChangeListener listener); Registration addValueChangeListener(
            ValueChangeListener<? super ValueChangeEvent<?>> listener); boolean hasChanges(); void setReadOnly(boolean readOnly); void bindInstanceFields(Object objectWithMemberFields); Optional<Binding<BEAN, ?>> getBinding(String propertyName); Stream<HasValue<?, ?>> getFields(); void removeBinding(HasValue<?, ?> field); void removeBinding(Binding<BEAN, ?> binding); void removeBinding(String propertyName); void setValidatorsDisabled(boolean validatorsDisabled); boolean isValidatorsDisabled();  }
@Test public void load_unbound_noChanges() { nameField.setValue(""); Person person = new Person(); String name = "bar"; person.setFirstName(name); binder.readBean(person); Assert.assertEquals("", nameField.getValue()); }
@Test public void nullRejetingField_nullValue_wrappedExceptionMentionsNullRepresentation() { TestTextField field = createNullRejectingFieldWithEmptyValue(""); Binder<AtomicReference<Integer>> binder = createIntegerConverterBinder( field); exceptionRule.expect(IllegalStateException.class); exceptionRule.expectMessage("null representation"); exceptionRule.expectCause(CoreMatchers.isA(NullPointerException.class)); binder.readBean(new AtomicReference<>()); }
@Test public void nullRejetingField_otherRejectedValue_originalExceptionIsThrown() { TestTextField field = createNullRejectingFieldWithEmptyValue(""); Binder<AtomicReference<Integer>> binder = createIntegerConverterBinder( field); exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage("42"); binder.readBean(new AtomicReference<>(Integer.valueOf(42))); }
@Test public void nullAcceptingField_nullValue_originalExceptionIsThrown() { TestTextField field = createNullRejectingFieldWithEmptyValue(null); Binder<AtomicReference<Integer>> binder = createIntegerConverterBinder( field); exceptionRule.expect(NullPointerException.class); binder.readBean(new AtomicReference<>(null)); }