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

TAKETODAY / today-infrastructure / 20632861616

01 Jan 2026 04:53AM UTC coverage: 84.18% (-0.3%) from 84.439%
20632861616

push

github

TAKETODAY
:sparkles: ApplicationType 支持通过 SPI 获取

55643 of 70608 branches covered (78.81%)

Branch coverage included in aggregate %.

130472 of 150485 relevant lines covered (86.7%)

3.73 hits per line

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

44.93
today-context/src/main/java/infra/validation/BindException.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;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.beans.PropertyEditor;
23
import java.util.List;
24
import java.util.Map;
25

26
import infra.beans.PropertyEditorRegistry;
27
import infra.lang.Assert;
28

29
/**
30
 * Thrown when binding errors are considered fatal. Implements the
31
 * {@link BindingResult} interface (and its super-interface {@link Errors})
32
 * to allow for the direct analysis of binding errors.
33
 *
34
 * <p>this is a special-purpose class. Normally,
35
 * application code will work with the {@link BindingResult} interface,
36
 * or with a {@link DataBinder} that in turn exposes a BindingResult via
37
 * {@link DataBinder#getBindingResult()}.
38
 *
39
 * @author Rod Johnson
40
 * @author Juergen Hoeller
41
 * @author Rob Harrop
42
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
43
 * @see BindingResult
44
 * @see DataBinder#getBindingResult()
45
 * @see DataBinder#close()
46
 * @since 4.0
47
 */
