Class SimpleResponse.Builder
java.lang.Object
com.atlassian.oai.validator.model.SimpleResponse.Builder
- Enclosing class:
- SimpleResponse
A builder for constructing new
SimpleResponse instances.-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(int status) Creates aSimpleResponse.Builderwith the given HTTP status code. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleResponse.BuilderA convenience method for creating aSimpleResponse.Builderwith the HTTP status code 400.build()Builds aSimpleResponseout of this builder.static SimpleResponse.BuilderA convenience method for creating aSimpleResponse.Builderwith the HTTP status code 204.static SimpleResponse.BuildernotFound()A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 404.static SimpleResponse.Builderok()A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 200.static SimpleResponse.BuilderA convenience method for creating aSimpleResponse.Builderwith the HTTP status code 500.static SimpleResponse.Builderstatus(int status) Creates aSimpleResponse.Builderwith the given HTTP status code.static SimpleResponse.BuilderA convenience method for creating aSimpleResponse.Builderwith the HTTP status code 401.withBody(byte[] content) Adds a response body as byte array to this builder.withBody(InputStream content) Adds a response body asInputStreamto this builder.Adds a response body to this builder.withContentType(String contentType) Sets the content type header on this builder.withHeader(String name, String... values) Adds a response header to this builder.withHeader(String name, List<String> values) Adds a response header to this builder.
-
Constructor Details
-
Builder
public Builder(int status) Creates aSimpleResponse.Builderwith the given HTTP status code.- Parameters:
status- the responses HTTP status code
-
-
Method Details
-
status
Creates aSimpleResponse.Builderwith the given HTTP status code.- Parameters:
status- the responses HTTP status code- Returns:
- a prepared
SimpleResponse.Builder
-
ok
A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 200.- Returns:
- a prepared
SimpleResponse.Builder
-
noContent
A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 204.- Returns:
- a prepared
SimpleResponse.Builder
-
badRequest
A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 400.- Returns:
- a prepared
SimpleResponse.Builder
-
unauthorized
A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 401.- Returns:
- a prepared
SimpleResponse.Builder
-
notFound
A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 404.- Returns:
- a prepared
SimpleResponse.Builder
-
serverError
A convenience method for creating aSimpleResponse.Builderwith the HTTP status code 500.- Returns:
- a prepared
SimpleResponse.Builder
-
withBody
Adds a response body to this builder.The charset of the response body will be extracted from the content-type header during
build(). If no such header is specified UTF-8 is used.For better performance use
withBody(byte[])orwithBody(InputStream)if possible.- Parameters:
content- the response body- Returns:
- this builder
- See Also:
-
withBody
Adds a response body asStringand itsCharsetto this builder.For better performance use
withBody(byte[])orwithBody(InputStream)if possible.- Parameters:
content- the request bodycharset- theCharsetof the request body- Returns:
- this builder
-
withBody
Adds a response body as byte array to this builder.- Parameters:
content- the response body- Returns:
- this builder
-
withBody
Adds a response body asInputStreamto this builder.- Parameters:
content- the response body stream- Returns:
- this builder
-
withHeader
Adds a response header to this builder. If there was already a header with this name the values will be added.Headers are treated case insensitive.
- Parameters:
name- the header namevalues- the values for this header- Returns:
- this builder
-
withHeader
Adds a response header to this builder. If there was already a header with this name the values will be added.Headers are treated case insensitive.
- Parameters:
name- the header namevalues- the values for this header- Returns:
- this builder
-
withContentType
Sets the content type header on this builder.Equivalent to:
withHeader("Content-Type", contentType);- Parameters:
contentType- The content type to set- Returns:
- this builder
-
build
Builds aSimpleResponseout of this builder.- Returns:
- the build
SimpleResponse
-