From ce26bf7c4ce2d3f4a40904d103cb85bdd8fb17c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pekka=20Hyv=C3=B6nen?= Date: Wed, 14 Dec 2016 15:12:13 +0200 Subject: [PATCH] Remove usage of Consumer from event listeners (#7985) Touched event listeners are: - SelectionListener - MultiSelectionListener - SingleSelectionListener - ValueChangeListener - ItemClickListener - BindingValidationStatusHandler - BinderValidationStatusHandler - StatusChangeListener Part of vaadin/framework8-issues#264 --- .../main/java/com/vaadin/data/BeanBinder.java | 8 +- .../src/main/java/com/vaadin/data/Binder.java | 80 +++++++++---------- .../vaadin/data/BinderValidationStatus.java | 16 ++-- .../data/BinderValidationStatusHandler.java | 16 ++-- ...atus.java => BindingValidationStatus.java} | 18 ++--- ...va => BindingValidationStatusHandler.java} | 19 +++-- .../main/java/com/vaadin/data/HasValue.java | 14 ++-- .../com/vaadin/data/StatusChangeListener.java | 15 ++-- .../com/vaadin/data/ValidationException.java | 6 +- .../selection/MultiSelectionListener.java | 34 +++++--- .../event/selection/SelectionListener.java | 13 ++- .../selection/SingleSelectionListener.java | 32 +++++--- .../java/com/vaadin/ui/AbstractField.java | 8 +- .../com/vaadin/ui/AbstractMultiSelect.java | 11 +-- .../com/vaadin/ui/AbstractSingleSelect.java | 11 +-- .../src/main/java/com/vaadin/ui/ComboBox.java | 2 +- server/src/main/java/com/vaadin/ui/Grid.java | 19 ++--- .../vaadin/ui/components/grid/EditorImpl.java | 2 +- .../grid/MultiSelectionModelImpl.java | 12 +-- .../grid/SingleSelectionModelImpl.java | 10 +-- .../java/com/vaadin/data/BeanBinderTest.java | 2 +- .../vaadin/data/BinderBookOfVaadinTest.java | 10 +-- .../data/BinderConverterValidatorTest.java | 20 ++--- .../data/BinderValidationStatusTest.java | 18 ++--- .../grid/GridMultiSelectionModelTest.java | 2 +- .../grid/GridSingleSelectionModelTest.java | 2 +- .../java/com/vaadin/ui/AbstractFieldTest.java | 4 +- .../vaadin/ui/AbstractMultiSelectTest.java | 2 +- .../vaadin/ui/AbstractSingleSelectTest.java | 2 +- .../abstractfield/AbstractFieldTest.java | 2 +- .../components/datefield/LenientMode.java | 2 +- .../HeaderFooterClickLeftRightMiddle.java | 4 +- 32 files changed, 216 insertions(+), 200 deletions(-) rename server/src/main/java/com/vaadin/data/{ValidationStatus.java => BindingValidationStatus.java} (89%) rename server/src/main/java/com/vaadin/data/{ValidationStatusHandler.java => BindingValidationStatusHandler.java} (72%) diff --git a/server/src/main/java/com/vaadin/data/BeanBinder.java b/server/src/main/java/com/vaadin/data/BeanBinder.java index 8231c56bfc..64beee5264 100644 --- a/server/src/main/java/com/vaadin/data/BeanBinder.java +++ b/server/src/main/java/com/vaadin/data/BeanBinder.java @@ -130,7 +130,7 @@ public class BeanBinder extends Binder { @Override public BeanBindingBuilder withValidationStatusHandler( - ValidationStatusHandler handler); + BindingValidationStatusHandler handler); @Override public default BeanBindingBuilder withStatusLabel( @@ -196,7 +196,7 @@ public class BeanBinder extends Binder { protected BeanBindingImpl(BeanBinder binder, HasValue field, Converter converter, - ValidationStatusHandler statusHandler) { + BindingValidationStatusHandler statusHandler) { super(binder, field, converter, statusHandler); } @@ -216,7 +216,7 @@ public class BeanBinder extends Binder { @Override public BeanBindingBuilder withValidationStatusHandler( - ValidationStatusHandler handler) { + BindingValidationStatusHandler handler) { return (BeanBindingBuilder) super.withValidationStatusHandler( handler); } @@ -377,7 +377,7 @@ public class BeanBinder extends Binder { @Override protected BeanBindingImpl createBinding( HasValue field, Converter converter, - ValidationStatusHandler handler) { + BindingValidationStatusHandler handler) { Objects.requireNonNull(field, "field cannot be null"); Objects.requireNonNull(converter, "converter cannot be null"); return new BeanBindingImpl<>(this, field, converter, handler); diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java index 794c6807c4..c419caf7b0 100644 --- a/server/src/main/java/com/vaadin/data/Binder.java +++ b/server/src/main/java/com/vaadin/data/Binder.java @@ -116,7 +116,7 @@ public class Binder implements Serializable { * * @return the validation result. */ - public ValidationStatus validate(); + public BindingValidationStatus validate(); } @@ -383,15 +383,15 @@ public class Binder implements Serializable { * default behavior). *

* This is just a shorthand for - * {@link #withValidationStatusHandler(ValidationStatusHandler)} method + * {@link #withValidationStatusHandler(BindingValidationStatusHandler)} method * where the handler instance hides the {@code label} if there is no * error and shows it with validation error message if validation fails. * It means that it cannot be called after - * {@link #withValidationStatusHandler(ValidationStatusHandler)} method - * call or {@link #withValidationStatusHandler(ValidationStatusHandler)} + * {@link #withValidationStatusHandler(BindingValidationStatusHandler)} method + * call or {@link #withValidationStatusHandler(BindingValidationStatusHandler)} * after this method call. * - * @see #withValidationStatusHandler(ValidationStatusHandler) + * @see #withValidationStatusHandler(BindingValidationStatusHandler) * @see AbstractComponent#setComponentError(ErrorMessage) * @param label * label to show validation status for the field @@ -407,7 +407,7 @@ public class Binder implements Serializable { } /** - * Sets a {@link ValidationStatusHandler} to track validation status + * Sets a {@link BindingValidationStatusHandler} to track validation status * changes. *

* The validation state of each field is updated whenever the user @@ -436,7 +436,7 @@ public class Binder implements Serializable { * @return this binding, for chaining */ public BindingBuilder withValidationStatusHandler( - ValidationStatusHandler handler); + BindingValidationStatusHandler handler); /** * Sets the field to be required. This means two things: @@ -498,7 +498,7 @@ public class Binder implements Serializable { private final Binder binder; private final HasValue field; - private ValidationStatusHandler statusHandler; + private BindingValidationStatusHandler statusHandler; private boolean isStatusHandlerChanged; private boolean bound; @@ -526,7 +526,7 @@ public class Binder implements Serializable { protected BindingBuilderImpl(Binder binder, HasValue field, Converter converterValidatorChain, - ValidationStatusHandler statusHandler) { + BindingValidationStatusHandler statusHandler) { this.field = field; this.binder = binder; this.converterValidatorChain = converterValidatorChain; @@ -573,12 +573,12 @@ public class Binder implements Serializable { @Override public BindingBuilder withValidationStatusHandler( - ValidationStatusHandler handler) { + BindingValidationStatusHandler handler) { checkUnbound(); Objects.requireNonNull(handler, "handler cannot be null"); if (isStatusHandlerChanged) { throw new IllegalStateException( - "A " + ValidationStatusHandler.class.getSimpleName() + "A " + BindingValidationStatusHandler.class.getSimpleName() + " has already been set"); } isStatusHandlerChanged = true; @@ -672,7 +672,7 @@ public class Binder implements Serializable { private final Binder binder; private final HasValue field; - private final ValidationStatusHandler statusHandler; + private final BindingValidationStatusHandler statusHandler; private final SerializableFunction getter; private final SerializableBiConsumer setter; @@ -726,10 +726,10 @@ public class Binder implements Serializable { } @Override - public ValidationStatus validate() { - ValidationStatus status = doValidation(); + public BindingValidationStatus validate() { + BindingValidationStatus status = doValidation(); getBinder().getValidationStatusHandler() - .accept(new BinderValidationStatus<>(getBinder(), + .statusChange(new BinderValidationStatus<>(getBinder(), Arrays.asList(status), Collections.emptyList())); getBinder().fireStatusChangeEvent(status.isError()); return status; @@ -737,7 +737,7 @@ public class Binder implements Serializable { /** * Returns the field value run through all converters and validators, - * but doesn't pass the {@link ValidationStatus} to any status handler. + * but doesn't pass the {@link BindingValidationStatus} to any status handler. * * @return the result of the conversion */ @@ -747,9 +747,9 @@ public class Binder implements Serializable { createValueContext()); } - private ValidationStatus toValidationStatus( + private BindingValidationStatus toValidationStatus( Result result) { - return new ValidationStatus<>(this, + return new BindingValidationStatus<>(this, result.isError() ? ValidationResult.error(result.getMessage().get()) : ValidationResult.ok()); @@ -757,11 +757,11 @@ public class Binder implements Serializable { /** * Returns the field value run through all converters and validators, - * but doesn't pass the {@link ValidationStatus} to any status handler. + * but doesn't pass the {@link BindingValidationStatus} to any status handler. * * @return the validation status */ - private ValidationStatus doValidation() { + private BindingValidationStatus doValidation() { return toValidationStatus(doConversion()); } @@ -814,13 +814,13 @@ public class Binder implements Serializable { getBinder().setHasChanges(true); List binderValidationResults = Collections .emptyList(); - ValidationStatus fieldValidationStatus; + BindingValidationStatus fieldValidationStatus; if (getBinder().getBean() != null) { BEAN bean = getBinder().getBean(); fieldValidationStatus = writeFieldValue(bean); if (!getBinder().bindings.stream() .map(BindingImpl::doValidation) - .anyMatch(ValidationStatus::isError)) { + .anyMatch(BindingValidationStatus::isError)) { binderValidationResults = getBinder().validateBean(bean); if (!binderValidationResults.stream() .anyMatch(ValidationResult::isError)) { @@ -833,7 +833,7 @@ public class Binder implements Serializable { BinderValidationStatus status = new BinderValidationStatus<>( getBinder(), Arrays.asList(fieldValidationStatus), binderValidationResults); - getBinder().getValidationStatusHandler().accept(status); + getBinder().getValidationStatusHandler().statusChange(status); getBinder().fireStatusChangeEvent(status.hasErrors()); } @@ -844,7 +844,7 @@ public class Binder implements Serializable { * @param bean * the bean to set the property value to */ - private ValidationStatus writeFieldValue(BEAN bean) { + private BindingValidationStatus writeFieldValue(BEAN bean) { assert bean != null; Result result = doConversion(); @@ -864,8 +864,8 @@ public class Binder implements Serializable { return binder; } - private void notifyStatusHandler(ValidationStatus status) { - statusHandler.accept(status); + private void notifyStatusHandler(BindingValidationStatus status) { + statusHandler.statusChange(status); } } @@ -1099,7 +1099,7 @@ public class Binder implements Serializable { bindings.forEach(b -> b.initFieldValue(bean)); // if there has been field value change listeners that trigger // validation, need to make sure the validation errors are cleared - getValidationStatusHandler().accept( + getValidationStatusHandler().statusChange( BinderValidationStatus.createUnresolvedStatus(this)); fireStatusChangeEvent(false); } @@ -1136,7 +1136,7 @@ public class Binder implements Serializable { bindings.forEach(binding -> binding.initFieldValue(bean)); getValidationStatusHandler() - .accept(BinderValidationStatus.createUnresolvedStatus(this)); + .statusChange(BinderValidationStatus.createUnresolvedStatus(this)); fireStatusChangeEvent(false); } @@ -1208,9 +1208,9 @@ public class Binder implements Serializable { private BinderValidationStatus doWriteIfValid(BEAN bean) { Objects.requireNonNull(bean, "bean cannot be null"); // First run fields level validation - List> bindingStatuses = validateBindings(); + List> bindingStatuses = validateBindings(); // If no validation errors then update bean - if (bindingStatuses.stream().filter(ValidationStatus::isError).findAny() + if (bindingStatuses.stream().filter(BindingValidationStatus::isError).findAny() .isPresent()) { fireStatusChangeEvent(true); return new BinderValidationStatus<>(this, bindingStatuses, @@ -1324,10 +1324,10 @@ public class Binder implements Serializable { * @return validation status for the binder */ public BinderValidationStatus validate() { - List> bindingStatuses = validateBindings(); + List> bindingStatuses = validateBindings(); BinderValidationStatus validationStatus; - if (bindingStatuses.stream().filter(ValidationStatus::isError).findAny() + if (bindingStatuses.stream().filter(BindingValidationStatus::isError).findAny() .isPresent() || bean == null) { validationStatus = new BinderValidationStatus<>(this, bindingStatuses, Collections.emptyList()); @@ -1335,7 +1335,7 @@ public class Binder implements Serializable { validationStatus = new BinderValidationStatus<>(this, bindingStatuses, validateBean(bean)); } - getValidationStatusHandler().accept(validationStatus); + getValidationStatusHandler().statusChange(validationStatus); fireStatusChangeEvent(validationStatus.hasErrors()); return validationStatus; } @@ -1350,8 +1350,8 @@ public class Binder implements Serializable { * * @return an immutable list of validation results for bindings */ - private List> validateBindings() { - List> results = new ArrayList<>(); + private List> validateBindings() { + List> results = new ArrayList<>(); for (BindingImpl binding : bindings) { results.add(binding.doValidation()); } @@ -1433,7 +1433,7 @@ public class Binder implements Serializable { * @throws NullPointerException * for null status handler * @see #setStatusLabel(Label) - * @see BindingBuilder#withValidationStatusHandler(ValidationStatusHandler) + * @see BindingBuilder#withValidationStatusHandler(BindingValidationStatusHandler) */ public void setValidationStatusHandler( BinderValidationStatusHandler statusHandler) { @@ -1516,7 +1516,7 @@ public class Binder implements Serializable { */ protected BindingBuilder createBinding( HasValue field, Converter converter, - ValidationStatusHandler handler) { + BindingValidationStatusHandler handler) { return new BindingBuilderImpl<>(this, field, converter, handler); } @@ -1554,12 +1554,12 @@ public class Binder implements Serializable { } /** - * Default {@link ValidationStatusHandler} functional method implementation. + * Default {@link BindingValidationStatusHandler} functional method implementation. * * @param status * the validation status */ - protected void handleValidationStatus(ValidationStatus status) { + protected void handleValidationStatus(BindingValidationStatus status) { HasValue source = status.getField(); clearError(source); if (status.isError()) { @@ -1676,7 +1676,7 @@ public class Binder implements Serializable { bean = null; } getValidationStatusHandler() - .accept(BinderValidationStatus.createUnresolvedStatus(this)); + .statusChange(BinderValidationStatus.createUnresolvedStatus(this)); if (fireStatusEvent) { fireStatusChangeEvent(false); } diff --git a/server/src/main/java/com/vaadin/data/BinderValidationStatus.java b/server/src/main/java/com/vaadin/data/BinderValidationStatus.java index 983745c89a..c95a93f074 100644 --- a/server/src/main/java/com/vaadin/data/BinderValidationStatus.java +++ b/server/src/main/java/com/vaadin/data/BinderValidationStatus.java @@ -45,14 +45,14 @@ import com.vaadin.data.validator.BeanValidator; * @see BinderValidationStatusHandler * @see Binder#setValidationStatusHandler(BinderStatusHandler) * @see Binder#validate() - * @see ValidationStatus + * @see BindingValidationStatus * * @since 8.0 */ public class BinderValidationStatus implements Serializable { private final Binder binder; - private final List> bindingStatuses; + private final List> bindingStatuses; private final List binderStatuses; /** @@ -72,7 +72,7 @@ public class BinderValidationStatus implements Serializable { Binder source) { return new BinderValidationStatus<>(source, source.getBindings().stream() - .map(b -> ValidationStatus.createUnresolvedStatus(b)) + .map(b -> BindingValidationStatus.createUnresolvedStatus(b)) .collect(Collectors.toList()), Collections.emptyList()); } @@ -89,7 +89,7 @@ public class BinderValidationStatus implements Serializable { * the validation results for binder level validation */ public BinderValidationStatus(Binder source, - List> bindingStatuses, + List> bindingStatuses, List binderStatuses) { Objects.requireNonNull(binderStatuses, "binding statuses cannot be null"); @@ -118,7 +118,7 @@ public class BinderValidationStatus implements Serializable { public boolean hasErrors() { return binderStatuses.stream().filter(ValidationResult::isError) .findAny().isPresent() - || bindingStatuses.stream().filter(ValidationStatus::isError) + || bindingStatuses.stream().filter(BindingValidationStatus::isError) .findAny().isPresent(); } @@ -153,7 +153,7 @@ public class BinderValidationStatus implements Serializable { * * @return the field validation statuses */ - public List> getFieldValidationStatuses() { + public List> getFieldValidationStatuses() { return bindingStatuses; } @@ -179,8 +179,8 @@ public class BinderValidationStatus implements Serializable { * * @return a list of failed field level validation statuses */ - public List> getFieldValidationErrors() { - return bindingStatuses.stream().filter(ValidationStatus::isError) + public List> getFieldValidationErrors() { + return bindingStatuses.stream().filter(BindingValidationStatus::isError) .collect(Collectors.toList()); } diff --git a/server/src/main/java/com/vaadin/data/BinderValidationStatusHandler.java b/server/src/main/java/com/vaadin/data/BinderValidationStatusHandler.java index 81a622bbd4..c2b591cf25 100644 --- a/server/src/main/java/com/vaadin/data/BinderValidationStatusHandler.java +++ b/server/src/main/java/com/vaadin/data/BinderValidationStatusHandler.java @@ -15,9 +15,7 @@ */ package com.vaadin.data; -import java.io.Serializable; -import java.util.function.Consumer; - +import com.vaadin.event.SerializableEventListener; import com.vaadin.ui.AbstractComponent; /** @@ -37,7 +35,7 @@ import com.vaadin.ui.AbstractComponent; * * @see BinderValidationStatus * @see Binder#validate() - * @see ValidationStatus + * @see BindingValidationStatus * * @param * the bean type of binder @@ -46,6 +44,14 @@ import com.vaadin.ui.AbstractComponent; */ @FunctionalInterface public interface BinderValidationStatusHandler - extends Consumer>, Serializable { + extends SerializableEventListener { + + /** + * Invoked when the validation status has changed in binder. + * + * @param statusChange + * the changed status + */ + void statusChange(BinderValidationStatus statusChange); } diff --git a/server/src/main/java/com/vaadin/data/ValidationStatus.java b/server/src/main/java/com/vaadin/data/BindingValidationStatus.java similarity index 89% rename from server/src/main/java/com/vaadin/data/ValidationStatus.java rename to server/src/main/java/com/vaadin/data/BindingValidationStatus.java index a5ff3896aa..5b5a066418 100644 --- a/server/src/main/java/com/vaadin/data/ValidationStatus.java +++ b/server/src/main/java/com/vaadin/data/BindingValidationStatus.java @@ -28,7 +28,7 @@ import com.vaadin.data.Binder.BindingBuilder; * associated with a ValidationResult {@link #getResult}. *

* Use - * {@link BindingBuilder#withValidationStatusHandler(ValidationStatusHandler)} + * {@link BindingBuilder#withValidationStatusHandler(BindingValidationStatusHandler)} * to register a handler for field level validation status changes. * * @author Vaadin Ltd @@ -38,19 +38,19 @@ import com.vaadin.data.Binder.BindingBuilder; * status changed, matches the field type unless a converter has been * set * - * @see BindingBuilder#withValidationStatusHandler(ValidationStatusHandler) + * @see BindingBuilder#withValidationStatusHandler(BindingValidationStatusHandler) * @see Binding#validate() - * @see ValidationStatusHandler + * @see BindingValidationStatusHandler * @see BinderValidationStatus * * @since 8.0 */ -public class ValidationStatus implements Serializable { +public class BindingValidationStatus implements Serializable { /** * Status of the validation. *

- * The status is the part of {@link ValidationStatus} which indicates + * The status is the part of {@link BindingValidationStatus} which indicates * whether the validation failed or not, or whether it is in unresolved * state (e.g. after clear or reset). */ @@ -84,9 +84,9 @@ public class ValidationStatus implements Serializable { * the target data type of the binding for which the validation * status was reset */ - public static ValidationStatus createUnresolvedStatus( + public static BindingValidationStatus createUnresolvedStatus( Binding source) { - return new ValidationStatus<>(source, Status.UNRESOLVED, null); + return new BindingValidationStatus<>(source, Status.UNRESOLVED, null); } /** @@ -98,7 +98,7 @@ public class ValidationStatus implements Serializable { * @param result * the result of the validation */ - public ValidationStatus(Binding source, + public BindingValidationStatus(Binding source, ValidationResult result) { this(source, result.isError() ? Status.ERROR : Status.OK, result); } @@ -116,7 +116,7 @@ public class ValidationStatus implements Serializable { * @param result * the related result, may be {@code null} */ - public ValidationStatus(Binding source, Status status, + public BindingValidationStatus(Binding source, Status status, ValidationResult result) { Objects.requireNonNull(source, "Event source may not be null"); Objects.requireNonNull(status, "Status may not be null"); diff --git a/server/src/main/java/com/vaadin/data/ValidationStatusHandler.java b/server/src/main/java/com/vaadin/data/BindingValidationStatusHandler.java similarity index 72% rename from server/src/main/java/com/vaadin/data/ValidationStatusHandler.java rename to server/src/main/java/com/vaadin/data/BindingValidationStatusHandler.java index f2170537f9..74a4c41c66 100644 --- a/server/src/main/java/com/vaadin/data/ValidationStatusHandler.java +++ b/server/src/main/java/com/vaadin/data/BindingValidationStatusHandler.java @@ -15,14 +15,12 @@ */ package com.vaadin.data; -import java.io.Serializable; -import java.util.function.Consumer; - import com.vaadin.data.Binder.BindingBuilder; +import com.vaadin.event.SerializableEventListener; import com.vaadin.ui.AbstractComponent; /** - * Handler for {@link ValidationStatus} changes. + * Handler for {@link BindingValidationStatus} changes. *

* {@link BindingBuilder#withValidationStatusHandler(withValidationStatusHandler) * Register} an instance of this class to be able to override the default @@ -33,13 +31,20 @@ import com.vaadin.ui.AbstractComponent; * @author Vaadin Ltd * * @see BindingBuilder#withValidationStatusHandler(withValidationStatusHandler) - * @see ValidationStatus + * @see BindingValidationStatus * * @since 8.0 * */ @FunctionalInterface -public interface ValidationStatusHandler - extends Consumer>, Serializable { +public interface BindingValidationStatusHandler + extends SerializableEventListener { + /** + * Invoked when the validation status has changed in a binding. + * + * @param statusChange + * the changed status + */ + public void statusChange(BindingValidationStatus statusChange); } diff --git a/server/src/main/java/com/vaadin/data/HasValue.java b/server/src/main/java/com/vaadin/data/HasValue.java index a7fe8901db..fe5820839c 100644 --- a/server/src/main/java/com/vaadin/data/HasValue.java +++ b/server/src/main/java/com/vaadin/data/HasValue.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.EventObject; import java.util.Objects; import java.util.function.BiConsumer; -import java.util.function.Consumer; +import com.vaadin.event.SerializableEventListener; import com.vaadin.shared.Registration; import com.vaadin.ui.Component; import com.vaadin.util.ReflectTools; @@ -140,11 +140,12 @@ public interface HasValue extends Serializable { * @see Registration */ @FunctionalInterface - public interface ValueChangeListener - extends Consumer>, Serializable { + public interface ValueChangeListener extends SerializableEventListener { + + /** For internal use only. Might be removed in the future. */ @Deprecated public static final Method VALUE_CHANGE_METHOD = ReflectTools - .findMethod(ValueChangeListener.class, "accept", + .findMethod(ValueChangeListener.class, "valueChange", ValueChangeEvent.class); /** @@ -154,8 +155,7 @@ public interface HasValue extends Serializable { * @param event * the received event, not null */ - @Override - public void accept(ValueChangeEvent event); + public void valueChange(ValueChangeEvent event); } /** @@ -263,7 +263,7 @@ public interface HasValue extends Serializable { *

* This is just a shorthand for resetting the value, see the methods * {@link #setValue(Object)} and {@link #getEmptyValue()}. - * + * * @see #setValue(Object) * @see #getEmptyValue() */ diff --git a/server/src/main/java/com/vaadin/data/StatusChangeListener.java b/server/src/main/java/com/vaadin/data/StatusChangeListener.java index cb6afead24..7e1a53100f 100644 --- a/server/src/main/java/com/vaadin/data/StatusChangeListener.java +++ b/server/src/main/java/com/vaadin/data/StatusChangeListener.java @@ -15,21 +15,24 @@ */ package com.vaadin.data; -import java.io.Serializable; +import com.vaadin.event.SerializableEventListener; /** - * Listener interface for {@link StatusChangeEvent}s. - * - * @see StatusChangeEvent + * Listener interface for status change events from binder. + * * @author Vaadin Ltd * + * @since 8.0 + * + * @see StatusChangeEvent + * @see Binder#addStatusChangeListener(StatusChangeListener) */ @FunctionalInterface -public interface StatusChangeListener extends Serializable { +public interface StatusChangeListener extends SerializableEventListener { /** * Notifies the listener about status change {@code event}. - * + * * @param event * a status change event, not null */ diff --git a/server/src/main/java/com/vaadin/data/ValidationException.java b/server/src/main/java/com/vaadin/data/ValidationException.java index 0f86dd5186..fe515ad56d 100644 --- a/server/src/main/java/com/vaadin/data/ValidationException.java +++ b/server/src/main/java/com/vaadin/data/ValidationException.java @@ -33,7 +33,7 @@ import java.util.stream.Collectors; */ public class ValidationException extends Exception { - private final List> fieldValidationErrors; + private final List> fieldValidationErrors; private final List beanValidationErrors; /** @@ -44,7 +44,7 @@ public class ValidationException extends Exception { * @param beanValidationErrors * binder validation errors list */ - public ValidationException(List> fieldValidationErrors, + public ValidationException(List> fieldValidationErrors, List beanValidationErrors) { super("Validation has failed for some fields"); this.fieldValidationErrors = Collections @@ -74,7 +74,7 @@ public class ValidationException extends Exception { * * @return binding validation errors list */ - public List> getFieldValidationErrors() { + public List> getFieldValidationErrors() { return fieldValidationErrors; } diff --git a/server/src/main/java/com/vaadin/event/selection/MultiSelectionListener.java b/server/src/main/java/com/vaadin/event/selection/MultiSelectionListener.java index d8b138f184..653ae67979 100644 --- a/server/src/main/java/com/vaadin/event/selection/MultiSelectionListener.java +++ b/server/src/main/java/com/vaadin/event/selection/MultiSelectionListener.java @@ -15,23 +15,39 @@ */ package com.vaadin.event.selection; -import java.io.Serializable; -import java.util.function.Consumer; +import java.lang.reflect.Method; + +import com.vaadin.event.SerializableEventListener; +import com.vaadin.util.ReflectTools; /** - * Listens to changes from a {@link com.vaadin.data.SelectionModel.Multi}. + * A listener for listening for selection changes from a multiselection + * component. * * @author Vaadin Ltd * * @since 8.0 * * @param - * the data type of the selection model + * the type of the selected item + * + * @see SelectionModel.Multi + * @see MultiSelectionEvent */ @FunctionalInterface -public interface MultiSelectionListener - extends Consumer>, Serializable { - @Override - // Explicitly defined to make reflection logic happy - void accept(MultiSelectionEvent event); +public interface MultiSelectionListener extends SerializableEventListener { + + /** For internal use only. Might be removed in the future. */ + @Deprecated + static final Method SELECTION_CHANGE_METHOD = ReflectTools.findMethod( + MultiSelectionListener.class, "selectionChange", + MultiSelectionEvent.class); + + /** + * Invoked when the selection has changed by the user or programmatically. + * + * @param event + * the selection event, never {@code null} + */ + public void selectionChange(MultiSelectionEvent event); } diff --git a/server/src/main/java/com/vaadin/event/selection/SelectionListener.java b/server/src/main/java/com/vaadin/event/selection/SelectionListener.java index e26e02315f..a7b91df734 100644 --- a/server/src/main/java/com/vaadin/event/selection/SelectionListener.java +++ b/server/src/main/java/com/vaadin/event/selection/SelectionListener.java @@ -15,7 +15,7 @@ */ package com.vaadin.event.selection; -import com.vaadin.server.SerializableConsumer; +import com.vaadin.event.SerializableEventListener; /** * A listener for {@code SelectionEvent}. @@ -33,7 +33,14 @@ import com.vaadin.server.SerializableConsumer; * @since 8.0 */ @FunctionalInterface -public interface SelectionListener - extends SerializableConsumer> { +public interface SelectionListener extends SerializableEventListener { + + /** + * Invoked when the selection has changed by user or programmatically. + * + * @param event + * the selection event + */ + public void selectionChange(SelectionEvent event); } diff --git a/server/src/main/java/com/vaadin/event/selection/SingleSelectionListener.java b/server/src/main/java/com/vaadin/event/selection/SingleSelectionListener.java index ef34435678..e52b780ccf 100644 --- a/server/src/main/java/com/vaadin/event/selection/SingleSelectionListener.java +++ b/server/src/main/java/com/vaadin/event/selection/SingleSelectionListener.java @@ -15,25 +15,39 @@ */ package com.vaadin.event.selection; -import java.io.Serializable; -import java.util.function.Consumer; +import java.lang.reflect.Method; + +import com.vaadin.event.SerializableEventListener; +import com.vaadin.util.ReflectTools; /** - * A listener for {@code SingleSelectionEvent}. + * A listener for listening to selection changes on a single selection + * component. * * @author Vaadin Ltd. * + * @since 8.0 + * * @param * the type of the selected item * + * @see SelectionModel.Single * @see SingleSelectionEvent - * - * @since 8.0 */ @FunctionalInterface -public interface SingleSelectionListener - extends Consumer>, Serializable { +public interface SingleSelectionListener extends SerializableEventListener { + + /** For internal use only. Might be removed in the future. */ + @Deprecated + static final Method SELECTION_CHANGE_METHOD = ReflectTools.findMethod( + SingleSelectionListener.class, "selectionChange", + SingleSelectionEvent.class); - @Override - public void accept(SingleSelectionEvent event); + /** + * Invoked when selection has been changed by the user or programmatically. + * + * @param event + * the selection event + */ + public void selectionChange(SingleSelectionEvent event); } diff --git a/server/src/main/java/com/vaadin/ui/AbstractField.java b/server/src/main/java/com/vaadin/ui/AbstractField.java index 331f8d28e1..f19e1fd8fc 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractField.java +++ b/server/src/main/java/com/vaadin/ui/AbstractField.java @@ -16,7 +16,6 @@ package com.vaadin.ui; -import java.lang.reflect.Method; import java.util.Collection; import java.util.Objects; @@ -29,7 +28,6 @@ import com.vaadin.shared.Registration; import com.vaadin.ui.Component.Focusable; import com.vaadin.ui.declarative.DesignAttributeHandler; import com.vaadin.ui.declarative.DesignContext; -import com.vaadin.util.ReflectTools; /** * An abstract implementation of a field, or a {@code Component} allowing user @@ -50,10 +48,6 @@ import com.vaadin.util.ReflectTools; public abstract class AbstractField extends AbstractComponent implements HasValue, Focusable { - @Deprecated - private static final Method VALUE_CHANGE_METHOD = ReflectTools.findMethod( - ValueChangeListener.class, "accept", ValueChangeEvent.class); - @Override public void setValue(T value) { setValue(value, false); @@ -90,7 +84,7 @@ public abstract class AbstractField extends AbstractComponent public Registration addValueChangeListener( ValueChangeListener listener) { return addListener(ValueChangeEvent.class, listener, - VALUE_CHANGE_METHOD); + ValueChangeListener.VALUE_CHANGE_METHOD); } @Override diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java index c0c3af15d7..b053277cc3 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java @@ -15,7 +15,6 @@ */ package com.vaadin.ui; -import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -45,7 +44,6 @@ import com.vaadin.shared.ui.ListingJsonConstants; import com.vaadin.shared.ui.abstractmultiselect.AbstractMultiSelectState; import com.vaadin.ui.declarative.DesignContext; import com.vaadin.ui.declarative.DesignException; -import com.vaadin.util.ReflectTools; import elemental.json.JsonObject; @@ -122,11 +120,6 @@ public abstract class AbstractMultiSelect extends AbstractListing } } - @Deprecated - private static final Method SELECTION_CHANGE_METHOD = ReflectTools - .findMethod(MultiSelectionListener.class, "accept", - MultiSelectionEvent.class); - /** * The item enabled status provider. It is up to the implementing class to * support this or not. @@ -156,7 +149,7 @@ public abstract class AbstractMultiSelect extends AbstractListing public Registration addSelectionListener( MultiSelectionListener listener) { return addListener(MultiSelectionEvent.class, listener, - SELECTION_CHANGE_METHOD); + MultiSelectionListener.SELECTION_CHANGE_METHOD); } @Override @@ -231,7 +224,7 @@ public abstract class AbstractMultiSelect extends AbstractListing @Override public Registration addValueChangeListener( HasValue.ValueChangeListener> listener) { - return addSelectionListener(event -> listener.accept( + return addSelectionListener(event -> listener.valueChange( new ValueChangeEvent<>(this, event.isUserOriginated()))); } diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java index 1ff77b7f1a..6c0d1efc54 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java @@ -15,7 +15,6 @@ */ package com.vaadin.ui; -import java.lang.reflect.Method; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -37,7 +36,6 @@ import com.vaadin.shared.data.selection.SelectionServerRpc; import com.vaadin.shared.ui.AbstractSingleSelectState; import com.vaadin.ui.declarative.DesignContext; import com.vaadin.ui.declarative.DesignException; -import com.vaadin.util.ReflectTools; import elemental.json.Json; @@ -57,11 +55,6 @@ import elemental.json.Json; public abstract class AbstractSingleSelect extends AbstractListing implements SingleSelect { - @Deprecated - private static final Method SELECTION_CHANGE_METHOD = ReflectTools - .findMethod(SingleSelectionListener.class, "accept", - SingleSelectionEvent.class); - /** * Creates a new {@code AbstractListing} with a default data communicator. *

@@ -106,7 +99,7 @@ public abstract class AbstractSingleSelect extends AbstractListing public Registration addSelectionListener( SingleSelectionListener listener) { return addListener(SingleSelectionEvent.class, listener, - SELECTION_CHANGE_METHOD); + SingleSelectionListener.SELECTION_CHANGE_METHOD); } /** @@ -168,7 +161,7 @@ public abstract class AbstractSingleSelect extends AbstractListing @Override public Registration addValueChangeListener( HasValue.ValueChangeListener listener) { - return addSelectionListener(event -> listener.accept( + return addSelectionListener(event -> listener.valueChange( new ValueChangeEvent<>(this, event.isUserOriginated()))); } diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index b85a721c54..3e04f26d97 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -559,7 +559,7 @@ public class ComboBox extends AbstractSingleSelect public Registration addValueChangeListener( HasValue.ValueChangeListener listener) { return addSelectionListener(event -> { - listener.accept(new ValueChangeEvent<>(event.getComponent(), this, + listener.valueChange(new ValueChangeEvent<>(event.getComponent(), this, event.isUserOriginated())); }); } diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 11dfb464b9..5a6135a1bc 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -35,7 +35,6 @@ import java.util.Set; import java.util.UUID; import java.util.function.BiFunction; import java.util.function.BinaryOperator; -import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -49,8 +48,8 @@ import com.vaadin.data.BinderValidationStatus; import com.vaadin.data.Listing; import com.vaadin.data.SelectionModel; import com.vaadin.event.ConnectorEvent; -import com.vaadin.event.ConnectorEventListener; import com.vaadin.event.ContextClickEvent; +import com.vaadin.event.SerializableEventListener; import com.vaadin.event.selection.MultiSelectionListener; import com.vaadin.event.selection.SelectionListener; import com.vaadin.event.selection.SingleSelectionListener; @@ -125,7 +124,7 @@ public class Grid extends AbstractListing @Deprecated private static final Method ITEM_CLICK_METHOD = ReflectTools - .findMethod(ItemClickListener.class, "accept", ItemClick.class); + .findMethod(ItemClickListener.class, "itemClick", ItemClick.class); @Deprecated private static final Method COLUMN_VISIBILITY_METHOD = ReflectTools @@ -260,7 +259,7 @@ public class Grid extends AbstractListing @Override public default Registration addSelectionListener( SelectionListener listener) { - return addSingleSelectionListener(e -> listener.accept(e)); + return addSingleSelectionListener(e -> listener.selectionChange(e)); } /** @@ -303,7 +302,7 @@ public class Grid extends AbstractListing @Override public default Registration addSelectionListener( SelectionListener listener) { - return addMultiSelectionListener(e -> listener.accept(e)); + return addMultiSelectionListener(e -> listener.selectionChange(e)); } /** @@ -482,8 +481,7 @@ public class Grid extends AbstractListing * @see Registration */ @FunctionalInterface - public interface ItemClickListener - extends Consumer>, ConnectorEventListener { + public interface ItemClickListener extends SerializableEventListener { /** * Invoked when this listener receives a item click event from a Grid to * which it has been added. @@ -491,8 +489,7 @@ public class Grid extends AbstractListing * @param event * the received event, not null */ - @Override - public void accept(ItemClick event); + public void itemClick(ItemClick event); } /** @@ -3648,9 +3645,9 @@ public class Grid extends AbstractListing for (Column column : getColumns()) { Object value = column.valueProvider.apply(item); tableRow.appendElement("td") - .append((Optional.ofNullable(value).map(Object::toString) + .append(Optional.ofNullable(value).map(Object::toString) .map(DesignFormatter::encodeForTextNode) - .orElse(""))); + .orElse("")); } } diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java index bd8ba27b51..44471d2806 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java @@ -50,7 +50,7 @@ public class EditorImpl extends AbstractGridExtension implements BinderValidationStatusHandler { @Override - public void accept(BinderValidationStatus status) { + public void statusChange(BinderValidationStatus status) { boolean ok = status.isOk(); if (saving) { rpc.confirmSave(ok); diff --git a/server/src/main/java/com/vaadin/ui/components/grid/MultiSelectionModelImpl.java b/server/src/main/java/com/vaadin/ui/components/grid/MultiSelectionModelImpl.java index 02f7a4d0de..c3e9f38cb2 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/MultiSelectionModelImpl.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/MultiSelectionModelImpl.java @@ -15,7 +15,6 @@ */ package com.vaadin.ui.components.grid; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashSet; @@ -35,7 +34,6 @@ import com.vaadin.shared.data.selection.GridMultiSelectServerRpc; import com.vaadin.shared.ui.grid.MultiSelectionModelState; import com.vaadin.ui.Grid.MultiSelectionModel; import com.vaadin.ui.MultiSelect; -import com.vaadin.util.ReflectTools; /** * Multiselection model for grid. @@ -122,11 +120,6 @@ public class MultiSelectionModelImpl extends AbstractSelectionModel } } - @Deprecated - private static final Method SELECTION_CHANGE_METHOD = ReflectTools - .findMethod(MultiSelectionListener.class, "accept", - MultiSelectionEvent.class); - private Set selection = new LinkedHashSet<>(); private SelectAllCheckBoxVisibility selectAllCheckBoxVisibility = SelectAllCheckBoxVisibility.DEFAULT; @@ -247,7 +240,7 @@ public class MultiSelectionModelImpl extends AbstractSelectionModel public Registration addMultiSelectionListener( MultiSelectionListener listener) { return addListener(MultiSelectionEvent.class, listener, - SELECTION_CHANGE_METHOD); + MultiSelectionListener.SELECTION_CHANGE_METHOD); } @Override @@ -296,7 +289,8 @@ public class MultiSelectionModelImpl extends AbstractSelectionModel @Override public Registration addValueChangeListener( com.vaadin.data.HasValue.ValueChangeListener> listener) { - return addSelectionListener(event -> listener.accept(event)); + return addSelectionListener( + event -> listener.valueChange(event)); } @Override diff --git a/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModelImpl.java b/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModelImpl.java index 8487ea87ef..7ca7b583a8 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModelImpl.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModelImpl.java @@ -15,7 +15,6 @@ */ package com.vaadin.ui.components.grid; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -31,7 +30,6 @@ import com.vaadin.shared.ui.grid.SingleSelectionModelState; import com.vaadin.ui.Component; import com.vaadin.ui.Grid.SingleSelectionModel; import com.vaadin.ui.SingleSelect; -import com.vaadin.util.ReflectTools; /** * Single selection model for grid. @@ -45,10 +43,6 @@ import com.vaadin.util.ReflectTools; public class SingleSelectionModelImpl extends AbstractSelectionModel implements SingleSelectionModel { - private static final Method SELECTION_CHANGE_METHOD = ReflectTools - .findMethod(SingleSelectionListener.class, "accept", - SingleSelectionEvent.class); - private T selectedItem = null; @Override @@ -83,7 +77,7 @@ public class SingleSelectionModelImpl extends AbstractSelectionModel public Registration addSingleSelectionListener( SingleSelectionListener listener) { return addListener(SingleSelectionEvent.class, listener, - SELECTION_CHANGE_METHOD); + SingleSelectionListener.SELECTION_CHANGE_METHOD); } @Override @@ -250,7 +244,7 @@ public class SingleSelectionModelImpl extends AbstractSelectionModel com.vaadin.data.HasValue.ValueChangeListener listener) { return SingleSelectionModelImpl.this.addSingleSelectionListener( (SingleSelectionListener) event -> listener - .accept(event)); + .valueChange(event)); } @Override diff --git a/server/src/test/java/com/vaadin/data/BeanBinderTest.java b/server/src/test/java/com/vaadin/data/BeanBinderTest.java index 14f32bd1ec..d45cfe04fd 100644 --- a/server/src/test/java/com/vaadin/data/BeanBinderTest.java +++ b/server/src/test/java/com/vaadin/data/BeanBinderTest.java @@ -198,7 +198,7 @@ public class BeanBinderTest private void assertInvalid(HasValue field, String message) { BinderValidationStatus status = binder.validate(); - List> errors = status.getFieldValidationErrors(); + List> errors = status.getFieldValidationErrors(); assertEquals(1, errors.size()); assertSame(field, errors.get(0).getField()); assertEquals(message, errors.get(0).getMessage().get()); diff --git a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java index 8f61fb5f16..493842b63c 100644 --- a/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java +++ b/server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import com.vaadin.data.Binder.Binding; import com.vaadin.data.Binder.BindingBuilder; -import com.vaadin.data.ValidationStatus.Status; +import com.vaadin.data.BindingValidationStatus.Status; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.StringToIntegerConverter; import com.vaadin.data.util.converter.ValueContext; @@ -375,7 +375,7 @@ public class BinderBookOfVaadinTest { departing.setValue(before); returning.setValue(after); - ValidationStatus result = returnBinding.validate(); + BindingValidationStatus result = returnBinding.validate(); Assert.assertFalse(result.isError()); Assert.assertNull(departing.getComponentError()); @@ -426,7 +426,7 @@ public class BinderBookOfVaadinTest { @Test public void withBindingStatusHandlerExample() { Label nameStatus = new Label(); - AtomicReference> statusCapture = new AtomicReference<>(); + AtomicReference> statusCapture = new AtomicReference<>(); String msg = "Full name must contain at least three characters"; binder.forField(field).withValidator(name -> name.length() >= 3, msg) @@ -444,7 +444,7 @@ public class BinderBookOfVaadinTest { Assert.assertTrue(nameStatus.isVisible()); Assert.assertEquals(msg, nameStatus.getValue()); Assert.assertNotNull(statusCapture.get()); - ValidationStatus status = statusCapture.get(); + BindingValidationStatus status = statusCapture.get(); Assert.assertEquals(Status.ERROR, status.getStatus()); Assert.assertEquals(msg, status.getMessage().get()); Assert.assertEquals(field, status.getField()); @@ -652,7 +652,7 @@ public class BinderBookOfVaadinTest { formStatusLabel.setVisible(!errorMessage.isEmpty()); // Let the default handler show messages for each field - defaultHandler.accept(status); + defaultHandler.statusChange(status); }); final String bindingMessage = "uneven"; diff --git a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java index 81cfbb5484..d86a9d04cc 100644 --- a/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java +++ b/server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java @@ -98,11 +98,11 @@ public class BinderConverterValidatorTest binding.bind(Person::getFirstName, Person::setFirstName); BinderValidationStatus status = binder.validate(); - List> errors = status.getFieldValidationErrors(); + List> errors = status.getFieldValidationErrors(); assertEquals(1, errors.size()); - ValidationStatus validationStatus = errors.stream().findFirst() + BindingValidationStatus validationStatus = errors.stream().findFirst() .get(); String msg = validationStatus.getMessage().get(); assertEquals(msg1, msg); @@ -167,7 +167,7 @@ public class BinderConverterValidatorTest } private void assertValidationErrors( - List> validationErrors, + List> validationErrors, String... errorMessages) { assertEquals(errorMessages.length, validationErrors.size()); for (int i = 0; i < errorMessages.length; i++) { @@ -258,7 +258,7 @@ public class BinderConverterValidatorTest Person person = new Person(); binder.setBean(person); - List> errors = binder.validate() + List> errors = binder.validate() .getFieldValidationErrors(); assertEquals(0, errors.size()); } @@ -275,10 +275,10 @@ public class BinderConverterValidatorTest Person person = new Person(); binder.setBean(person); - List> errors = binder.validate() + List> errors = binder.validate() .getFieldValidationErrors(); assertEquals(1, errors.size()); - ValidationStatus error = errors.get(0); + BindingValidationStatus error = errors.get(0); assertEquals(msg, error.getMessage().get()); assertEquals(nameField, error.getField()); } @@ -296,11 +296,11 @@ public class BinderConverterValidatorTest Person person = new Person(); binder.setBean(person); - List> errors = binder.validate() + List> errors = binder.validate() .getFieldValidationErrors(); assertEquals(1, errors.size()); - ValidationStatus error = errors.get(0); + BindingValidationStatus error = errors.get(0); assertEquals(msg1, error.getMessage().get()); assertEquals(nameField, error.getField()); @@ -570,10 +570,10 @@ public class BinderConverterValidatorTest binder.writeBean(person); Assert.fail(); } catch (ValidationException exception) { - List> validationErrors = exception + List> validationErrors = exception .getFieldValidationErrors(); Assert.assertEquals(2, validationErrors.size()); - ValidationStatus error = validationErrors.get(0); + BindingValidationStatus error = validationErrors.get(0); Assert.assertEquals(nameField, error.getField()); Assert.assertEquals(msg, error.getMessage().get()); diff --git a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java index bb4052cc8d..6e1f7614bb 100644 --- a/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java +++ b/server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java @@ -24,14 +24,14 @@ import org.junit.Test; import com.vaadin.data.Binder.Binding; import com.vaadin.data.Binder.BindingBuilder; -import com.vaadin.data.ValidationStatus.Status; +import com.vaadin.data.BindingValidationStatus.Status; import com.vaadin.tests.data.bean.Person; import com.vaadin.ui.Label; public class BinderValidationStatusTest extends BinderTestBase, Person> { - protected final static ValidationStatusHandler NOOP = event -> { + protected final static BindingValidationStatusHandler NOOP = event -> { }; @Before @@ -48,7 +48,7 @@ public class BinderValidationStatusTest @Test public void bindingWithStatusHandler_handlerGetsEvents() { - AtomicReference> statusCapture = new AtomicReference<>(); + AtomicReference> statusCapture = new AtomicReference<>(); BindingBuilder binding = binder.forField(nameField) .withValidator(notEmpty).withValidationStatusHandler(evt -> { Assert.assertNull(statusCapture.get()); @@ -63,7 +63,7 @@ public class BinderValidationStatusTest binder.validate(); Assert.assertNotNull(statusCapture.get()); - ValidationStatus evt = statusCapture.get(); + BindingValidationStatus evt = statusCapture.get(); Assert.assertEquals(Status.ERROR, evt.getStatus()); Assert.assertEquals(EMPTY_ERROR_MESSAGE, evt.getMessage().get()); Assert.assertEquals(nameField, evt.getField()); @@ -235,13 +235,13 @@ public class BinderValidationStatusTest Assert.assertNull(nameField.getComponentError()); - List> bindingStatuses = status + List> bindingStatuses = status .getFieldValidationStatuses(); Assert.assertNotNull(bindingStatuses); Assert.assertEquals(1, status.getFieldValidationErrors().size()); Assert.assertEquals(2, bindingStatuses.size()); - ValidationStatus r = bindingStatuses.get(0); + BindingValidationStatus r = bindingStatuses.get(0); Assert.assertTrue(r.isError()); Assert.assertEquals(EMPTY_ERROR_MESSAGE, r.getMessage().get()); Assert.assertEquals(nameField, r.getField()); @@ -328,13 +328,13 @@ public class BinderValidationStatusTest Assert.assertNull(nameField.getComponentError()); - List> bindingStatuses = status + List> bindingStatuses = status .getFieldValidationStatuses(); Assert.assertNotNull(bindingStatuses); Assert.assertEquals(1, status.getFieldValidationErrors().size()); Assert.assertEquals(2, bindingStatuses.size()); - ValidationStatus r = bindingStatuses.get(0); + BindingValidationStatus r = bindingStatuses.get(0); Assert.assertTrue(r.isError()); Assert.assertEquals(EMPTY_ERROR_MESSAGE, r.getMessage().get()); Assert.assertEquals(nameField, r.getField()); @@ -497,7 +497,7 @@ public class BinderValidationStatusTest nameField.setValue("foo"); binder.validate(); - List> results = capture.get() + List> results = capture.get() .getFieldValidationStatuses(); Assert.assertNotNull(results); Assert.assertEquals(1, results.size()); diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java index 733f00816d..e353035c63 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java @@ -602,7 +602,7 @@ public class GridMultiSelectionModelTest { }); Assert.assertSame(registration, actualRegistration); - selectionListener.get().accept(new MultiSelectionEvent<>(grid, + selectionListener.get().selectionChange(new MultiSelectionEvent<>(grid, model.asMultiSelect(), Collections.emptySet(), true)); Assert.assertEquals(grid, event.get().getComponent()); diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java index 9dd7d7e27a..6bf81982c8 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java @@ -313,7 +313,7 @@ public class GridSingleSelectionModelTest { }); Assert.assertSame(registration, actualRegistration); - selectionListener.get().accept(new SingleSelectionEvent<>(grid, + selectionListener.get().selectionChange(new SingleSelectionEvent<>(grid, select.asSingleSelect(), true)); Assert.assertEquals(grid, event.get().getComponent()); diff --git a/server/src/test/java/com/vaadin/ui/AbstractFieldTest.java b/server/src/test/java/com/vaadin/ui/AbstractFieldTest.java index 37036e1d2b..7f66ca5ed3 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractFieldTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractFieldTest.java @@ -58,7 +58,7 @@ public class AbstractFieldTest extends EasyMockSupport { @Test public void valueChangeListenerInvoked() { - l.accept(EasyMock.capture(capture)); + l.valueChange(EasyMock.capture(capture)); replayAll(); field.setValue("foo"); @@ -72,7 +72,7 @@ public class AbstractFieldTest extends EasyMockSupport { @Test public void valueChangeListenerInvokedFromClient() { - l.accept(EasyMock.capture(capture)); + l.valueChange(EasyMock.capture(capture)); replayAll(); field.setValue("foo"); diff --git a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java index ff8d1fcead..93985114be 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java @@ -318,7 +318,7 @@ public class AbstractMultiSelectTest & Lis Assert.assertSame(registration, actualRegistration); - selectionListener.get().accept(new MultiSelectionEvent<>(select, + selectionListener.get().selectionChange(new MultiSelectionEvent<>(select, Mockito.mock(Set.class), true)); Assert.assertEquals(select, event.get().getComponent()); diff --git a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java index c930b8e217..e519612810 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java @@ -269,7 +269,7 @@ public class AbstractSingleSelectTest { Assert.assertSame(registration, actualRegistration); selectionListener.get() - .accept(new SingleSelectionEvent<>(select, true)); + .selectionChange(new SingleSelectionEvent<>(select, true)); Assert.assertEquals(select, event.get().getComponent()); Assert.assertEquals(value, event.get().getValue()); diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java b/uitest/src/main/java/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java index ced0d796e4..6b72db4091 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java +++ b/uitest/src/main/java/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java @@ -88,7 +88,7 @@ public abstract class AbstractFieldTest, V> private ValueChangeListener valueChangeListener = new ValueChangeListener() { @Override - public void accept(ValueChangeEvent event) { + public void valueChange(ValueChangeEvent event) { log(event.getClass().getSimpleName() + ", new value: " + formatValue(event.getValue())); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/LenientMode.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/LenientMode.java index 9cd829ec89..8619ec6785 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/datefield/LenientMode.java +++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/LenientMode.java @@ -72,7 +72,7 @@ public class LenientMode extends TestBase } @Override - public void accept(ValueChangeEvent event) { + public void valueChange(ValueChangeEvent event) { getMainWindow().showNotification("New value" + event.getValue()); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java index a784a45814..1db44b00e2 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java +++ b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java @@ -50,7 +50,7 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog { }; @Override - public void accept(ValueChangeEvent event) { + public void valueChange(ValueChangeEvent event) { if (table.getListeners(HeaderClickEvent.class) .isEmpty()) { table.addHeaderClickListener(headerClickListener); @@ -80,7 +80,7 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog { }; @Override - public void accept(ValueChangeEvent event) { + public void valueChange(ValueChangeEvent event) { if (table.getListeners(FooterClickEvent.class) .isEmpty()) { table.addFooterClickListener(footerClickListener); -- 2.39.5