48
public class BindException extends Exception implements BindingResult {
49

50
  private final BindingResult bindingResult;
51

52
  /**
53
   * Create a new BindException instance for a BindingResult.
54
   *
55
   * @param bindingResult the BindingResult instance to wrap
56
   */
57
  public BindException(BindingResult bindingResult) {
2✔
58
    Assert.notNull(bindingResult, "BindingResult is required");
3✔
59
    this.bindingResult = bindingResult;
3✔
60
  }
1✔
61

62
  /**
63
   * Create a new BindException instance for a target bean.
64
   *
65
   * @param target the target bean to bind onto
66
   * @param objectName the name of the target object
67
   * @see BeanPropertyBindingResult
68
   */
69
  public BindException(Object target, String objectName) {
2✔
70
    Assert.notNull(target, "Target object is required");
3✔
71
    this.bindingResult = new BeanPropertyBindingResult(target, objectName);
7✔
72
  }
1✔
73

74
  /**
75
   * Return the BindingResult that this BindException wraps.
76
   */
77
  public final BindingResult getBindingResult() {
78
    return this.bindingResult;
3✔
79
  }
80

81
  @Override
82
  public String getObjectName() {
83
    return this.bindingResult.getObjectName();
4✔
84
  }
85

86
  @Override
87
  public void setNestedPath(String nestedPath) {
88
    this.bindingResult.setNestedPath(nestedPath);
×
89
  }
×
90

91
  @Override
92
  public String getNestedPath() {
93
    return this.bindingResult.getNestedPath();
×
94
  }
95

96
  @Override
97
  public void pushNestedPath(String subPath) {
98
    this.bindingResult.pushNestedPath(subPath);
×
99
  }
×
100

101
  @Override
102
  public void popNestedPath() throws IllegalStateException {
103
    this.bindingResult.popNestedPath();
×
104
  }
×
105

106
  @Override
107
  public void reject(String errorCode) {
108
    this.bindingResult.reject(errorCode);
4✔
109
  }
1✔
110

111
  @Override
112
  public void reject(String errorCode, String defaultMessage) {
113
    this.bindingResult.reject(errorCode, defaultMessage);
5✔
114
  }
1✔
115

116
  @Override
117
  public void reject(String errorCode, Object @Nullable [] errorArgs, @Nullable String defaultMessage) {
118
    this.bindingResult.reject(errorCode, errorArgs, defaultMessage);
×
119
  }
×
120

121
  @Override
122
  public void rejectValue(@Nullable String field, String errorCode) {
123
    this.bindingResult.rejectValue(field, errorCode);
5✔
124
  }
1✔
125

126
  @Override
127
  public void rejectValue(@Nullable String field, String errorCode, String defaultMessage) {
128
    this.bindingResult.rejectValue(field, errorCode, defaultMessage);
6✔
129
  }
1✔
130

131
  @Override
132
  public void rejectValue(@Nullable String field, String errorCode, Object @Nullable [] errorArgs, @Nullable String defaultMessage) {
133
    this.bindingResult.rejectValue(field, errorCode, errorArgs, defaultMessage);
×
134
  }
×
135

136
  @Override
137
  public void addAllErrors(Errors errors) {
138
    this.bindingResult.addAllErrors(errors);
×
139
  }
×
140

141
  @Override
142
  public boolean hasErrors() {
143
    return this.bindingResult.hasErrors();
×
144
  }
145

146
  @Override
147
  public int getErrorCount() {
148
    return this.bindingResult.getErrorCount();
4✔
149
  }
150

151
  @Override
152
  public List<ObjectError> getAllErrors() {
153
    return this.bindingResult.getAllErrors();
4✔
154
  }
155

156
  @Override
157
  public boolean hasGlobalErrors() {
158
    return this.bindingResult.hasGlobalErrors();
4✔
159
  }
160

161
  @Override
162
  public int getGlobalErrorCount() {
163
    return this.bindingResult.getGlobalErrorCount();
×
164
  }
165

166
  @Override
167
  public List<ObjectError> getGlobalErrors() {
168
    return this.bindingResult.getGlobalErrors();
×
169
  }
170

171
  @Override
172
  @Nullable
173
  public ObjectError getGlobalError() {
174
    return this.bindingResult.getGlobalError();
4✔
175
  }
176

177
  @Override
178
  public boolean hasFieldErrors() {
179
    return this.bindingResult.hasFieldErrors();
×
180
  }
181

182
  @Override
183
  public int getFieldErrorCount() {
184
    return this.bindingResult.getFieldErrorCount();
×
185
  }
186

187
  @Override
188
  public List<FieldError> getFieldErrors() {
189
    return this.bindingResult.getFieldErrors();
×
190
  }
191

192
  @Override
193
  @Nullable
194
  public FieldError getFieldError() {
195
    return this.bindingResult.getFieldError();
×
196
  }
197

198
  @Override
199
  public boolean hasFieldErrors(String field) {
200
    return this.bindingResult.hasFieldErrors(field);
5✔
201
  }
202

203
  @Override
204
  public int getFieldErrorCount(String field) {
205
    return this.bindingResult.getFieldErrorCount(field);
×
206
  }
207

208
  @Override
209
  public List<FieldError> getFieldErrors(String field) {
210
    return this.bindingResult.getFieldErrors(field);
×
211
  }
212

213
  @Override
214
  @Nullable
215
  public FieldError getFieldError(String field) {
216
    return this.bindingResult.getFieldError(field);
5✔
217
  }
218

219
  @Override
220
  @Nullable
221
  public Object getFieldValue(String field) {
222
    return this.bindingResult.getFieldValue(field);
5✔
223
  }
224

225
  @Override
226
  @Nullable
227
  public Class<?> getFieldType(String field) {
228
    return this.bindingResult.getFieldType(field);
×
229
  }
230

231
  @Override
232
  @Nullable
233
  public Object getTarget() {
234
    return this.bindingResult.getTarget();
4✔
235
  }
236

237
  @Override
238
  public Map<String, Object> getModel() {
239
    return this.bindingResult.getModel();
×
240
  }
241

242
  @Override
243
  @Nullable
244
  public Object getRawFieldValue(String field) {
245
    return this.bindingResult.getRawFieldValue(field);
×
246
  }
247

248
  @Override
249
  @SuppressWarnings("rawtypes")
250
  @Nullable
251
  public PropertyEditor findEditor(@Nullable String field, @Nullable Class valueType) {
252
    return this.bindingResult.findEditor(field, valueType);
×
253
  }
254

255
  @Override
256
  @Nullable
257
  public PropertyEditorRegistry getPropertyEditorRegistry() {
258
    return this.bindingResult.getPropertyEditorRegistry();
×
259
  }
260

261
  @Override
262
  public String[] resolveMessageCodes(String errorCode) {
263
    return this.bindingResult.resolveMessageCodes(errorCode);
×
264
  }
265

266
  @Override
267
  public String[] resolveMessageCodes(String errorCode, String field) {
268
    return this.bindingResult.resolveMessageCodes(errorCode, field);
×
269
  }
270

271
  @Override
272
  public void addError(ObjectError error) {
273
    this.bindingResult.addError(error);
4✔
274
  }
1✔
275

276
  @Override
277
  public void recordFieldValue(String field, Class<?> type, @Nullable Object value) {
278
    this.bindingResult.recordFieldValue(field, type, value);
×
279
  }
×
280

281
  @Override
282
  public void recordSuppressedField(String field) {
283
    this.bindingResult.recordSuppressedField(field);
×
284
  }
×
285

286
  @Override
287
  public String[] getSuppressedFields() {
288
    return this.bindingResult.getSuppressedFields();
×
289
  }
290

291
  /**
292
   * Returns diagnostic information about the errors held in this object.
293
   */
294
  @Override
295
  public String getMessage() {
296
    return this.bindingResult.toString();
×
297
  }
298

299
  @Override
300
  public boolean equals(@Nullable Object other) {
301
    return (this == other || this.bindingResult.equals(other));
11!
302
  }
303

304
  @Override
305
  public int hashCode() {
306
    return this.bindingResult.hashCode();
×
307
  }
308

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

© 2026 Coveralls, Inc