From b2e3aa2acf99e98dc3e5ac3c96ec829fe3896c47 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 14 Dec 2016 14:32:07 +0200 Subject: [PATCH] Rename setRequired to asRequired since it's logically not a setter (#7986) --- server/src/main/java/com/vaadin/data/BeanBinder.java | 10 +++++----- server/src/main/java/com/vaadin/data/Binder.java | 12 ++++++------ server/src/test/java/com/vaadin/data/BinderTest.java | 4 ++-- .../com/vaadin/data/validator/NotEmptyValidator.java | 9 +++++---- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/server/src/main/java/com/vaadin/data/BeanBinder.java b/server/src/main/java/com/vaadin/data/BeanBinder.java index c04a36186a..8231c56bfc 100644 --- a/server/src/main/java/com/vaadin/data/BeanBinder.java +++ b/server/src/main/java/com/vaadin/data/BeanBinder.java @@ -97,13 +97,13 @@ public class BeanBinder extends Binder { } @Override - public BeanBindingBuilder setRequired( + public BeanBindingBuilder asRequired( ErrorMessageProvider errorMessageProvider); @Override - public default BeanBindingBuilder setRequired( + public default BeanBindingBuilder asRequired( String errorMessage) { - return (BeanBindingBuilder) BindingBuilder.super.setRequired( + return (BeanBindingBuilder) BindingBuilder.super.asRequired( errorMessage); } @@ -222,9 +222,9 @@ public class BeanBinder extends Binder { } @Override - public BeanBindingBuilder setRequired( + public BeanBindingBuilder asRequired( ErrorMessageProvider errorMessageProvider) { - return (BeanBindingBuilder) super.setRequired( + return (BeanBindingBuilder) super.asRequired( errorMessageProvider); } diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java index 41c07a4c08..794c6807c4 100644 --- a/server/src/main/java/com/vaadin/data/Binder.java +++ b/server/src/main/java/com/vaadin/data/Binder.java @@ -445,21 +445,21 @@ public class Binder implements Serializable { *
  • the field value is validated for not being empty*
  • * * For localizing the error message, use - * {@link #setRequired(SerializableFunction)}. + * {@link #asRequired(ErrorMessageProvider)}. *

    * *Value not being the equal to what {@link HasValue#getEmptyValue()} * returns. * - * @see #setRequired(SerializableFunction) + * @see #asRequired(ErrorMessageProvider) * @see HasValue#setRequiredIndicatorVisible(boolean) * @see HasValue#isEmpty() * @param errorMessage * the error message to show for the invalid value * @return this binding, for chaining */ - public default BindingBuilder setRequired( + public default BindingBuilder asRequired( String errorMessage) { - return setRequired(context -> errorMessage); + return asRequired(context -> errorMessage); } /** @@ -477,7 +477,7 @@ public class Binder implements Serializable { * the provider for localized validation error message * @return this binding, for chaining */ - public BindingBuilder setRequired( + public BindingBuilder asRequired( ErrorMessageProvider errorMessageProvider); } @@ -587,7 +587,7 @@ public class Binder implements Serializable { } @Override - public BindingBuilder setRequired( + public BindingBuilder asRequired( ErrorMessageProvider errorMessageProvider) { checkUnbound(); field.setRequiredIndicatorVisible(true); diff --git a/server/src/test/java/com/vaadin/data/BinderTest.java b/server/src/test/java/com/vaadin/data/BinderTest.java index 397676c062..b0d16bd9e7 100644 --- a/server/src/test/java/com/vaadin/data/BinderTest.java +++ b/server/src/test/java/com/vaadin/data/BinderTest.java @@ -334,7 +334,7 @@ public class BinderTest extends BinderTestBase, Person> { BindingBuilder binding = binder.forField(textField); Assert.assertFalse(textField.isRequiredIndicatorVisible()); - binding.setRequired("foobar"); + binding.asRequired("foobar"); Assert.assertTrue(textField.isRequiredIndicatorVisible()); binding.bind(Person::getFirstName, Person::setFirstName); @@ -361,7 +361,7 @@ public class BinderTest extends BinderTestBase, Person> { Assert.assertFalse(textField.isRequiredIndicatorVisible()); AtomicInteger invokes = new AtomicInteger(); - binding.setRequired(context -> { + binding.asRequired(context -> { invokes.incrementAndGet(); Assert.assertSame(Locale.CANADA, context.getLocale().get()); return "foobar"; diff --git a/server/src/test/java/com/vaadin/data/validator/NotEmptyValidator.java b/server/src/test/java/com/vaadin/data/validator/NotEmptyValidator.java index 3a358b7097..faa37367b0 100644 --- a/server/src/test/java/com/vaadin/data/validator/NotEmptyValidator.java +++ b/server/src/test/java/com/vaadin/data/validator/NotEmptyValidator.java @@ -33,13 +33,14 @@ import com.vaadin.data.util.converter.ValueContext; * This validator can be suitable for fields that have been marked as required * with {@link HasValue#setRequiredIndicatorVisible(boolean)}. *

    - * Note that {@link BindingBuilder#setRequired(com.vaadin.data.ErrorMessageProvider)} - * does almost the same thing, but verifies against the value NOT being equal to - * what {@link HasValue#getEmptyValue()} returns and sets the required indicator + * Note that + * {@link BindingBuilder#asRequired(com.vaadin.data.ErrorMessageProvider)} does + * almost the same thing, but verifies against the value NOT being equal to what + * {@link HasValue#getEmptyValue()} returns and sets the required indicator * visible with {@link HasValue#setRequiredIndicatorVisible(boolean)}. * * @see HasValue#setRequiredIndicatorVisible(boolean) - * @see BindingBuilder#setRequired(com.vaadin.data.ErrorMessageProvider) + * @see BindingBuilder#asRequired(com.vaadin.data.ErrorMessageProvider) * @author Vaadin Ltd * @since 8.0 * -- 2.39.5