Browse Source

Added @since tags, some tweaks to formatting. (#11839)

tags/8.10.0.alpha1
Anna Koskinen 4 years ago
parent
commit
7895a74211

+ 5
- 2
server/src/main/java/com/vaadin/data/BeanValidationBinder.java View File

@@ -49,7 +49,7 @@ public class BeanValidationBinder<BEAN> extends Binder<BEAN> {
* the bean type to use, not <code>null</code>
*/
public BeanValidationBinder(Class<BEAN> beanType) {
this(beanType,false);
this(beanType, false);
}

/**
@@ -65,8 +65,11 @@ public class BeanValidationBinder<BEAN> extends Binder<BEAN> {
* 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<BEAN> beanType, boolean scanNestedDefinitions) {
public BeanValidationBinder(Class<BEAN> beanType,
boolean scanNestedDefinitions) {
super(beanType, scanNestedDefinitions);
if (!BeanUtil.checkBeanValidationAvailable()) {
throw new IllegalStateException(BeanValidationBinder.class

+ 25
- 15
server/src/main/java/com/vaadin/data/Binder.java View File

@@ -228,26 +228,30 @@ public class Binder<BEAN> implements Serializable {
public Setter<BEAN, TARGET> 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<BEAN> 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<BEAN> 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<BEAN> 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<BEAN> implements Serializable {
* <p>
* 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<BEAN> 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<BEAN> 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<BEAN> implements Serializable {
* the set of bindings to write to the bean
*/
@SuppressWarnings({ "unchecked" })
private void doWriteDraft(BEAN bean, Collection<Binding<BEAN, ?>> bindings) {
private void doWriteDraft(BEAN bean,
Collection<Binding<BEAN, ?>> bindings) {
Objects.requireNonNull(bean, "bean cannot be null");

bindings.forEach(binding -> ((BindingImpl<BEAN, ?, ?>) binding)
.writeFieldValue(bean));
.writeFieldValue(bean));
}

/**

+ 4
- 1
server/src/main/java/com/vaadin/server/VaadinService.java View File

@@ -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)) {

Loading…
Cancel
Save