summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2016-12-14 15:12:13 +0200
committerHenri Sara <henri.sara@gmail.com>2016-12-14 15:12:13 +0200
commitce26bf7c4ce2d3f4a40904d103cb85bdd8fb17c6 (patch)
treee804c7ec2f4a392cb50a9261354ae367c6fac7d0
parentb2e3aa2acf99e98dc3e5ac3c96ec829fe3896c47 (diff)
downloadvaadin-framework-ce26bf7c4ce2d3f4a40904d103cb85bdd8fb17c6.tar.gz
vaadin-framework-ce26bf7c4ce2d3f4a40904d103cb85bdd8fb17c6.zip
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
-rw-r--r--server/src/main/java/com/vaadin/data/BeanBinder.java8
-rw-r--r--server/src/main/java/com/vaadin/data/Binder.java80
-rw-r--r--server/src/main/java/com/vaadin/data/BinderValidationStatus.java16
-rw-r--r--server/src/main/java/com/vaadin/data/BinderValidationStatusHandler.java16
-rw-r--r--server/src/main/java/com/vaadin/data/BindingValidationStatus.java (renamed from server/src/main/java/com/vaadin/data/ValidationStatus.java)18
-rw-r--r--server/src/main/java/com/vaadin/data/BindingValidationStatusHandler.java (renamed from server/src/main/java/com/vaadin/data/ValidationStatusHandler.java)19
-rw-r--r--server/src/main/java/com/vaadin/data/HasValue.java14
-rw-r--r--server/src/main/java/com/vaadin/data/StatusChangeListener.java15
-rw-r--r--server/src/main/java/com/vaadin/data/ValidationException.java6
-rw-r--r--server/src/main/java/com/vaadin/event/selection/MultiSelectionListener.java34
-rw-r--r--server/src/main/java/com/vaadin/event/selection/SelectionListener.java13
-rw-r--r--server/src/main/java/com/vaadin/event/selection/SingleSelectionListener.java32
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractField.java8
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java19
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/MultiSelectionModelImpl.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModelImpl.java10
-rw-r--r--server/src/test/java/com/vaadin/data/BeanBinderTest.java2
-rw-r--r--server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java10
-rw-r--r--server/src/test/java/com/vaadin/data/BinderConverterValidatorTest.java20
-rw-r--r--server/src/test/java/com/vaadin/data/BinderValidationStatusTest.java18
-rw-r--r--server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java2
-rw-r--r--server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java2
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractFieldTest.java4
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java2
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/LenientMode.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java4
32 files changed, 216 insertions, 200 deletions
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<BEAN> extends Binder<BEAN> {
@Override
public BeanBindingBuilder<BEAN, TARGET> withValidationStatusHandler(
- ValidationStatusHandler handler);
+ BindingValidationStatusHandler handler);
@Override
public default BeanBindingBuilder<BEAN, TARGET> withStatusLabel(
@@ -196,7 +196,7 @@ public class BeanBinder<BEAN> extends Binder<BEAN> {
protected BeanBindingImpl(BeanBinder<BEAN> binder,
HasValue<FIELDVALUE> field,
Converter<FIELDVALUE, TARGET> converter,
- ValidationStatusHandler statusHandler) {
+ BindingValidationStatusHandler statusHandler) {
super(binder, field, converter, statusHandler);
}
@@ -216,7 +216,7 @@ public class BeanBinder<BEAN> extends Binder<BEAN> {
@Override
public BeanBindingBuilder<BEAN, TARGET> withValidationStatusHandler(
- ValidationStatusHandler handler) {
+ BindingValidationStatusHandler handler) {
return (BeanBindingBuilder<BEAN, TARGET>) super.withValidationStatusHandler(
handler);
}
@@ -377,7 +377,7 @@ public class BeanBinder<BEAN> extends Binder<BEAN> {
@Override
protected <FIELDVALUE, TARGET> BeanBindingImpl<BEAN, FIELDVALUE, TARGET> createBinding(
HasValue<FIELDVALUE> field, Converter<FIELDVALUE, TARGET> 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<BEAN> implements Serializable {
*
* @return the validation result.
*/
- public ValidationStatus<TARGET> validate();
+ public BindingValidationStatus<TARGET> validate();
}
@@ -383,15 +383,15 @@ public class Binder<BEAN> implements Serializable {
* default behavior).
* <p>
* 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<BEAN> implements Serializable {
}
/**
- * Sets a {@link ValidationStatusHandler} to track validation status
+ * Sets a {@link BindingValidationStatusHandler} to track validation status
* changes.
* <p>
* The validation state of each field is updated whenever the user
@@ -436,7 +436,7 @@ public class Binder<BEAN> implements Serializable {
* @return this binding, for chaining
*/
public BindingBuilder<BEAN, TARGET> withValidationStatusHandler(
- ValidationStatusHandler handler);
+ BindingValidationStatusHandler handler);
/**
* Sets the field to be required. This means two things:
@@ -498,7 +498,7 @@ public class Binder<BEAN> implements Serializable {
private final Binder<BEAN> binder;
private final HasValue<FIELDVALUE> field;
- private ValidationStatusHandler statusHandler;
+ private BindingValidationStatusHandler statusHandler;
private boolean isStatusHandlerChanged;
private boolean bound;
@@ -526,7 +526,7 @@ public class Binder<BEAN> implements Serializable {
protected BindingBuilderImpl(Binder<BEAN> binder,
HasValue<FIELDVALUE> field,
Converter<FIELDVALUE, TARGET> converterValidatorChain,
- ValidationStatusHandler statusHandler) {
+ BindingValidationStatusHandler statusHandler) {
this.field = field;
this.binder = binder;
this.converterValidatorChain = converterValidatorChain;
@@ -573,12 +573,12 @@ public class Binder<BEAN> implements Serializable {
@Override
public BindingBuilder<BEAN, TARGET> 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<BEAN> implements Serializable {
private final Binder<BEAN> binder;
private final HasValue<FIELDVALUE> field;
- private final ValidationStatusHandler statusHandler;
+ private final BindingValidationStatusHandler statusHandler;
private final SerializableFunction<BEAN, TARGET> getter;
private final SerializableBiConsumer<BEAN, TARGET> setter;
@@ -726,10 +726,10 @@ public class Binder<BEAN> implements Serializable {
}
@Override
- public ValidationStatus<TARGET> validate() {
- ValidationStatus<TARGET> status = doValidation();
+ public BindingValidationStatus<TARGET> validate() {
+ BindingValidationStatus<TARGET> 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<BEAN> 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<BEAN> implements Serializable {
createValueContext());
}
- private ValidationStatus<TARGET> toValidationStatus(
+ private BindingValidationStatus<TARGET> toValidationStatus(
Result<TARGET> 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<BEAN> 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<TARGET> doValidation() {
+ private BindingValidationStatus<TARGET> doValidation() {
return toValidationStatus(doConversion());
}
@@ -814,13 +814,13 @@ public class Binder<BEAN> implements Serializable {
getBinder().setHasChanges(true);
List<ValidationResult> binderValidationResults = Collections
.emptyList();
- ValidationStatus<TARGET> fieldValidationStatus;
+ BindingValidationStatus<TARGET> 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<BEAN> implements Serializable {
BinderValidationStatus<BEAN> 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<BEAN> implements Serializable {
* @param bean
* the bean to set the property value to
*/
- private ValidationStatus<TARGET> writeFieldValue(BEAN bean) {
+ private BindingValidationStatus<TARGET> writeFieldValue(BEAN bean) {
assert bean != null;
Result<TARGET> result = doConversion();
@@ -864,8 +864,8 @@ public class Binder<BEAN> 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<BEAN> 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<BEAN> 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<BEAN> implements Serializable {
private BinderValidationStatus<BEAN> doWriteIfValid(BEAN bean) {
Objects.requireNonNull(bean, "bean cannot be null");
// First run fields level validation
- List<ValidationStatus<?>> bindingStatuses = validateBindings();
+ List<BindingValidationStatus<?>> 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<BEAN> implements Serializable {
* @return validation status for the binder
*/
public BinderValidationStatus<BEAN> validate() {
- List<ValidationStatus<?>> bindingStatuses = validateBindings();
+ List<BindingValidationStatus<?>> bindingStatuses = validateBindings();
BinderValidationStatus<BEAN> 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<BEAN> 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<BEAN> implements Serializable {
*
* @return an immutable list of validation results for bindings
*/
- private List<ValidationStatus<?>> validateBindings() {
- List<ValidationStatus<?>> results = new ArrayList<>();
+ private List<BindingValidationStatus<?>> validateBindings() {
+ List<BindingValidationStatus<?>> results = new ArrayList<>();
for (BindingImpl<?, ?, ?> binding : bindings) {
results.add(binding.doValidation());
}
@@ -1433,7 +1433,7 @@ public class Binder<BEAN> implements Serializable {
* @throws NullPointerException
* for <code>null</code> status handler
* @see #setStatusLabel(Label)
- * @see BindingBuilder#withValidationStatusHandler(ValidationStatusHandler)
+ * @see BindingBuilder#withValidationStatusHandler(BindingValidationStatusHandler)
*/
public void setValidationStatusHandler(
BinderValidationStatusHandler<BEAN> statusHandler) {
@@ -1516,7 +1516,7 @@ public class Binder<BEAN> implements Serializable {
*/
protected <FIELDVALUE, TARGET> BindingBuilder<BEAN, TARGET> createBinding(
HasValue<FIELDVALUE> field, Converter<FIELDVALUE, TARGET> converter,
- ValidationStatusHandler handler) {
+ BindingValidationStatusHandler handler) {
return new BindingBuilderImpl<>(this, field, converter, handler);
}
@@ -1554,12 +1554,12 @@ public class Binder<BEAN> 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<BEAN> 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<BEAN> implements Serializable {
private final Binder<BEAN> binder;
- private final List<ValidationStatus<?>> bindingStatuses;
+ private final List<BindingValidationStatus<?>> bindingStatuses;
private final List<ValidationResult> binderStatuses;
/**
@@ -72,7 +72,7 @@ public class BinderValidationStatus<BEAN> implements Serializable {
Binder<BEAN> 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<BEAN> implements Serializable {
* the validation results for binder level validation
*/
public BinderValidationStatus(Binder<BEAN> source,
- List<ValidationStatus<?>> bindingStatuses,
+ List<BindingValidationStatus<?>> bindingStatuses,
List<ValidationResult> binderStatuses) {
Objects.requireNonNull(binderStatuses,
"binding statuses cannot be null");
@@ -118,7 +118,7 @@ public class BinderValidationStatus<BEAN> 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<BEAN> implements Serializable {
*
* @return the field validation statuses
*/
- public List<ValidationStatus<?>> getFieldValidationStatuses() {
+ public List<BindingValidationStatus<?>> getFieldValidationStatuses() {
return bindingStatuses;
}
@@ -179,8 +179,8 @@ public class BinderValidationStatus<BEAN> implements Serializable {
*
* @return a list of failed field level validation statuses
*/
- public List<ValidationStatus<?>> getFieldValidationErrors() {
- return bindingStatuses.stream().filter(ValidationStatus::isError)
+ public List<BindingValidationStatus<?>> 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 <BEAN>
* the bean type of binder
@@ -46,6 +44,14 @@ import com.vaadin.ui.AbstractComponent;
*/
@FunctionalInterface
public interface BinderValidationStatusHandler<BEAN>
- extends Consumer<BinderValidationStatus<BEAN>>, Serializable {
+ extends SerializableEventListener {
+
+ /**
+ * Invoked when the validation status has changed in binder.
+ *
+ * @param statusChange
+ * the changed status
+ */
+ void statusChange(BinderValidationStatus<BEAN> statusChange);
}
diff --git a/server/src/main/java/com/vaadin/data/ValidationStatus.java b/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}.
* <p>
* 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<TARGET> implements Serializable {
+public class BindingValidationStatus<TARGET> implements Serializable {
/**
* Status of the validation.
* <p>
- * 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<TARGET> implements Serializable {
* the target data type of the binding for which the validation
* status was reset
*/
- public static <TARGET> ValidationStatus<TARGET> createUnresolvedStatus(
+ public static <TARGET> BindingValidationStatus<TARGET> createUnresolvedStatus(
Binding<?, TARGET> source) {
- return new ValidationStatus<>(source, Status.UNRESOLVED, null);
+ return new BindingValidationStatus<>(source, Status.UNRESOLVED, null);
}
/**
@@ -98,7 +98,7 @@ public class ValidationStatus<TARGET> implements Serializable {
* @param result
* the result of the validation
*/
- public ValidationStatus(Binding<?, TARGET> source,
+ public BindingValidationStatus(Binding<?, TARGET> source,
ValidationResult result) {
this(source, result.isError() ? Status.ERROR : Status.OK, result);
}
@@ -116,7 +116,7 @@ public class ValidationStatus<TARGET> implements Serializable {
* @param result
* the related result, may be {@code null}
*/
- public ValidationStatus(Binding<?, TARGET> source, Status status,
+ public BindingValidationStatus(Binding<?, TARGET> 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
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.
* <p>
* {@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<ValidationStatus<?>>, 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<V> extends Serializable {
* @see Registration
*/
@FunctionalInterface
- public interface ValueChangeListener<V>
- extends Consumer<ValueChangeEvent<V>>, Serializable {
+ public interface ValueChangeListener<V> 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<V> extends Serializable {
* @param event
* the received event, not null
*/
- @Override
- public void accept(ValueChangeEvent<V> event);
+ public void valueChange(ValueChangeEvent<V> event);
}
/**
@@ -263,7 +263,7 @@ public interface HasValue<V> extends Serializable {
* <p>
* 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<ValidationStatus<?>> fieldValidationErrors;
+ private final List<BindingValidationStatus<?>> fieldValidationErrors;
private final List<ValidationResult> beanValidationErrors;
/**
@@ -44,7 +44,7 @@ public class ValidationException extends Exception {
* @param beanValidationErrors
* binder validation errors list
*/
- public ValidationException(List<ValidationStatus<?>> fieldValidationErrors,
+ public ValidationException(List<BindingValidationStatus<?>> fieldValidationErrors,
List<ValidationResult> 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<ValidationStatus<?>> getFieldValidationErrors() {
+ public List<BindingValidationStatus<?>> 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 <T>
- * the data type of the selection model
+ * the type of the selected item
+ *
+ * @see SelectionModel.Multi
+ * @see MultiSelectionEvent
*/
@FunctionalInterface
-public interface MultiSelectionListener<T>
- extends Consumer<MultiSelectionEvent<T>>, Serializable {
- @Override
- // Explicitly defined to make reflection logic happy
- void accept(MultiSelectionEvent<T> event);
+public interface MultiSelectionListener<T> 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<T> 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<T>
- extends SerializableConsumer<SelectionEvent<T>> {
+public interface SelectionListener<T> extends SerializableEventListener {
+
+ /**
+ * Invoked when the selection has changed by user or programmatically.
+ *
+ * @param event
+ * the selection event
+ */
+ public void selectionChange(SelectionEvent<T> 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 <T>
* the type of the selected item
*
+ * @see SelectionModel.Single
* @see SingleSelectionEvent
- *
- * @since 8.0
*/
@FunctionalInterface
-public interface SingleSelectionListener<T>
- extends Consumer<SingleSelectionEvent<T>>, Serializable {
+public interface SingleSelectionListener<T> 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<T> event);
+ /**
+ * Invoked when selection has been changed by the user or programmatically.
+ *
+ * @param event
+ * the selection event
+ */
+ public void selectionChange(SingleSelectionEvent<T> 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<T> extends AbstractComponent
implements HasValue<T>, 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<T> extends AbstractComponent
public Registration addValueChangeListener(
ValueChangeListener<T> 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<T> extends AbstractListing<T>
}
}
- @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<T> extends AbstractListing<T>
public Registration addSelectionListener(
MultiSelectionListener<T> listener) {
return addListener(MultiSelectionEvent.class, listener,
- SELECTION_CHANGE_METHOD);
+ MultiSelectionListener.SELECTION_CHANGE_METHOD);
}
@Override
@@ -231,7 +224,7 @@ public abstract class AbstractMultiSelect<T> extends AbstractListing<T>
@Override
public Registration addValueChangeListener(
HasValue.ValueChangeListener<Set<T>> 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<T> extends AbstractListing<T>
implements SingleSelect<T> {
- @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.
* <p>
@@ -106,7 +99,7 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T>
public Registration addSelectionListener(
SingleSelectionListener<T> listener) {
return addListener(SingleSelectionEvent.class, listener,
- SELECTION_CHANGE_METHOD);
+ SingleSelectionListener.SELECTION_CHANGE_METHOD);
}
/**
@@ -168,7 +161,7 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T>
@Override
public Registration addValueChangeListener(
HasValue.ValueChangeListener<T> 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<T> extends AbstractSingleSelect<T>
public Registration addValueChangeListener(
HasValue.ValueChangeListener<T> 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<T> extends AbstractListing<T>
@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<T> extends AbstractListing<T>
@Override
public default Registration addSelectionListener(
SelectionListener<T> listener) {
- return addSingleSelectionListener(e -> listener.accept(e));
+ return addSingleSelectionListener(e -> listener.selectionChange(e));
}
/**
@@ -303,7 +302,7 @@ public class Grid<T> extends AbstractListing<T>
@Override
public default Registration addSelectionListener(
SelectionListener<T> listener) {
- return addMultiSelectionListener(e -> listener.accept(e));
+ return addMultiSelectionListener(e -> listener.selectionChange(e));
}
/**
@@ -482,8 +481,7 @@ public class Grid<T> extends AbstractListing<T>
* @see Registration
*/
@FunctionalInterface
- public interface ItemClickListener<T>
- extends Consumer<ItemClick<T>>, ConnectorEventListener {
+ public interface ItemClickListener<T> 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<T> extends AbstractListing<T>
* @param event
* the received event, not null
*/
- @Override
- public void accept(ItemClick<T> event);
+ public void itemClick(ItemClick<T> event);
}
/**
@@ -3648,9 +3645,9 @@ public class Grid<T> extends AbstractListing<T>
for (Column<T, ?> 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<T> extends AbstractGridExtension<T>
implements BinderValidationStatusHandler<T> {
@Override
- public void accept(BinderValidationStatus<T> status) {
+ public void statusChange(BinderValidationStatus<T> 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<T> extends AbstractSelectionModel<T>
}
}
- @Deprecated
- private static final Method SELECTION_CHANGE_METHOD = ReflectTools
- .findMethod(MultiSelectionListener.class, "accept",
- MultiSelectionEvent.class);
-
private Set<T> selection = new LinkedHashSet<>();
private SelectAllCheckBoxVisibility selectAllCheckBoxVisibility = SelectAllCheckBoxVisibility.DEFAULT;
@@ -247,7 +240,7 @@ public class MultiSelectionModelImpl<T> extends AbstractSelectionModel<T>
public Registration addMultiSelectionListener(
MultiSelectionListener<T> listener) {
return addListener(MultiSelectionEvent.class, listener,
- SELECTION_CHANGE_METHOD);
+ MultiSelectionListener.SELECTION_CHANGE_METHOD);
}
@Override
@@ -296,7 +289,8 @@ public class MultiSelectionModelImpl<T> extends AbstractSelectionModel<T>
@Override
public Registration addValueChangeListener(
com.vaadin.data.HasValue.ValueChangeListener<Set<T>> 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<T> extends AbstractSelectionModel<T>
implements SingleSelectionModel<T> {
- 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<T> extends AbstractSelectionModel<T>
public Registration addSingleSelectionListener(
SingleSelectionListener<T> listener) {
return addListener(SingleSelectionEvent.class, listener,
- SELECTION_CHANGE_METHOD);
+ SingleSelectionListener.SELECTION_CHANGE_METHOD);
}
@Override
@@ -250,7 +244,7 @@ public class SingleSelectionModelImpl<T> extends AbstractSelectionModel<T>
com.vaadin.data.HasValue.ValueChangeListener<T> listener) {
return SingleSelectionModelImpl.this.addSingleSelectionListener(
(SingleSelectionListener<T>) 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<ValidationStatus<?>> errors = status.getFieldValidationErrors();
+ List<BindingValidationStatus<?>> 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<LocalDate> result = returnBinding.validate();
+ BindingValidationStatus<LocalDate> 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<ValidationStatus<?>> statusCapture = new AtomicReference<>();
+ AtomicReference<BindingValidationStatus<?>> 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<Person> status = binder.validate();
- List<ValidationStatus<?>> errors = status.getFieldValidationErrors();
+ List<BindingValidationStatus<?>> 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<ValidationStatus<?>> validationErrors,
+ List<BindingValidationStatus<?>> 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<ValidationStatus<?>> errors = binder.validate()
+ List<BindingValidationStatus<?>> errors = binder.validate()
.getFieldValidationErrors();
assertEquals(0, errors.size());
}
@@ -275,10 +275,10 @@ public class BinderConverterValidatorTest
Person person = new Person();
binder.setBean(person);
- List<ValidationStatus<?>> errors = binder.validate()
+ List<BindingValidationStatus<?>> 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<ValidationStatus<?>> errors = binder.validate()
+ List<BindingValidationStatus<?>> 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<ValidationStatus<?>> validationErrors = exception
+ List<BindingValidationStatus<?>> 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<Binder<Person>, 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<ValidationStatus<?>> statusCapture = new AtomicReference<>();
+ AtomicReference<BindingValidationStatus<?>> statusCapture = new AtomicReference<>();
BindingBuilder<Person, String> 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<ValidationStatus<?>> bindingStatuses = status
+ List<BindingValidationStatus<?>> 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<ValidationStatus<?>> bindingStatuses = status
+ List<BindingValidationStatus<?>> 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<ValidationStatus<?>> results = capture.get()
+ List<BindingValidationStatus<?>> 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<S extends AbstractMultiSelect<String> & 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<T extends AbstractField<V>, V>
private ValueChangeListener<V> valueChangeListener = new ValueChangeListener<V>() {
@Override
- public void accept(ValueChangeEvent<V> event) {
+ public void valueChange(ValueChangeEvent<V> 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<LocalDate> event) {
+ public void valueChange(ValueChangeEvent<LocalDate> 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<Boolean> event) {
+ public void valueChange(ValueChangeEvent<Boolean> event) {
if (table.getListeners(HeaderClickEvent.class)
.isEmpty()) {
table.addHeaderClickListener(headerClickListener);
@@ -80,7 +80,7 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog {
};
@Override
- public void accept(ValueChangeEvent<Boolean> event) {
+ public void valueChange(ValueChangeEvent<Boolean> event) {
if (table.getListeners(FooterClickEvent.class)
.isEmpty()) {
table.addFooterClickListener(footerClickListener);