diff options
author | Leif Åstrand <leif@vaadin.com> | 2016-11-28 11:08:38 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-11-29 07:44:01 +0000 |
commit | 3fd7537c14e63e7558acfa553f9996c6cfc323d6 (patch) | |
tree | 8835309e75f6ab94bec9243195a71b5657584c37 | |
parent | 9aee6e6de56666dbb8f70bff32a33d4d0c2520e7 (diff) | |
download | vaadin-framework-3fd7537c14e63e7558acfa553f9996c6cfc323d6.tar.gz vaadin-framework-3fd7537c14e63e7558acfa553f9996c6cfc323d6.zip |
Simplify Binding API by removing the FIELDTYPE type parameter
The type parameter is mainly used internally, the only externally facing
use is to define the exact type of Binding.getField. Code that has
access to a typed instance of Binding does typically also have direct
access to the field instance, so there's no real use for the type
parameter.
Change-Id: Idf2ab18a79ec5f0a7cef83705b8084fbf7014c10
8 files changed, 90 insertions, 100 deletions
diff --git a/server/src/main/java/com/vaadin/data/BeanBinder.java b/server/src/main/java/com/vaadin/data/BeanBinder.java index a2307a5161..8bc207ae56 100644 --- a/server/src/main/java/com/vaadin/data/BeanBinder.java +++ b/server/src/main/java/com/vaadin/data/BeanBinder.java @@ -23,6 +23,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Locale; @@ -40,7 +41,6 @@ import com.vaadin.server.SerializableBiConsumer; import com.vaadin.server.SerializableFunction; import com.vaadin.server.SerializablePredicate; import com.vaadin.util.ReflectTools; -import java.util.Arrays; /** * A {@code Binder} subclass specialized for binding <em>beans</em>: classes @@ -62,44 +62,41 @@ public class BeanBinder<BEAN> extends Binder<BEAN> { * * @param <BEAN> * the bean type - * @param <FIELDVALUE> - * the field value type * @param <TARGET> * the target property type */ - public interface BeanBinding<BEAN, FIELDVALUE, TARGET> - extends Binding<BEAN, FIELDVALUE, TARGET> { + public interface BeanBinding<BEAN, TARGET> extends Binding<BEAN, TARGET> { @Override - public BeanBinding<BEAN, FIELDVALUE, TARGET> withValidator( + public BeanBinding<BEAN, TARGET> withValidator( Validator<? super TARGET> validator); @Override - public default BeanBinding<BEAN, FIELDVALUE, TARGET> withValidator( + public default BeanBinding<BEAN, TARGET> withValidator( SerializablePredicate<? super TARGET> predicate, String message) { - return (BeanBinding<BEAN, FIELDVALUE, TARGET>) Binding.super.withValidator( + return (BeanBinding<BEAN, TARGET>) Binding.super.withValidator( predicate, message); } @Override - public <NEWTARGET> BeanBinding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public <NEWTARGET> BeanBinding<BEAN, NEWTARGET> withConverter( Converter<TARGET, NEWTARGET> converter); @Override - public default <NEWTARGET> BeanBinding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public default <NEWTARGET> BeanBinding<BEAN, NEWTARGET> withConverter( SerializableFunction<TARGET, NEWTARGET> toModel, SerializableFunction<NEWTARGET, TARGET> toPresentation) { - return (BeanBinding<BEAN, FIELDVALUE, NEWTARGET>) Binding.super.withConverter( + return (BeanBinding<BEAN, NEWTARGET>) Binding.super.withConverter( toModel, toPresentation); } @Override - public default <NEWTARGET> BeanBinding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public default <NEWTARGET> BeanBinding<BEAN, NEWTARGET> withConverter( SerializableFunction<TARGET, NEWTARGET> toModel, SerializableFunction<NEWTARGET, TARGET> toPresentation, String errorMessage) { - return (BeanBinding<BEAN, FIELDVALUE, NEWTARGET>) Binding.super.withConverter( + return (BeanBinding<BEAN, NEWTARGET>) Binding.super.withConverter( toModel, toPresentation, errorMessage); } @@ -141,7 +138,7 @@ public class BeanBinder<BEAN> extends Binder<BEAN> { */ protected static class BeanBindingImpl<BEAN, FIELDVALUE, TARGET> extends BindingImpl<BEAN, FIELDVALUE, TARGET> - implements BeanBinding<BEAN, FIELDVALUE, TARGET> { + implements BeanBinding<BEAN, TARGET> { private Method getter; private Method setter; @@ -166,16 +163,15 @@ public class BeanBinder<BEAN> extends Binder<BEAN> { } @Override - public BeanBinding<BEAN, FIELDVALUE, TARGET> withValidator( + public BeanBinding<BEAN, TARGET> withValidator( Validator<? super TARGET> validator) { - return (BeanBinding<BEAN, FIELDVALUE, TARGET>) super.withValidator( - validator); + return (BeanBinding<BEAN, TARGET>) super.withValidator(validator); } @Override - public <NEWTARGET> BeanBinding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public <NEWTARGET> BeanBinding<BEAN, NEWTARGET> withConverter( Converter<TARGET, NEWTARGET> converter) { - return (BeanBinding<BEAN, FIELDVALUE, NEWTARGET>) super.withConverter( + return (BeanBinding<BEAN, NEWTARGET>) super.withConverter( converter); } @@ -183,7 +179,7 @@ public class BeanBinder<BEAN> extends Binder<BEAN> { public void bind(String propertyName) { checkUnbound(); - Binding<BEAN, FIELDVALUE, Object> finalBinding; + Binding<BEAN, Object> finalBinding; finalBinding = withConverter(createConverter(), false); @@ -281,10 +277,9 @@ public class BeanBinder<BEAN> extends Binder<BEAN> { } @Override - public <FIELDVALUE> BeanBinding<BEAN, FIELDVALUE, FIELDVALUE> forField( + public <FIELDVALUE> BeanBinding<BEAN, FIELDVALUE> forField( HasValue<FIELDVALUE> field) { - return (BeanBinding<BEAN, FIELDVALUE, FIELDVALUE>) super.forField( - field); + return (BeanBinding<BEAN, FIELDVALUE>) super.forField(field); } /** @@ -481,7 +476,8 @@ public class BeanBinder<BEAN> extends Binder<BEAN> { ArrayList<Field> memberFieldInOrder = new ArrayList<>(); while (searchClass != null) { - memberFieldInOrder.addAll(Arrays.asList(searchClass.getDeclaredFields())); + memberFieldInOrder + .addAll(Arrays.asList(searchClass.getDeclaredFields())); searchClass = searchClass.getSuperclass(); } return memberFieldInOrder; diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java index df6d72d79c..65e791931d 100644 --- a/server/src/main/java/com/vaadin/data/Binder.java +++ b/server/src/main/java/com/vaadin/data/Binder.java @@ -92,15 +92,13 @@ public class Binder<BEAN> implements Serializable { * * @param <BEAN> * the bean type - * @param <FIELDVALUE> - * the value type of the field * @param <TARGET> * the target data type of the binding, matches the field type * until a converter has been set * * @see Binder#forField(HasValue) */ - public interface Binding<BEAN, FIELDVALUE, TARGET> extends Serializable { + public interface Binding<BEAN, TARGET> extends Serializable { /** * Completes this binding using the given getter and setter functions @@ -159,7 +157,7 @@ public class Binder<BEAN> implements Serializable { * @throws IllegalStateException * if {@code bind} has already been called */ - public Binding<BEAN, FIELDVALUE, TARGET> withValidator( + public Binding<BEAN, TARGET> withValidator( Validator<? super TARGET> validator); /** @@ -182,7 +180,7 @@ public class Binder<BEAN> implements Serializable { * @throws IllegalStateException * if {@code bind} has already been called */ - public default Binding<BEAN, FIELDVALUE, TARGET> withValidator( + public default Binding<BEAN, TARGET> withValidator( SerializablePredicate<? super TARGET> predicate, String message) { return withValidator(Validator.from(predicate, message)); @@ -209,7 +207,7 @@ public class Binder<BEAN> implements Serializable { * @throws IllegalStateException * if {@code bind} has already been called */ - public default Binding<BEAN, FIELDVALUE, TARGET> withValidator( + public default Binding<BEAN, TARGET> withValidator( SerializablePredicate<? super TARGET> predicate, ErrorMessageProvider errorMessageProvider) { return withValidator( @@ -239,7 +237,7 @@ public class Binder<BEAN> implements Serializable { * @throws IllegalStateException * if {@code bind} has already been called */ - public <NEWTARGET> Binding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public <NEWTARGET> Binding<BEAN, NEWTARGET> withConverter( Converter<TARGET, NEWTARGET> converter); /** @@ -269,7 +267,7 @@ public class Binder<BEAN> implements Serializable { * @throws IllegalStateException * if {@code bind} has already been called */ - public default <NEWTARGET> Binding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public default <NEWTARGET> Binding<BEAN, NEWTARGET> withConverter( SerializableFunction<TARGET, NEWTARGET> toModel, SerializableFunction<NEWTARGET, TARGET> toPresentation) { return withConverter(Converter.from(toModel, toPresentation, @@ -307,7 +305,7 @@ public class Binder<BEAN> implements Serializable { * @throws IllegalStateException * if {@code bind} has already been called */ - public default <NEWTARGET> Binding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public default <NEWTARGET> Binding<BEAN, NEWTARGET> withConverter( SerializableFunction<TARGET, NEWTARGET> toModel, SerializableFunction<NEWTARGET, TARGET> toPresentation, String errorMessage) { @@ -323,7 +321,7 @@ public class Binder<BEAN> implements Serializable { * the value to use instead of {@code null} * @return a new binding with null representation handling. */ - public default Binding<BEAN, FIELDVALUE, TARGET> withNullRepresentation( + public default Binding<BEAN, TARGET> withNullRepresentation( TARGET nullRepresentation) { return withConverter( fieldValue -> Objects.equals(fieldValue, nullRepresentation) @@ -337,7 +335,7 @@ public class Binder<BEAN> implements Serializable { * * @return the field for the binding */ - public HasValue<FIELDVALUE> getField(); + public HasValue<?> getField(); /** * Sets the given {@code label} to show an error message if validation @@ -371,8 +369,7 @@ public class Binder<BEAN> implements Serializable { * label to show validation status for the field * @return this binding, for chaining */ - public default Binding<BEAN, FIELDVALUE, TARGET> withStatusLabel( - Label label) { + public default Binding<BEAN, TARGET> withStatusLabel(Label label) { return withValidationStatusHandler(status -> { label.setValue(status.getMessage().orElse("")); // Only show the label when validation has failed @@ -409,7 +406,7 @@ public class Binder<BEAN> implements Serializable { * status change handler * @return this binding, for chaining */ - public Binding<BEAN, FIELDVALUE, TARGET> withValidationStatusHandler( + public Binding<BEAN, TARGET> withValidationStatusHandler( ValidationStatusHandler handler); /** @@ -442,8 +439,7 @@ public class Binder<BEAN> implements Serializable { * the error message to show for the invalid value * @return this binding, for chaining */ - public default Binding<BEAN, FIELDVALUE, TARGET> setRequired( - String errorMessage) { + public default Binding<BEAN, TARGET> setRequired(String errorMessage) { return setRequired(context -> errorMessage); } @@ -462,7 +458,7 @@ public class Binder<BEAN> implements Serializable { * the provider for localized validation error message * @return this binding, for chaining */ - public Binding<BEAN, FIELDVALUE, TARGET> setRequired( + public Binding<BEAN, TARGET> setRequired( ErrorMessageProvider errorMessageProvider); } @@ -478,7 +474,7 @@ public class Binder<BEAN> implements Serializable { * until a converter has been set */ protected static class BindingImpl<BEAN, FIELDVALUE, TARGET> - implements Binding<BEAN, FIELDVALUE, TARGET> { + implements Binding<BEAN, TARGET> { private final Binder<BEAN> binder; @@ -534,7 +530,7 @@ public class Binder<BEAN> implements Serializable { } @Override - public Binding<BEAN, FIELDVALUE, TARGET> withValidator( + public Binding<BEAN, TARGET> withValidator( Validator<? super TARGET> validator) { checkUnbound(); Objects.requireNonNull(validator, "validator cannot be null"); @@ -545,13 +541,13 @@ public class Binder<BEAN> implements Serializable { } @Override - public <NEWTARGET> Binding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + public <NEWTARGET> Binding<BEAN, NEWTARGET> withConverter( Converter<TARGET, NEWTARGET> converter) { return withConverter(converter, true); } @Override - public Binding<BEAN, FIELDVALUE, TARGET> withValidationStatusHandler( + public Binding<BEAN, TARGET> withValidationStatusHandler( ValidationStatusHandler handler) { checkUnbound(); Objects.requireNonNull(handler, "handler cannot be null"); @@ -566,7 +562,7 @@ public class Binder<BEAN> implements Serializable { } @Override - public Binding<BEAN, FIELDVALUE, TARGET> setRequired( + public Binding<BEAN, TARGET> setRequired( ErrorMessageProvider errorMessageProvider) { checkUnbound(); @@ -601,7 +597,7 @@ public class Binder<BEAN> implements Serializable { * @throws IllegalStateException * if {@code bind} has already been called */ - protected <NEWTARGET> Binding<BEAN, FIELDVALUE, NEWTARGET> withConverter( + protected <NEWTARGET> Binding<BEAN, NEWTARGET> withConverter( Converter<TARGET, NEWTARGET> converter, boolean resetNullRepresentation) { checkUnbound(); @@ -920,7 +916,7 @@ public class Binder<BEAN> implements Serializable { * * @see #bind(HasValue, SerializableFunction, SerializableBiConsumer) */ - public <FIELDVALUE> Binding<BEAN, FIELDVALUE, FIELDVALUE> forField( + public <FIELDVALUE> Binding<BEAN, FIELDVALUE> forField( HasValue<FIELDVALUE> field) { Objects.requireNonNull(field, "field cannot be null"); // clear previous errors for this field and any bean level validation @@ -1139,7 +1135,7 @@ public class Binder<BEAN> implements Serializable { } // Store old bean values so we can restore them if validators fail - Map<Binding<BEAN, ?, ?>, Object> oldValues = new HashMap<>(); + Map<Binding<BEAN, ?>, Object> oldValues = new HashMap<>(); bindings.forEach( binding -> oldValues.put(binding, binding.getter.apply(bean))); @@ -1435,7 +1431,7 @@ public class Binder<BEAN> implements Serializable { * the handler to notify of status changes, not null * @return the new incomplete binding */ - protected <FIELDVALUE, TARGET> Binding<BEAN, FIELDVALUE, TARGET> createBinding( + protected <FIELDVALUE, TARGET> Binding<BEAN, TARGET> createBinding( HasValue<FIELDVALUE> field, Converter<FIELDVALUE, TARGET> converter, ValidationStatusHandler handler) { return new BindingImpl<>(this, field, converter, handler); diff --git a/server/src/main/java/com/vaadin/data/ValidationStatus.java b/server/src/main/java/com/vaadin/data/ValidationStatus.java index 66e34eb6dd..bbc4326b60 100644 --- a/server/src/main/java/com/vaadin/data/ValidationStatus.java +++ b/server/src/main/java/com/vaadin/data/ValidationStatus.java @@ -69,7 +69,7 @@ public class ValidationStatus<TARGET> implements Serializable { private final Status status; private final ValidationResult result; - private final Binding<?, ?, TARGET> binding; + private final Binding<?, TARGET> binding; /** * Convenience method for creating a {@link Status#UNRESOLVED} validation @@ -83,7 +83,7 @@ public class ValidationStatus<TARGET> implements Serializable { * status was reset */ public static <TARGET> ValidationStatus<TARGET> createUnresolvedStatus( - Binding<?, ?, TARGET> source) { + Binding<?, TARGET> source) { return new ValidationStatus<>(source, Status.UNRESOLVED, null); } @@ -96,7 +96,7 @@ public class ValidationStatus<TARGET> implements Serializable { * @param result * the result of the validation */ - public ValidationStatus(Binding<?, ?, TARGET> source, + public ValidationStatus(Binding<?, TARGET> source, ValidationResult result) { this(source, result.isError() ? Status.ERROR : Status.OK, result); } @@ -114,7 +114,7 @@ public class ValidationStatus<TARGET> implements Serializable { * @param result * the related result, may be {@code null} */ - public ValidationStatus(Binding<?, ?, TARGET> source, Status status, + public ValidationStatus(Binding<?, TARGET> source, Status status, ValidationResult result) { Objects.requireNonNull(source, "Event source may not be null"); Objects.requireNonNull(status, "Status may not be null"); @@ -177,7 +177,7 @@ public class ValidationStatus<TARGET> implements Serializable { * * @return the source binding */ - public Binding<?, ?, TARGET> getBinding() { + public Binding<?, TARGET> getBinding() { return binding; } diff --git a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java index 14a6be0307..5aafc475ef 100644 --- a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java +++ b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java @@ -249,15 +249,14 @@ public class BinderBookOfVaadinTest { // Slider for integers between 1 and 10 Slider salaryLevelField = new Slider("Salary level", 1, 10); - Binding<BookPerson, String, String> b1 = binder - .forField(yearOfBirthField); - Binding<BookPerson, String, Integer> b2 = b1.withConverter( + Binding<BookPerson, String> b1 = binder.forField(yearOfBirthField); + Binding<BookPerson, Integer> b2 = b1.withConverter( new StringToIntegerConverter("Must enter a number")); b2.bind(BookPerson::getYearOfBirth, BookPerson::setYearOfBirth); - Binding<BookPerson, Double, Double> salaryBinding1 = binder + Binding<BookPerson, Double> salaryBinding1 = binder .forField(salaryLevelField); - Binding<BookPerson, Double, Integer> salaryBinding2 = salaryBinding1 + Binding<BookPerson, Integer> salaryBinding2 = salaryBinding1 .withConverter(Double::intValue, Integer::doubleValue); salaryBinding2.bind(BookPerson::getSalaryLevel, BookPerson::setSalaryLevel); @@ -305,8 +304,8 @@ public class BinderBookOfVaadinTest { DateField departing = new DateField("Departing"); DateField returning = new DateField("Returning"); - Binding<Trip, LocalDate, LocalDate> returnBinding = binder - .forField(returning).withValidator( + Binding<Trip, LocalDate> returnBinding = binder.forField(returning) + .withValidator( returnDate -> !returnDate .isBefore(departing.getValue()), "Cannot return before departing"); @@ -358,8 +357,8 @@ public class BinderBookOfVaadinTest { DateField departing = new DateField("Departing"); DateField returning = new DateField("Returning"); - Binding<Trip, LocalDate, LocalDate> returnBinding = binder - .forField(returning).withValidator( + Binding<Trip, LocalDate> returnBinding = binder.forField(returning) + .withValidator( returnDate -> !returnDate .isBefore(departing.getValue()), "Cannot return before departing"); diff --git a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java index b3d6d62c0b..9ad8dca2c3 100644 --- a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java +++ b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java @@ -73,7 +73,7 @@ public class BinderConverterValidatorTest @Test public void bound_validatorsAreOK_noErrors() { - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.withValidator(Validator.alwaysPass()).bind(Person::getFirstName, Person::setFirstName); @@ -87,7 +87,7 @@ public class BinderConverterValidatorTest @SuppressWarnings("serial") @Test public void bound_validatorsFail_errors() { - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.withValidator(Validator.alwaysPass()); String msg1 = "foo"; String msg2 = "bar"; @@ -221,7 +221,7 @@ public class BinderConverterValidatorTest bean.setStatus("1"); Binder<StatusBean> binder = new Binder<>(); - Binding<StatusBean, String, String> binding = binder.forField(field) + Binding<StatusBean, String> binding = binder.forField(field) .withConverter(presentation -> { if (presentation.equals("OK")) { return "1"; @@ -266,7 +266,7 @@ public class BinderConverterValidatorTest public void validate_failedBeanValidatorWithFieldValidator() { String msg = "foo"; - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(new NotEmptyValidator<>(msg)); binding.bind(Person::getFirstName, Person::setFirstName); @@ -286,7 +286,7 @@ public class BinderConverterValidatorTest public void validate_failedBothBeanValidatorAndFieldValidator() { String msg1 = "foo"; - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(new NotEmptyValidator<>(msg1)); binding.bind(Person::getFirstName, Person::setFirstName); @@ -322,7 +322,7 @@ public class BinderConverterValidatorTest @Test public void binder_saveIfValid() { String msg1 = "foo"; - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(new NotEmptyValidator<>(msg1)); binding.bind(Person::getFirstName, Person::setFirstName); @@ -554,11 +554,11 @@ public class BinderConverterValidatorTest public void save_validationErrors_exceptionContainsErrors() throws ValidationException { String msg = "foo"; - Binding<Person, String, String> nameBinding = binder.forField(nameField) + Binding<Person, String> nameBinding = binder.forField(nameField) .withValidator(new NotEmptyValidator<>(msg)); nameBinding.bind(Person::getFirstName, Person::setFirstName); - Binding<Person, String, Integer> ageBinding = binder.forField(ageField) + Binding<Person, Integer> ageBinding = binder.forField(ageField) .withConverter(stringToInteger).withValidator(notNegative); ageBinding.bind(Person::getAge, Person::setAge); @@ -585,7 +585,7 @@ public class BinderConverterValidatorTest @Test public void binderBindAndLoad_clearsErrors() { - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty); binding.bind(Person::getFirstName, Person::setFirstName); binder.withValidator(bean -> !bean.getFirstName().contains("error"), @@ -621,8 +621,8 @@ public class BinderConverterValidatorTest // bind a new field that has invalid value in bean TextField lastNameField = new TextField(); person.setLastName(""); - Binding<Person, String, String> binding2 = binder - .forField(lastNameField).withValidator(notEmpty); + Binding<Person, String> binding2 = binder.forField(lastNameField) + .withValidator(notEmpty); binding2.bind(Person::getLastName, Person::setLastName); // should not have error shown @@ -663,12 +663,11 @@ public class BinderConverterValidatorTest final SerializablePredicate<String> lengthPredicate = v -> v .length() > 2; - Binding<Person, String, String> firstNameBinding = binder - .forField(nameField).withValidator(lengthPredicate, "length"); + Binding<Person, String> firstNameBinding = binder.forField(nameField) + .withValidator(lengthPredicate, "length"); firstNameBinding.bind(Person::getFirstName, Person::setFirstName); - Binding<Person, String, String> lastNameBinding = binder - .forField(lastNameField) + Binding<Person, String> lastNameBinding = binder.forField(lastNameField) .withValidator(v -> !nameField.getValue().isEmpty() || lengthPredicate.test(v), "err") .withValidator(lengthPredicate, "length"); diff --git a/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java b/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java index 1e03a22fd7..e453e68482 100644 --- a/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java +++ b/server/src/test/java/com/vaadin/data/BinderStatusChangeTest.java @@ -45,7 +45,7 @@ public class BinderStatusChangeTest public void bindBinding_unbound_eventWhenBoundEndnoEventsBeforeBound() { binder.addStatusChangeListener(this::statusChanged); - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); nameField.setValue(""); Assert.assertNull(event.get()); @@ -377,7 +377,7 @@ public class BinderStatusChangeTest @Test public void validateBinding_noValidationErrors_statusEventWithoutErrors() { - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.bind(Person::getFirstName, Person::setFirstName); binder.forField(ageField) .withConverter(new StringToIntegerConverter("")) @@ -393,7 +393,7 @@ public class BinderStatusChangeTest @Test public void validateBinding_validationErrors_statusEventWithError() { - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(name -> false, ""); binding.bind(Person::getFirstName, Person::setFirstName); binder.forField(ageField) diff --git a/server/src/test/java/com/vaadin/data/BinderTest.java b/server/src/test/java/com/vaadin/data/BinderTest.java index 0ad86b9f19..7f2353a448 100644 --- a/server/src/test/java/com/vaadin/data/BinderTest.java +++ b/server/src/test/java/com/vaadin/data/BinderTest.java @@ -331,7 +331,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { TextField textField = new TextField(); Assert.assertFalse(textField.isRequiredIndicatorVisible()); - Binding<Person, String, String> binding = binder.forField(textField); + Binding<Person, String> binding = binder.forField(textField); Assert.assertFalse(textField.isRequiredIndicatorVisible()); binding.setRequired("foobar"); @@ -357,7 +357,7 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> { textField.setLocale(Locale.CANADA); Assert.assertFalse(textField.isRequiredIndicatorVisible()); - Binding<Person, String, String> binding = binder.forField(textField); + Binding<Person, String> binding = binder.forField(textField); Assert.assertFalse(textField.isRequiredIndicatorVisible()); AtomicInteger invokes = new AtomicInteger(); diff --git a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java index 6cef908aef..d901ee00d8 100644 --- a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java +++ b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java @@ -48,7 +48,7 @@ public class BinderValidationStatusTest @Test public void bindingWithStatusHandler_handlerGetsEvents() { AtomicReference<ValidationStatus<?>> statusCapture = new AtomicReference<>(); - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty).withValidationStatusHandler(evt -> { Assert.assertNull(statusCapture.get()); statusCapture.set(evt); @@ -84,7 +84,7 @@ public class BinderValidationStatusTest @Test public void bindingWithStatusHandler_defaultStatusHandlerIsReplaced() { - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty).withValidationStatusHandler(evt -> { }); binding.bind(Person::getFirstName, Person::setFirstName); @@ -105,7 +105,7 @@ public class BinderValidationStatusTest public void bindingWithStatusLabel_labelIsUpdatedAccordingStatus() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty).withStatusLabel(label); binding.bind(Person::getFirstName, Person::setFirstName); @@ -132,7 +132,7 @@ public class BinderValidationStatusTest public void bindingWithStatusLabel_defaultStatusHandlerIsReplaced() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty).withStatusLabel(label); binding.bind(Person::getFirstName, Person::setFirstName); @@ -150,7 +150,7 @@ public class BinderValidationStatusTest @Test(expected = IllegalStateException.class) public void bindingWithStatusHandler_addAfterBound() { - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty); binding.bind(Person::getFirstName, Person::setFirstName); @@ -161,7 +161,7 @@ public class BinderValidationStatusTest public void bindingWithStatusLabel_addAfterBound() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty); binding.bind(Person::getFirstName, Person::setFirstName); @@ -172,7 +172,7 @@ public class BinderValidationStatusTest public void bindingWithStatusLabel_setAfterHandler() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.withValidationStatusHandler(NOOP); @@ -183,7 +183,7 @@ public class BinderValidationStatusTest public void bindingWithStatusHandler_setAfterLabel() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.withStatusLabel(label); @@ -193,7 +193,7 @@ public class BinderValidationStatusTest @Test(expected = IllegalStateException.class) public void bindingWithStatusHandler_setAfterOtherHandler() { - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.withValidationStatusHandler(NOOP); @@ -392,7 +392,7 @@ public class BinderValidationStatusTest @Test public void binderWithStatusHandler_defaultStatusHandlerIsReplaced() { - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty).withValidationStatusHandler(evt -> { }); binding.bind(Person::getFirstName, Person::setFirstName); @@ -413,7 +413,7 @@ public class BinderValidationStatusTest public void binderWithStatusLabel_defaultStatusHandlerIsReplaced() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty).withStatusLabel(label); binding.bind(Person::getFirstName, Person::setFirstName); @@ -431,7 +431,7 @@ public class BinderValidationStatusTest @Test(expected = IllegalStateException.class) public void binderWithStatusHandler_addAfterBound() { - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty); binding.bind(Person::getFirstName, Person::setFirstName); @@ -442,7 +442,7 @@ public class BinderValidationStatusTest public void binderWithStatusLabel_addAfterBound() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField) + Binding<Person, String> binding = binder.forField(nameField) .withValidator(notEmpty); binding.bind(Person::getFirstName, Person::setFirstName); @@ -453,7 +453,7 @@ public class BinderValidationStatusTest public void binderWithStatusLabel_setAfterHandler() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.bind(Person::getFirstName, Person::setFirstName); binder.setValidationStatusHandler(event -> { @@ -466,7 +466,7 @@ public class BinderValidationStatusTest public void binderWithStatusHandler_setAfterLabel() { Label label = new Label(); - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.bind(Person::getFirstName, Person::setFirstName); binder.setStatusLabel(label); @@ -484,7 +484,7 @@ public class BinderValidationStatusTest public void binderWithStatusHandler_replaceHandler() { AtomicReference<BinderValidationStatus<?>> capture = new AtomicReference<>(); - Binding<Person, String, String> binding = binder.forField(nameField); + Binding<Person, String> binding = binder.forField(nameField); binding.bind(Person::getFirstName, Person::setFirstName); binder.setValidationStatusHandler(results -> { |