// Path: src/test/java/org/vaadin/easybinder/testentity/Flight.java
// @FlightValid
// @GroupSequenceProvider(FlightGroupProvider.class)
// public class Flight {
// 	@Valid
// 	FlightId flightId;
// 
// 	@Temporal(TemporalType.TIMESTAMP)
// 	Date sbt;
// 
// 	@Temporal(TemporalType.TIMESTAMP)
// 	Date ebt;
// 
// 	@Temporal(TemporalType.TIMESTAMP)
// 	Date abt;
// 
// 	@NotNull(groups = FlightGroupProvider.Scheduled.class, message = "Gate should be set when scheduled")
// 	String gate;
// 	
// 	boolean canceled;
// 
// 	public Flight() {
// 		flightId = new FlightId();
// 	}
// 
// 	/**
// 	 * @return the flightId
// 	 */
// 	public FlightId getFlightId() {
// 		return flightId;
// 	}
// 
// 	/**
// 	 * @param flightId
// 	 *            the flightId to set
// 	 */
// 	public void setFlightId(FlightId flightId) {
// 		this.flightId = flightId;
// 	}
// 
// 	/**
// 	 * @return the sbt
// 	 */
// 	public Date getSbt() {
// 		return sbt;
// 	}
// 
// 	/**
// 	 * @return the ebt
// 	 */
// 	public Date getEbt() {
// 		return ebt;
// 	}
// 
// 	/**
// 	 * @return the abt
// 	 */
// 	public Date getAbt() {
// 		return abt;
// 	}
// 
// 	/**
// 	 * @return the gate
// 	 */
// 	public String getGate() {
// 		return gate;
// 	}
// 
// 	/**
// 	 * @param sbt
// 	 *            the sbt to set
// 	 */
// 	public void setSbt(Date sbt) {
// 		this.sbt = sbt;
// 	}
// 
// 	/**
// 	 * @param ebt
// 	 *            the ebt to set
// 	 */
// 	public void setEbt(Date ebt) {
// 		this.ebt = ebt;
// 	}
// 
// 	/**
// 	 * @param abt
// 	 *            the abt to set
// 	 */
// 	public void setAbt(Date abt) {
// 		this.abt = abt;
// 	}
// 
// 	/**
// 	 * @param gate
// 	 *            the gate to set
// 	 */
// 	public void setGate(String gate) {
// 		this.gate = gate;
// 	}
// 	
// 	public void setCanceled(boolean canceled) {
// 		this.canceled = canceled;
// 	}
// 	
// 	public boolean getCanceled() {
// 		return canceled;
// 	}
// 
// 	public boolean isCanceled() {
// 		return canceled;
// 	}
// 
// }
// 
// Path: src/test/java/org/vaadin/easybinder/testentity/FlightValidator.java
// public class FlightValidator implements ConstraintValidator<FlightValid, Flight> {
// 
// 	@Override
// 	public void initialize(FlightValid constraintAnnotation) {
// 	}
// 
// 	@Override
// 	public boolean isValid(Flight flight, ConstraintValidatorContext context) {
// 		return (flight.getAbt() == null || flight.getEbt() != null)
// 				&& (flight.getEbt() == null || flight.getSbt() != null);
// 	}
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.time.ZoneId;
import java.util.stream.Stream;
import javax.validation.constraints.Min;
import org.junit.BeforeClass;
import org.junit.Test;
import org.vaadin.easybinder.testentity.Flight;
import org.vaadin.easybinder.testentity.FlightValid;
import org.vaadin.easybinder.testentity.FlightValidator;
import com.vaadin.data.BeanValidationBinder;
import com.vaadin.data.Binder;
import com.vaadin.data.Converter;
import com.vaadin.data.HasValue;
import com.vaadin.data.RequiredFieldConfigurator;
import com.vaadin.data.Result;
import com.vaadin.data.converter.LocalDateTimeToDateConverter;
import com.vaadin.data.converter.LocalDateToDateConverter;
import com.vaadin.ui.Label;
			if (e.length() == 0) {
				return Result.error("Must be a number");
			}
			try {
				return Result.ok(Integer.parseInt(e));
			} catch (NumberFormatException ex) {
				return Result.error("Must be a number");
			}
		}, e -> Integer.toString(e));

		binder.forField(form.airline).bind("flightId.airline");
		binder.forField(form.flightNumber).withConverter(c).bind("flightId.flightNumber");
		binder.forField(form.flightSuffix)
				.withConverter(Converter.from(
						e -> e.length() == 0 ? Result.ok(null)
								: (e.length() == 1 ? Result.ok(e.charAt(0)) : Result.error("Must be 1 character")),
						f -> f == null ? "" : "" + f))
				.bind("flightId.flightSuffix");
		binder.forField(form.date).withConverter(new LocalDateToDateConverter()).bind("flightId.date");
		binder.forField(form.legType).bind("flightId.legType");
		binder.forField(form.sbt).withConverter(new LocalDateTimeToDateConverter(ZoneId.systemDefault())).bind("sbt");
		binder.forField(form.ebt).withConverter(new LocalDateTimeToDateConverter(ZoneId.systemDefault())).bind("ebt");
		binder.forField(form.abt).withConverter(new LocalDateTimeToDateConverter(ZoneId.systemDefault())).bind("abt");
		Binder.Binding<Flight, String> scheduledDependingBinding = binder.forField(form.gate).withNullRepresentation("")
				.withValidator(e -> form.sbt.getValue() == null ? true : e != null, "Gate should be set when scheduled")
				.bind(Flight::getGate, Flight::setGate);
		form.sbt.addValueChangeListener(e -> scheduledDependingBinding.validate());

		binder.bindInstanceFields(form);

