From 10d4d70b5e2ee7879eec67f1ce91fea01929b5a1 Mon Sep 17 00:00:00 2001 From: Ilia Motornyi Date: Thu, 15 Dec 2016 13:45:08 +0200 Subject: [PATCH] Rename SerializableBiConsumer into Setter --- .../main/java/com/vaadin/data/BeanBinder.java | 6 ++-- .../src/main/java/com/vaadin/data/Binder.java | 24 +++++++-------- .../com/vaadin/data/StatusChangeEvent.java | 4 +-- ...erializableBiConsumer.java => Setter.java} | 29 ++++++++++++++----- 4 files changed, 38 insertions(+), 25 deletions(-) rename server/src/main/java/com/vaadin/server/{SerializableBiConsumer.java => Setter.java} (53%) diff --git a/server/src/main/java/com/vaadin/data/BeanBinder.java b/server/src/main/java/com/vaadin/data/BeanBinder.java index 56219ff6bf..07bc40b1dd 100644 --- a/server/src/main/java/com/vaadin/data/BeanBinder.java +++ b/server/src/main/java/com/vaadin/data/BeanBinder.java @@ -36,7 +36,7 @@ import com.googlecode.gentyref.GenericTypeReflector; import com.vaadin.annotations.PropertyId; import com.vaadin.data.util.BeanUtil; import com.vaadin.data.validator.BeanValidator; -import com.vaadin.server.SerializableBiConsumer; +import com.vaadin.server.Setter; import com.vaadin.server.SerializableFunction; import com.vaadin.server.SerializablePredicate; import com.vaadin.ui.Label; @@ -161,7 +161,7 @@ public class BeanBinder extends Binder { * if the property has no accessible getter * * @see BindingBuilder#bind(ValueProvider, - * SerializableBiConsumer) + * Setter) */ public Binding bind(String propertyName); } @@ -361,7 +361,7 @@ public class BeanBinder extends Binder { * @throws IllegalArgumentException * if the property has no accessible getter * - * @see #bind(HasValue, ValueProvider, SerializableBiConsumer) + * @see #bind(HasValue, ValueProvider, Setter) */ public Binding bind( HasValue field, String propertyName) { diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java index 9f496d04d2..94a16d9da9 100644 --- a/server/src/main/java/com/vaadin/data/Binder.java +++ b/server/src/main/java/com/vaadin/data/Binder.java @@ -34,7 +34,7 @@ import com.vaadin.data.HasValue.ValueChangeEvent; import com.vaadin.data.converter.StringToIntegerConverter; import com.vaadin.event.EventRouter; import com.vaadin.server.ErrorMessage; -import com.vaadin.server.SerializableBiConsumer; +import com.vaadin.server.Setter; import com.vaadin.server.SerializableFunction; import com.vaadin.server.SerializablePredicate; import com.vaadin.server.UserError; @@ -173,7 +173,7 @@ public class Binder implements Serializable { */ public Binding bind( ValueProvider getter, - com.vaadin.server.SerializableBiConsumer setter); + Setter setter); /** * Adds a validator to this binding. Validators are applied, in @@ -255,7 +255,7 @@ public class Binder implements Serializable { * which must match the current target data type of the binding, and a * model type, which can be any data type and becomes the new target * type of the binding. When invoking - * {@link #bind(ValueProvider, SerializableBiConsumer)}, the + * {@link #bind(ValueProvider, Setter)}, the * target type of the binding must match the getter/setter types. *

* For instance, a {@code TextField} can be bound to an integer-typed @@ -281,7 +281,7 @@ public class Binder implements Serializable { * type, which must match the current target data type of the binding, * and a model type, which can be any data type and becomes the new * target type of the binding. When invoking - * {@link #bind(ValueProvider, SerializableBiConsumer)}, the + * {@link #bind(ValueProvider, Setter)}, the * target type of the binding must match the getter/setter types. *

* For instance, a {@code TextField} can be bound to an integer-typed @@ -316,7 +316,7 @@ public class Binder implements Serializable { * type, which must match the current target data type of the binding, * and a model type, which can be any data type and becomes the new * target type of the binding. When invoking - * {@link #bind(ValueProvider, SerializableBiConsumer)}, the + * {@link #bind(ValueProvider, Setter)}, the * target type of the binding must match the getter/setter types. *

* For instance, a {@code TextField} can be bound to an integer-typed @@ -534,7 +534,7 @@ public class Binder implements Serializable { @Override public Binding bind( ValueProvider getter, - SerializableBiConsumer setter) { + Setter setter) { checkUnbound(); Objects.requireNonNull(getter, "getter cannot be null"); @@ -673,7 +673,7 @@ public class Binder implements Serializable { private final BindingValidationStatusHandler statusHandler; private final SerializableFunction getter; - private final SerializableBiConsumer setter; + private final Setter setter; // Not final since we temporarily remove listener while changing values private Registration onValueChange; @@ -686,7 +686,7 @@ public class Binder implements Serializable { public BindingImpl(BindingBuilderImpl builder, SerializableFunction getter, - SerializableBiConsumer setter) { + Setter setter) { this.binder = builder.getBinder(); this.field = builder.field; this.statusHandler = builder.statusHandler; @@ -976,7 +976,7 @@ public class Binder implements Serializable { /** * Creates a new binding for the given field. The returned builder may be * further configured before invoking - * {@link BindingBuilder#bind(ValueProvider, SerializableBiConsumer)} + * {@link BindingBuilder#bind(ValueProvider, Setter)} * which completes the binding. Until {@code Binding.bind} is called, the * binding has no effect. *

@@ -993,7 +993,7 @@ public class Binder implements Serializable { * the field to be bound, not null * @return the new binding * - * @see #bind(HasValue, ValueProvider, SerializableBiConsumer) + * @see #bind(HasValue, ValueProvider, Setter) */ public BindingBuilder forField( HasValue field) { @@ -1061,7 +1061,7 @@ public class Binder implements Serializable { public Binding bind( HasValue field, ValueProvider getter, - SerializableBiConsumer setter) { + Setter setter) { return forField(field).bind(getter, setter); } @@ -1473,7 +1473,7 @@ public class Binder implements Serializable { *

  • {@link #setBean(Object)} is called *
  • {@link #removeBean()} is called *
  • - * {@link BindingBuilder#bind(ValueProvider, SerializableBiConsumer)} + * {@link BindingBuilder#bind(ValueProvider, Setter)} * is called *
  • {@link Binder#validate()} or {@link Binding#validate()} is called * diff --git a/server/src/main/java/com/vaadin/data/StatusChangeEvent.java b/server/src/main/java/com/vaadin/data/StatusChangeEvent.java index 2c4e87d897..42f92e654c 100644 --- a/server/src/main/java/com/vaadin/data/StatusChangeEvent.java +++ b/server/src/main/java/com/vaadin/data/StatusChangeEvent.java @@ -19,7 +19,7 @@ import java.util.EventObject; import com.vaadin.data.Binder.Binding; import com.vaadin.data.Binder.BindingBuilder; -import com.vaadin.server.SerializableBiConsumer; +import com.vaadin.server.Setter; /** * Binder status change event. @@ -32,7 +32,7 @@ import com.vaadin.server.SerializableBiConsumer; *
  • {@link Binder#readBean(Object)} is called *
  • {@link Binder#setBean(Object)} is called *
  • {@link Binder#removeBean()} is called - *
  • {@link BindingBuilder#bind(ValueProvider, SerializableBiConsumer)} + *
  • {@link BindingBuilder#bind(ValueProvider, Setter)} * is called *
  • {@link Binder#validate()} or {@link Binding#validate()} is called * diff --git a/server/src/main/java/com/vaadin/server/SerializableBiConsumer.java b/server/src/main/java/com/vaadin/server/Setter.java similarity index 53% rename from server/src/main/java/com/vaadin/server/SerializableBiConsumer.java rename to server/src/main/java/com/vaadin/server/Setter.java index 278d53fc05..87eb9ecd44 100644 --- a/server/src/main/java/com/vaadin/server/SerializableBiConsumer.java +++ b/server/src/main/java/com/vaadin/server/Setter.java @@ -15,24 +15,37 @@ */ package com.vaadin.server; +import com.vaadin.data.Binder; +import com.vaadin.data.HasValue; + import java.io.Serializable; import java.util.function.BiConsumer; /** - * A {@link BiConsumer} that is also {@link Serializable}. + * The function to write the field value to the bean property * * @see BiConsumer - * @param - * the type of the first argument to the operation - * @param - * the type of the second argument to the operation + * @see Binder#bind(HasValue, SerializableFunction, Setter) + * @param + * the type of the target bean + * @param + * the field value type to be written to the bean * * @since 8.0 * @author Vaadin Ltd * */ @FunctionalInterface -public interface SerializableBiConsumer - extends BiConsumer, Serializable { - // Only method inherited from BiConsumer +public interface Setter + extends BiConsumer, Serializable { + + /** Save value to the bean property + * + * @param bean + * the target bean + * @param fieldvalue + * the field value to be written to the bean + */ + @Override + void accept(BEAN bean, FIELDVALUE fieldvalue); } -- 2.39.5