@@ -64,6 +64,9 @@ default HttpHeaders getHeaders() {
64
64
*/
65
65
ProblemDetail getBody ();
66
66
67
+
68
+ // MessageSource codes and arguments
69
+
67
70
/**
68
71
* Return a code to use to resolve the problem "type" for this exception
69
72
* through a {@link MessageSource}. The type resolved through the
@@ -76,6 +79,15 @@ default String getTypeMessageCode() {
76
79
return getDefaultTypeMessageCode (getClass ());
77
80
}
78
81
82
+ /**
83
+ * Return a code to use to resolve the problem "title" for this exception
84
+ * through a {@link MessageSource}.
85
+ * <p>By default this is initialized via {@link #getDefaultTitleMessageCode(Class)}.
86
+ */
87
+ default String getTitleMessageCode () {
88
+ return getDefaultTitleMessageCode (getClass ());
89
+ }
90
+
79
91
/**
80
92
* Return a code to use to resolve the problem "detail" for this exception
81
93
* through a {@link MessageSource}.
@@ -111,15 +123,6 @@ default Object[] getDetailMessageArguments(MessageSource messageSource, Locale l
111
123
return getDetailMessageArguments ();
112
124
}
113
125
114
- /**
115
- * Return a code to use to resolve the problem "title" for this exception
116
- * through a {@link MessageSource}.
117
- * <p>By default this is initialized via {@link #getDefaultTitleMessageCode(Class)}.
118
- */
119
- default String getTitleMessageCode () {
120
- return getDefaultTitleMessageCode (getClass ());
121
- }
122
-
123
126
/**
124
127
* Use the given {@link MessageSource} to resolve the
125
128
* {@link #getTypeMessageCode() type}, {@link #getTitleMessageCode() title},
@@ -159,6 +162,16 @@ static String getDefaultTypeMessageCode(Class<?> exceptionType) {
159
162
return "problemDetail.type." + exceptionType .getName ();
160
163
}
161
164
165
+ /**
166
+ * Build a message code for the "title" field, for the given exception type.
167
+ * @param exceptionType the exception type associated with the problem
168
+ * @return {@code "problemDetail.title."} followed by the fully qualified
169
+ * {@link Class#getName() class name}
170
+ */
171
+ static String getDefaultTitleMessageCode (Class <?> exceptionType ) {
172
+ return "problemDetail.title." + exceptionType .getName ();
173
+ }
174
+
162
175
/**
163
176
* Build a message code for the "detail" field, for the given exception type.
164
177
* @param exceptionType the exception type associated with the problem
@@ -171,15 +184,6 @@ static String getDefaultDetailMessageCode(Class<?> exceptionType, @Nullable Stri
171
184
return "problemDetail." + exceptionType .getName () + (suffix != null ? "." + suffix : "" );
172
185
}
173
186
174
- /**
175
- * Build a message code for the "title" field, for the given exception type.
176
- * @param exceptionType the exception type associated with the problem
177
- * @return {@code "problemDetail.title."} followed by the fully qualified
178
- * {@link Class#getName() class name}
179
- */
180
- static String getDefaultTitleMessageCode (Class <?> exceptionType ) {
181
- return "problemDetail.title." + exceptionType .getName ();
182
- }
183
187
184
188
/**
185
189
* Static factory method to build an instance via
@@ -230,61 +234,61 @@ interface Builder {
230
234
Builder headers (Consumer <HttpHeaders > headersConsumer );
231
235
232
236
/**
233
- * Set the underlying {@link ProblemDetail#setDetail(String) detail} .
237
+ * Set the underlying {@link ProblemDetail#setType(URI) type} field .
234
238
* @return the same builder instance
235
239
*/
236
- Builder detail ( String detail );
240
+ Builder type ( URI type );
237
241
238
242
/**
239
- * Customize the {@link MessageSource} code for looking up the value for
240
- * the underlying {@link #detail(String) detail}.
241
- * <p>By default, this is set to
242
- * {@link ErrorResponse#getDefaultDetailMessageCode(Class, String)} with the
243
- * associated Exception type.
244
- * @param messageCode the message code to use
243
+ * Set the underlying {@link ProblemDetail#setTitle(String) title} field.
245
244
* @return the same builder instance
246
- * @see ErrorResponse#getDetailMessageCode()
247
245
*/
248
- Builder detailMessageCode ( String messageCode );
246
+ Builder title ( @ Nullable String title );
249
247
250
248
/**
251
- * Set the arguments to provide to the {@link MessageSource} lookup for
252
- * {@link #detailMessageCode(String)}.
253
- * @param messageArguments the arguments to provide
249
+ * Customize the {@link MessageSource} code for looking up the value for
250
+ * the underlying {@link ProblemDetail#setTitle(String) title}.
251
+ * <p>By default, set via
252
+ * {@link ErrorResponse#getDefaultTitleMessageCode(Class)} with the
253
+ * associated Exception type.
254
+ * @param messageCode the message code to use
254
255
* @return the same builder instance
255
- * @see ErrorResponse#getDetailMessageArguments ()
256
+ * @see ErrorResponse#getTitleMessageCode ()
256
257
*/
257
- Builder detailMessageArguments ( Object ... messageArguments );
258
+ Builder titleMessageCode ( String messageCode );
258
259
259
260
/**
260
- * Set the underlying {@link ProblemDetail#setType (URI) type } field.
261
+ * Set the underlying {@link ProblemDetail#setInstance (URI) instance } field.
261
262
* @return the same builder instance
262
263
*/
263
- Builder type ( URI type );
264
+ Builder instance ( @ Nullable URI instance );
264
265
265
266
/**
266
- * Set the underlying {@link ProblemDetail#setTitle (String) title} field .
267
+ * Set the underlying {@link ProblemDetail#setDetail (String) detail} .
267
268
* @return the same builder instance
268
269
*/
269
- Builder title ( @ Nullable String title );
270
+ Builder detail ( String detail );
270
271
271
272
/**
272
273
* Customize the {@link MessageSource} code for looking up the value for
273
- * the underlying {@link ProblemDetail#setTitle (String) title }.
274
- * <p>By default, set via
275
- * {@link ErrorResponse#getDefaultTitleMessageCode (Class)} with the
274
+ * the underlying {@link #detail (String) detail }.
275
+ * <p>By default, this is set to
276
+ * {@link ErrorResponse#getDefaultDetailMessageCode (Class, String )} with the
276
277
* associated Exception type.
277
278
* @param messageCode the message code to use
278
279
* @return the same builder instance
279
- * @see ErrorResponse#getTitleMessageCode ()
280
+ * @see ErrorResponse#getDetailMessageCode ()
280
281
*/
281
- Builder titleMessageCode (String messageCode );
282
+ Builder detailMessageCode (String messageCode );
282
283
283
284
/**
284
- * Set the underlying {@link ProblemDetail#setInstance(URI) instance} field.
285
+ * Set the arguments to provide to the {@link MessageSource} lookup for
286
+ * {@link #detailMessageCode(String)}.
287
+ * @param messageArguments the arguments to provide
285
288
* @return the same builder instance
289
+ * @see ErrorResponse#getDetailMessageArguments()
286
290
*/
287
- Builder instance ( @ Nullable URI instance );
291
+ Builder detailMessageArguments ( Object ... messageArguments );
288
292
289
293
/**
290
294
* Set a "dynamic" {@link ProblemDetail#setProperty(String, Object)
0 commit comments