// Path: src/test/java/org/vaadin/easybinder/testentity/Flight.java
// @FlightValid
// @GroupSequenceProvider(FlightGroupProvider.class)
// public class Flight {
// 	@Valid
// 	FlightId flightId;
// 
// 	@Temporal(TemporalType.TIMESTAMP)
// 	Date sbt;
// 
// 	@Temporal(TemporalType.TIMESTAMP)
// 	Date ebt;
// 
// 	@Temporal(TemporalType.TIMESTAMP)
// 	Date abt;
// 
// 	@NotNull(groups = FlightGroupProvider.Scheduled.class, message = "Gate should be set when scheduled")
// 	String gate;
// 	
// 	boolean canceled;
// 
// 	public Flight() {
// 		flightId = new FlightId();
// 	}
// 
// 	/**
// 	 * @return the flightId
// 	 */
// 	public FlightId getFlightId() {
// 		return flightId;
// 	}
// 
// 	/**
// 	 * @param flightId
// 	 *            the flightId to set
// 	 */
// 	public void setFlightId(FlightId flightId) {
// 		this.flightId = flightId;
// 	}
// 
// 	/**
// 	 * @return the sbt
// 	 */
// 	public Date getSbt() {
// 		return sbt;
// 	}
// 
// 	/**
// 	 * @return the ebt
// 	 */
// 	public Date getEbt() {
// 		return ebt;
// 	}
// 
// 	/**
// 	 * @return the abt
// 	 */
// 	public Date getAbt() {
// 		return abt;
// 	}
// 
// 	/**
// 	 * @return the gate
// 	 */
// 	public String getGate() {
// 		return gate;
// 	}
// 
// 	/**
// 	 * @param sbt
// 	 *            the sbt to set
// 	 */
// 	public void setSbt(Date sbt) {
// 		this.sbt = sbt;
// 	}
// 
// 	/**
// 	 * @param ebt
// 	 *            the ebt to set
// 	 */
// 	public void setEbt(Date ebt) {
// 		this.ebt = ebt;
// 	}
// 
// 	/**
// 	 * @param abt
// 	 *            the abt to set
// 	 */
// 	public void setAbt(Date abt) {
// 		this.abt = abt;
// 	}
// 
// 	/**
// 	 * @param gate
// 	 *            the gate to set
// 	 */
// 	public void setGate(String gate) {
// 		this.gate = gate;
// 	}
// 	
// 	public void setCanceled(boolean canceled) {
// 		this.canceled = canceled;
// 	}
// 	
// 	public boolean getCanceled() {
// 		return canceled;
// 	}
// 
// 	public boolean isCanceled() {
// 		return canceled;
// 	}
// 
// }
// 
// Path: src/test/java/org/vaadin/easybinder/testentity/FlightValidator.java
// public class FlightValidator implements ConstraintValidator<FlightValid, Flight> {
// 
// 	@Override
// 	public void initialize(FlightValid constraintAnnotation) {
// 	}
// 
// 	@Override
// 	public boolean isValid(Flight flight, ConstraintValidatorContext context) {
// 		return (flight.getAbt() == null || flight.getEbt() != null)
// 				&& (flight.getEbt() == null || flight.getSbt() != null);
// 	}
// }


