Skip to content

Commit 340b32a

Browse files
committed
Polishing
1 parent a7b7466 commit 340b32a

File tree

11 files changed

+243
-214
lines changed

11 files changed

+243
-214
lines changed

spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -102,8 +102,8 @@ public void reject(String errorCode, @Nullable Object[] errorArgs, @Nullable Str
102102
}
103103

104104
@Override
105-
public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs,
106-
@Nullable String defaultMessage) {
105+
public void rejectValue(@Nullable String field, String errorCode,
106+
@Nullable Object[] errorArgs, @Nullable String defaultMessage) {
107107

108108
if (!StringUtils.hasLength(getNestedPath()) && !StringUtils.hasLength(field)) {
109109
// We're at the top of the nested object hierarchy,

spring-context/src/main/java/org/springframework/validation/AbstractErrors.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,13 +28,14 @@
2828
import org.springframework.util.StringUtils;
2929

3030
/**
31-
* Abstract implementation of the {@link Errors} interface. Provides common
32-
* access to evaluated errors; however, does not define concrete management
31+
* Abstract implementation of the {@link Errors} interface.
32+
* Provides nested path handling but does not define concrete management
3333
* of {@link ObjectError ObjectErrors} and {@link FieldError FieldErrors}.
3434
*
3535
* @author Juergen Hoeller
3636
* @author Rossen Stoyanchev
3737
* @since 2.5.3
38+
* @see AbstractBindingResult
3839
*/
3940
@SuppressWarnings("serial")
4041
public abstract class AbstractErrors implements Errors, Serializable {
@@ -81,8 +82,8 @@ protected void doSetNestedPath(@Nullable String nestedPath) {
8182
nestedPath = "";
8283
}
8384
nestedPath = canonicalFieldName(nestedPath);
84-
if (nestedPath.length() > 0 && !nestedPath.endsWith(Errors.NESTED_PATH_SEPARATOR)) {
85-
nestedPath += Errors.NESTED_PATH_SEPARATOR;
85+
if (nestedPath.length() > 0 && !nestedPath.endsWith(NESTED_PATH_SEPARATOR)) {
86+
nestedPath += NESTED_PATH_SEPARATOR;
8687
}
8788
this.nestedPath = nestedPath;
8889
}
@@ -97,7 +98,7 @@ protected String fixedField(@Nullable String field) {
9798
}
9899
else {
99100
String path = getNestedPath();
100-
return (path.endsWith(Errors.NESTED_PATH_SEPARATOR) ?
101+
return (path.endsWith(NESTED_PATH_SEPARATOR) ?
101102
path.substring(0, path.length() - NESTED_PATH_SEPARATOR.length()) : path);
102103
}
103104
}
@@ -201,9 +202,9 @@ public List<FieldError> getFieldErrors(String field) {
201202
List<FieldError> fieldErrors = getFieldErrors();
202203
List<FieldError> result = new ArrayList<>();
203204
String fixedField = fixedField(field);
204-
for (FieldError error : fieldErrors) {
205-
if (isMatchingFieldError(fixedField, error)) {
206-
result.add(error);
205+
for (FieldError fieldError : fieldErrors) {
206+
if (isMatchingFieldError(fixedField, fieldError)) {
207+
result.add(fieldError);
207208
}
208209
}
209210
return Collections.unmodifiableList(result);

spring-context/src/main/java/org/springframework/validation/BeanPropertyBindingResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public class BeanPropertyBindingResult extends AbstractPropertyBindingResult imp
5555

5656

5757
/**
58-
* Creates a new instance of the {@link BeanPropertyBindingResult} class.
58+
* Create a new {@code BeanPropertyBindingResult} for the given target.
5959
* @param target the target bean to bind onto
6060
* @param objectName the name of the target object
6161
*/
@@ -64,7 +64,7 @@ public BeanPropertyBindingResult(@Nullable Object target, String objectName) {
6464
}
6565

6666
/**
67-
* Creates a new instance of the {@link BeanPropertyBindingResult} class.
67+
* Create a new {@code BeanPropertyBindingResult} for the given target.
6868
* @param target the target bean to bind onto
6969
* @param objectName the name of the target object
7070
* @param autoGrowNestedPaths whether to "auto-grow" a nested path that contains a null value

spring-context/src/main/java/org/springframework/validation/BindException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -128,7 +128,9 @@ public void rejectValue(@Nullable String field, String errorCode, String default
128128
}
129129

130130
@Override
131-
public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
131+
public void rejectValue(@Nullable String field, String errorCode,
132+
@Nullable Object[] errorArgs, @Nullable String defaultMessage) {
133+
132134
this.bindingResult.rejectValue(field, errorCode, errorArgs, defaultMessage);
133135
}
134136

spring-context/src/main/java/org/springframework/validation/DirectFieldBindingResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class DirectFieldBindingResult extends AbstractPropertyBindingResult {
4646

4747

4848
/**
49-
* Create a new DirectFieldBindingResult instance.
49+
* Create a new {@code DirectFieldBindingResult} for the given target.
5050
* @param target the target object to bind onto
5151
* @param objectName the name of the target object
5252
*/
@@ -55,7 +55,7 @@ public DirectFieldBindingResult(@Nullable Object target, String objectName) {
5555
}
5656

5757
/**
58-
* Create a new DirectFieldBindingResult instance.
58+
* Create a new {@code DirectFieldBindingResult} for the given target.
5959
* @param target the target object to bind onto
6060
* @param objectName the name of the target object
6161
* @param autoGrowNestedPaths whether to "auto-grow" a nested path that contains a null value

0 commit comments

Comments
 (0)