• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.28
today-context/src/main/java/infra/validation/method/ParameterErrors.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.validation.method;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.util.List;
23

24
import infra.core.MethodParameter;
25
import infra.validation.Errors;
26
import infra.validation.FieldError;
27
import infra.validation.ObjectError;
28

29
/**
30
 * Extension of {@link ParameterValidationResult} created for Object method
31
 * parameters or return values with nested errors on their properties.
32
 *
33
 * <p>The base class method {@link #getResolvableErrors()} returns
34
 * {@link Errors#getAllErrors()}, but this subclass provides access to the same
35
 * as {@link FieldError}s.
36
 *
37
 * <p>When the method parameter is a container such as a {@link List}, array,
38
 * or {@link java.util.Map}, then a separate {@link ParameterErrors} is created
39
 * for each element that has errors. In that case, the properties
40
 * {@link #getContainer() container}, {@link #getContainerIndex() containerIndex},
41
 * and {@link #getContainerKey() containerKey} provide additional context.
42
 *
43
 * @author Rossen Stoyanchev
44
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
45
 * @since 4.0
46
 */
47
public class ParameterErrors extends ParameterValidationResult implements Errors {
48

49
  private final Errors errors;
50

51
  /**
52
   * Create a {@code ParameterErrors}.
53
   */
54
  public ParameterErrors(MethodParameter parameter, @Nullable Object argument, Errors errors,
55
          @Nullable Object container, @Nullable Integer index, @Nullable Object key) {
56

57
    super(parameter, argument, errors.getAllErrors(),
10✔
58
            container, index, key, (error, sourceType) -> ((FieldError) error).unwrap(sourceType));
×
59

60
    this.errors = errors;
3✔
61
  }
1✔
62

63
  // Errors implementation
64

65
  @Override
66
  public String getObjectName() {
67
    return this.errors.getObjectName();
4✔
68
  }
69

70
  @Override
71
  public void setNestedPath(String nestedPath) {
72
    this.errors.setNestedPath(nestedPath);
×
73
  }
×
74

75
  @Override
76
  public String getNestedPath() {
77
    return this.errors.getNestedPath();
×
78
  }
79

80
  @Override
81
  public void pushNestedPath(String subPath) {
82
    this.errors.pushNestedPath(subPath);
×
83
  }
×
84

85
  @Override
86
  public void popNestedPath() throws IllegalStateException {
87
    this.errors.popNestedPath();
×
88
  }
×
89

90
  @Override
91
  public void reject(String errorCode) {
92
    this.errors.reject(errorCode);
×
93
  }
×
94

95
  @Override
96
  public void reject(String errorCode, String defaultMessage) {
97
    this.errors.reject(errorCode, defaultMessage);
×
98
  }
×
99

100
  @Override
101
  public void reject(String errorCode, Object @Nullable [] errorArgs, @Nullable String defaultMessage) {
102
    this.errors.reject(errorCode, errorArgs, defaultMessage);
×
103
  }
×
104

105
  @Override
106
  public void rejectValue(@Nullable String field, String errorCode) {
107
    this.errors.rejectValue(field, errorCode);
×
108
  }
×
109

110
  @Override
111
  public void rejectValue(@Nullable String field, String errorCode, String defaultMessage) {
112
    this.errors.rejectValue(field, errorCode, defaultMessage);
×
113
  }
×
114

115
  @Override
116
  public void rejectValue(@Nullable String field, String errorCode,
117
          Object @Nullable [] errorArgs, @Nullable String defaultMessage) {
118

119
    this.errors.rejectValue(field, errorCode, errorArgs, defaultMessage);
×
120
  }
×
121

122
  @Override
123
  public void addAllErrors(Errors errors) {
124
    this.errors.addAllErrors(errors);
×
125
  }
×
126

127
  @Override
128
  public boolean hasErrors() {
129
    return this.errors.hasErrors();
×
130
  }
131

132
  @Override
133
  public int getErrorCount() {
134
    return this.errors.getErrorCount();
4✔
135
  }
136

137
  @Override
138
  public List<ObjectError> getAllErrors() {
139
    return this.errors.getAllErrors();
×
140
  }
141

142
  @Override
143
  public boolean hasGlobalErrors() {
144
    return this.errors.hasGlobalErrors();
×
145
  }
146

147
  @Override
148
  public int getGlobalErrorCount() {
149
    return this.errors.getGlobalErrorCount();
×
150
  }
151

152
  @Override
153
  public List<ObjectError> getGlobalErrors() {
154
    return this.errors.getGlobalErrors();
×
155
  }
156

157
  @Nullable
158
  @Override
159
  public ObjectError getGlobalError() {
160
    return this.errors.getGlobalError();
×
161
  }
162

163
  @Override
164
  public boolean hasFieldErrors() {
165
    return this.errors.hasFieldErrors();
×
166
  }
167

168
  @Override
169
  public int getFieldErrorCount() {
170
    return this.errors.getFieldErrorCount();
×
171
  }
172

173
  @Override
174
  public List<FieldError> getFieldErrors() {
175
    return this.errors.getFieldErrors();
4✔
176
  }
177

178
  @Nullable
179
  @Override
180
  public FieldError getFieldError() {
181
    return this.errors.getFieldError();
4✔
182
  }
183

184
  @Override
185
  public boolean hasFieldErrors(String field) {
186
    return this.errors.hasFieldErrors(field);
×
187
  }
188

189
  @Override
190
  public int getFieldErrorCount(String field) {
191
    return this.errors.getFieldErrorCount(field);
×
192
  }
193

194
  @Override
195
  public List<FieldError> getFieldErrors(String field) {
196
    return this.errors.getFieldErrors(field);
×
197
  }
198

199
  @Nullable
200
  @Override
201
  public FieldError getFieldError(String field) {
202
    return this.errors.getFieldError(field);
×
203
  }
204

205
  @Nullable
206
  @Override
207
  public Object getFieldValue(String field) {
208
    return this.errors.getFieldError(field);
×
209
  }
210

211
  @Nullable
212
  @Override
213
  public Class<?> getFieldType(String field) {
214
    return this.errors.getFieldType(field);
×
215
  }
216

217
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc