diff --git a/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java b/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java index c431cfddfc0..64b9c9b5fb1 100644 --- a/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java +++ b/spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java @@ -102,8 +102,8 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi } @Override - public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, - @Nullable String defaultMessage) { + public void rejectValue(@Nullable String field, String errorCode, + @Nullable Object[] errorArgs, @Nullable String defaultMessage) { if (!StringUtils.hasLength(getNestedPath()) && !StringUtils.hasLength(field)) { // We're at the top of the nested object hierarchy, diff --git a/spring-context/src/main/java/org/springframework/validation/BeanPropertyBindingResult.java b/spring-context/src/main/java/org/springframework/validation/BeanPropertyBindingResult.java index 8558a2619c9..1cc6bb8e365 100644 --- a/spring-context/src/main/java/org/springframework/validation/BeanPropertyBindingResult.java +++ b/spring-context/src/main/java/org/springframework/validation/BeanPropertyBindingResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class BeanPropertyBindingResult extends AbstractPropertyBindingResult imp /** - * Creates a new instance of the {@link BeanPropertyBindingResult} class. + * Create a new {@code BeanPropertyBindingResult} for the given target. * @param target the target bean to bind onto * @param objectName the name of the target object */ @@ -64,7 +64,7 @@ public class BeanPropertyBindingResult extends AbstractPropertyBindingResult imp } /** - * Creates a new instance of the {@link BeanPropertyBindingResult} class. + * Create a new {@code BeanPropertyBindingResult} for the given target. * @param target the target bean to bind onto * @param objectName the name of the target object * @param autoGrowNestedPaths whether to "auto-grow" a nested path that contains a null value diff --git a/spring-context/src/main/java/org/springframework/validation/BindException.java b/spring-context/src/main/java/org/springframework/validation/BindException.java index afc0c5c2ae7..b84c81081a8 100644 --- a/spring-context/src/main/java/org/springframework/validation/BindException.java +++ b/spring-context/src/main/java/org/springframework/validation/BindException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,7 +128,9 @@ public class BindException extends Exception implements BindingResult { } @Override - public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) { + public void rejectValue(@Nullable String field, String errorCode, + @Nullable Object[] errorArgs, @Nullable String defaultMessage) { + this.bindingResult.rejectValue(field, errorCode, errorArgs, defaultMessage); } diff --git a/spring-context/src/main/java/org/springframework/validation/DirectFieldBindingResult.java b/spring-context/src/main/java/org/springframework/validation/DirectFieldBindingResult.java index 5ad401de5be..f01232ca1f6 100644 --- a/spring-context/src/main/java/org/springframework/validation/DirectFieldBindingResult.java +++ b/spring-context/src/main/java/org/springframework/validation/DirectFieldBindingResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ public class DirectFieldBindingResult extends AbstractPropertyBindingResult { /** - * Create a new DirectFieldBindingResult instance. + * Create a new {@code DirectFieldBindingResult} for the given target. * @param target the target object to bind onto * @param objectName the name of the target object */ @@ -55,7 +55,7 @@ public class DirectFieldBindingResult extends AbstractPropertyBindingResult { } /** - * Create a new DirectFieldBindingResult instance. + * Create a new {@code DirectFieldBindingResult} for the given target. * @param target the target object to bind onto * @param objectName the name of the target object * @param autoGrowNestedPaths whether to "auto-grow" a nested path that contains a null value diff --git a/spring-context/src/main/java/org/springframework/validation/Errors.java b/spring-context/src/main/java/org/springframework/validation/Errors.java index 221b06d9c7b..a44bbd3ad5c 100644 --- a/spring-context/src/main/java/org/springframework/validation/Errors.java +++ b/spring-context/src/main/java/org/springframework/validation/Errors.java @@ -39,7 +39,6 @@ import org.springframework.lang.Nullable; * * @author Rod Johnson * @author Juergen Hoeller - * @see #setNestedPath * @see Validator * @see ValidationUtils * @see SimpleErrors @@ -231,7 +230,7 @@ public interface Errors { } /** - * BReturn if there were any errors. + * Determine if there were any errors. * @see #hasGlobalErrors() * @see #hasFieldErrors() */ @@ -240,7 +239,7 @@ public interface Errors { } /** - * Return the total number of errors. + * Determine the total number of errors. * @see #getGlobalErrorCount() * @see #getFieldErrorCount() */ @@ -250,7 +249,7 @@ public interface Errors { /** * Get all errors, both global and field ones. - * @return a list of {@link ObjectError} instances + * @return a list of {@link ObjectError}/{@link FieldError} instances * @see #getGlobalErrors() * @see #getFieldErrors() */ @@ -259,8 +258,7 @@ public interface Errors { } /** - * Are there any global errors? - * @return {@code true} if there are any global errors + * Determine if there were any global errors. * @see #hasFieldErrors() */ default boolean hasGlobalErrors() { @@ -268,8 +266,7 @@ public interface Errors { } /** - * Return the number of global errors. - * @return the number of global errors + * Determine the number of global errors. * @see #getFieldErrorCount() */ default int getGlobalErrorCount() { @@ -294,8 +291,7 @@ public interface Errors { } /** - * Are there any field errors? - * @return {@code true} if there are any errors associated with a field + * Determine if there were any errors associated with a field. * @see #hasGlobalErrors() */ default boolean hasFieldErrors() { @@ -303,8 +299,7 @@ public interface Errors { } /** - * Return the number of errors associated with a field. - * @return the number of errors associated with a field + * Determine the number of errors associated with a field. * @see #getGlobalErrorCount() */ default int getFieldErrorCount() { @@ -329,9 +324,8 @@ public interface Errors { } /** - * Are there any errors associated with the given field? + * Determine if there were any errors associated with the given field. * @param field the field name - * @return {@code true} if there were any errors associated with the given field * @see #hasFieldErrors() */ default boolean hasFieldErrors(String field) { @@ -339,9 +333,8 @@ public interface Errors { } /** - * Return the number of errors associated with the given field. + * Determine the number of errors associated with the given field. * @param field the field name - * @return the number of errors associated with the given field * @see #getFieldErrorCount() */ default int getFieldErrorCount(String field) { @@ -384,7 +377,7 @@ public interface Errors { Object getFieldValue(String field); /** - * Return the type of a given field. + * Determine the type of the given field, as far as possible. *

Implementations should be able to determine the type even * when the field value is {@code null}, for example from some * associated descriptor. diff --git a/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java b/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java index eb1166f9ade..9edffefc90e 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java +++ b/spring-web/src/main/java/org/springframework/web/bind/EscapedErrors.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,8 +110,8 @@ public class EscapedErrors implements Errors { } @Override - public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, - @Nullable String defaultMessage) { + public void rejectValue(@Nullable String field, String errorCode, + @Nullable Object[] errorArgs, @Nullable String defaultMessage) { this.source.rejectValue(field, errorCode, errorArgs, defaultMessage); } diff --git a/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeBindException.java b/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeBindException.java index 9cfe9616a89..d6a90a07954 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeBindException.java +++ b/spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeBindException.java @@ -145,8 +145,8 @@ public class WebExchangeBindException extends ServerWebInputException implements } @Override - public void rejectValue( - @Nullable String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) { + public void rejectValue(@Nullable String field, String errorCode, + @Nullable Object[] errorArgs, @Nullable String defaultMessage) { this.bindingResult.rejectValue(field, errorCode, errorArgs, defaultMessage); }