Interface ErrorResponse.Builder
- Enclosing interface:
ErrorResponse
public static interface ErrorResponse.Builder
Builder for an
ErrorResponse.- since:
- 6.0
- Author:
- Rossen stoyanchev
-
Method summary
Modifier and TypeMethodDescriptionbuild()Build theErrorResponseinstance.default ErrorResponsebuild(@Nullable Messagesource messagesource, Locale locale) Build theErrorResponseinstance and also resolve the "detail" and "title" through the givenMessagesource.set the underlyingdetail.detailMessageArguments(Object... messageArguments) set the arguments to provide to theMessagesourcelookup fordetailMessageCode(string).detailMessageCode(string messageCode) Customize theMessagesourcecode to use to resolve the value for thedetail(string).Add the given header value(s) under the given name.headers(Consumer<HttpHeaders> headersConsumer) Manipulate this response's headers with the given consumer.set the underlyinginstancefield.set a "dynamic"propertyon the underlyingProblemDetail.set the underlyingtitlefield.titleMessageCode(string messageCode) Customize theMessagesourcecode to use to resolve the value forProblemDetail.setTitle(string).set the underlyingtypefield.typeMessageCode(string messageCode) Customize theMessagesourcecode to use to resolve the value forProblemDetail.setType(URI).
-
Method Details
-
header
Add the given header value(s) under the given name.- Parameters:
headerName- the header nameheaderValues- the header value(s)- Returns:
- the same builder instance
- see Also:
-
headers
Manipulate this response's headers with the given consumer. This is useful to overwrite or remove existing values, or use any otherHttpHeadersmethods.- Parameters:
headersConsumer- a function that consumes theHttpHeaders- Returns:
- the same builder instance
-
type
set the underlyingtypefield.- Returns:
- the same builder instance
-
typeMessageCode
Customize theMessagesourcecode to use to resolve the value forProblemDetail.setType(URI).By default, set from
ErrorResponse.getDefaultTypeMessageCode(Class).- Parameters:
messageCode- the message code to use- Returns:
- the same builder instance
- since:
- 6.1
- see Also:
-
title
set the underlyingtitlefield.- Returns:
- the same builder instance
-
titleMessageCode
Customize theMessagesourcecode to use to resolve the value forProblemDetail.setTitle(string).By default, set from
ErrorResponse.getDefaultTitleMessageCode(Class).- Parameters:
messageCode- the message code to use- Returns:
- the same builder instance
- see Also:
-
instance
set the underlyinginstancefield.- Returns:
- the same builder instance
-
detail
set the underlyingdetail.- Returns:
- the same builder instance
-
detailMessageCode
Customize theMessagesourcecode to use to resolve the value for thedetail(string).By default, set from
ErrorResponse.getDefaultDetailMessageCode(Class, string).- Parameters:
messageCode- the message code to use- Returns:
- the same builder instance
- see Also:
-
detailMessageArguments
set the arguments to provide to theMessagesourcelookup fordetailMessageCode(string).- Parameters:
messageArguments- the arguments to provide- Returns:
- the same builder instance
- see Also:
-
property
set a "dynamic"propertyon the underlyingProblemDetail.- Returns:
- the same builder instance
-
build
ErrorResponse build()Build theErrorResponseinstance. -
build
default ErrorResponse build(@Nullable Messagesource messagesource, Locale locale) Build theErrorResponseinstance and also resolve the "detail" and "title" through the givenMessagesource. Effectively a shortcut for callingbuild()and thenErrorResponse.updateAndGetBody(Messagesource, Locale).- since:
- 6.0.3
-