From 7895a74211c12a45e614892ce3e24fba838186fd Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Wed, 4 Dec 2019 14:38:04 +0200 Subject: [PATCH] Added @since tags, some tweaks to formatting. (#11839) --- .../com/vaadin/data/BeanValidationBinder.java | 7 +++- .../src/main/java/com/vaadin/data/Binder.java | 40 ++++++++++++------- .../java/com/vaadin/server/VaadinService.java | 5 ++- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/server/src/main/java/com/vaadin/data/BeanValidationBinder.java b/server/src/main/java/com/vaadin/data/BeanValidationBinder.java index de67f922bf..44d0e1703f 100644 --- a/server/src/main/java/com/vaadin/data/BeanValidationBinder.java +++ b/server/src/main/java/com/vaadin/data/BeanValidationBinder.java @@ -49,7 +49,7 @@ public class BeanValidationBinder extends Binder { * the bean type to use, not null */ public BeanValidationBinder(Class beanType) { - this(beanType,false); + this(beanType, false); } /** @@ -65,8 +65,11 @@ public class BeanValidationBinder extends Binder { * the bean type to use, not {@code null} * @param scanNestedDefinitions * if {@code true}, scan for nested property definitions as well + * + * @since 8.10 */ - public BeanValidationBinder(Class beanType, boolean scanNestedDefinitions) { + public BeanValidationBinder(Class beanType, + boolean scanNestedDefinitions) { super(beanType, scanNestedDefinitions); if (!BeanUtil.checkBeanValidationAvailable()) { throw new IllegalStateException(BeanValidationBinder.class diff --git a/server/src/main/java/com/vaadin/data/Binder.java b/server/src/main/java/com/vaadin/data/Binder.java index cd7b834571..07dbf20ce4 100644 --- a/server/src/main/java/com/vaadin/data/Binder.java +++ b/server/src/main/java/com/vaadin/data/Binder.java @@ -228,26 +228,30 @@ public class Binder implements Serializable { public Setter getSetter(); /** - * Enable or disable asRequired validator. - * The validator is enabled by default. + * Enable or disable asRequired validator. The validator is enabled by + * default. * * @see #asRequired(String) * @see #asRequired(ErrorMessageProvider) * * @param asRequiredEnabled - * {@code false} if asRequired validator should - * be disabled, {@code true} otherwise (default) + * {@code false} if asRequired validator should be disabled, + * {@code true} otherwise (default) + * + * @since 8.10 */ public void setAsRequiredEnabled(boolean asRequiredEnabled); /** - * Returns whether asRequired validator is currently enabled or not + * Returns whether asRequired validator is currently enabled or not. * * @see #asRequired(String) * @see #asRequired(ErrorMessageProvider) * * @return {@code false} if asRequired validator is disabled * {@code true} otherwise (default) + * + * @since 8.10 */ public boolean isAsRequiredEnabled(); } @@ -946,10 +950,11 @@ public class Binder implements Serializable { this.asRequiredSet = true; field.setRequiredIndicatorVisible(true); return withValidator((value, context) -> { - if (!field.isRequiredIndicatorVisible()) + if (!field.isRequiredIndicatorVisible()) { return ValidationResult.ok(); - else + } else { return customRequiredValidator.apply(value, context); + } }); } @@ -1281,7 +1286,8 @@ public class Binder implements Serializable { * field doesn't accept null rather than throwing for some other * reason. */ - if (convertedValue == null && getField().getEmptyValue() != null) { + if (convertedValue == null + && getField().getEmptyValue() != null) { throw new IllegalStateException(String.format( "A field of type %s didn't accept a null value." + " If null values are expected, then configure a null representation for the binding.", @@ -1322,12 +1328,12 @@ public class Binder implements Serializable { public void setAsRequiredEnabled(boolean asRequiredEnabled) { if (!asRequiredSet) { throw new IllegalStateException( - "Unable to toggle asRequired validation since " - + "asRequired has not been set."); + "Unable to toggle asRequired validation since " + + "asRequired has not been set."); } if (asRequiredEnabled != isAsRequiredEnabled()) { field.setRequiredIndicatorVisible(asRequiredEnabled); - validate(); + validate(); } } @@ -1732,7 +1738,7 @@ public class Binder implements Serializable { *

* After updating each field, the value is read back from the field and the * bean's property value is updated if it has been changed from the original - * value by the field or a converter. + * value by the field or a converter. * * @see #readBean(Object) * @see #writeBean(Object) @@ -1799,8 +1805,9 @@ public class Binder implements Serializable { // avoid NPE inside initFieldValue. It happens e.g. when // we unbind a binding in valueChangeListener of another // field. - if (binding.getField() != null) + if (binding.getField() != null) { binding.initFieldValue(bean, false); + } }); getValidationStatusHandler().statusChange( BinderValidationStatus.createUnresolvedStatus(this)); @@ -1851,6 +1858,8 @@ public class Binder implements Serializable { * @param bean * the object to which to write the field values, not * {@code null} + * + * @since 8.10 */ public void writeBeanAsDraft(BEAN bean) { doWriteDraft(bean, new ArrayList<>(bindings)); @@ -1953,11 +1962,12 @@ public class Binder implements Serializable { * the set of bindings to write to the bean */ @SuppressWarnings({ "unchecked" }) - private void doWriteDraft(BEAN bean, Collection> bindings) { + private void doWriteDraft(BEAN bean, + Collection> bindings) { Objects.requireNonNull(bean, "bean cannot be null"); bindings.forEach(binding -> ((BindingImpl) binding) - .writeFieldValue(bean)); + .writeFieldValue(bean)); } /** diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java index f83441e1c3..7db1a4fd55 100644 --- a/server/src/main/java/com/vaadin/server/VaadinService.java +++ b/server/src/main/java/com/vaadin/server/VaadinService.java @@ -202,7 +202,7 @@ public abstract class VaadinService implements Serializable { * @since 8.2 */ protected VaadinService() { - this.deploymentConfiguration = null; + deploymentConfiguration = null; } /** @@ -1232,6 +1232,9 @@ public abstract class VaadinService implements Serializable { * default called at the end of each request, after sending the response. * * @param session + * the session to clean up + * + * @since 8.10 */ public void cleanupSession(VaadinSession session) { if (isSessionActive(session)) { -- 2.39.5