// Path: src/test/java/org/vaadin/easybinder/usagetest/VaadinBeanBinderTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.time.ZoneId;
import java.util.stream.Stream;
import javax.validation.constraints.Min;
import org.junit.BeforeClass;
import org.junit.Test;
import org.vaadin.easybinder.testentity.Flight;
import org.vaadin.easybinder.testentity.FlightValid;
import org.vaadin.easybinder.testentity.FlightValidator;
import com.vaadin.data.BeanValidationBinder;
import com.vaadin.data.Binder;
import com.vaadin.data.Converter;
import com.vaadin.data.HasValue;
import com.vaadin.data.RequiredFieldConfigurator;
import com.vaadin.data.Result;
import com.vaadin.data.converter.LocalDateTimeToDateConverter;
import com.vaadin.data.converter.LocalDateToDateConverter;
import com.vaadin.ui.Label;

			if (e.length() == 0) {
				return Result.error("Must be a number");
			}
			try {
				return Result.ok(Integer.parseInt(e));
			} catch (NumberFormatException ex) {
				return Result.error("Must be a number");
			}
		}, e -> Integer.toString(e));

		binder.forField(form.airline).bind("flightId.airline");
		binder.forField(form.flightNumber).withConverter(c).bind("flightId.flightNumber");
		binder.forField(form.flightSuffix)
				.withConverter(Converter.from(
						e -> e.length() == 0 ? Result.ok(null)
								: (e.length() == 1 ? Result.ok(e.charAt(0)) : Result.error("Must be 1 character")),
						f -> f == null ? "" : "" + f))
				.bind("flightId.flightSuffix");
		binder.forField(form.date).withConverter(new LocalDateToDateConverter()).bind("flightId.date");
		binder.forField(form.legType).bind("flightId.legType");
		binder.forField(form.sbt).withConverter(new LocalDateTimeToDateConverter(ZoneId.systemDefault())).bind("sbt");
		binder.forField(form.ebt).withConverter(new LocalDateTimeToDateConverter(ZoneId.systemDefault())).bind("ebt");
		binder.forField(form.abt).withConverter(new LocalDateTimeToDateConverter(ZoneId.systemDefault())).bind("abt");
		Binder.Binding<Flight, String> scheduledDependingBinding = binder.forField(form.gate).withNullRepresentation("")
				.withValidator(e -> form.sbt.getValue() == null ? true : e != null, "Gate should be set when scheduled")
				.bind(Flight::getGate, Flight::setGate);
		form.sbt.addValueChangeListener(e -> scheduledDependingBinding.validate());

		binder.bindInstanceFields(form);

		binder.withValidator(e -> new FlightValidator().isValid(e, null), FlightValid.MESSAGE);