public static class StreamResource.Builder extends Object
StreamResource
objects.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
StreamResource |
build()
Create a new
StreamResource using values in this builder. |
StreamResource.Builder |
cached()
Specifies that this resource is intended to be cached.
|
StreamResource.Builder |
contents(Object... contents)
Specifies the contents for this resource.
|
StreamResource.Builder |
header(String name,
Object value)
Specifies an HTTP response header value.
|
StreamResource.Builder |
headers(Map<String,Object> headers)
Specifies HTTP response header values.
|
StreamResource.Builder |
mediaType(MediaType mediaType)
Specifies the resource media type string.
|
StreamResource.Builder |
mediaType(String mediaType)
Specifies the resource media type string.
|
public Builder()
public StreamResource.Builder mediaType(String mediaType)
mediaType
- The resource media type string.public StreamResource.Builder mediaType(MediaType mediaType)
mediaType
- The resource media type string.public StreamResource.Builder contents(Object... contents)
This method can be called multiple times to add more content.
contents
- The resource contents.
byte []
public StreamResource.Builder header(String name, Object value)
name
- The HTTP header name.value
- The HTTP header value.
Object.toString()
.public StreamResource.Builder headers(Map<String,Object> headers)
headers
- The HTTP headers.
Object.toString()
.public StreamResource.Builder cached()
This will trigger the contents to be loaded into a byte array for fast serializing.
public StreamResource build() throws IOException
StreamResource
using values in this builder.StreamResource
object.IOException
- Thrown by underlying stream.Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.