- Type Parameters:
T
- type of entity
public interface EntityWriter<T>
Writer of entity into bytes.
-
Method Summary
Modifier and TypeMethodDescriptiondefault InstanceWriter
instanceWriter
(GenericType<T> type, T object, Headers requestHeaders, WritableHeaders<?> responseHeaders) Server response entity instance writer.default InstanceWriter
instanceWriter
(GenericType<T> type, T object, WritableHeaders<?> requestHeaders) Client request entity instance writer.default boolean
Whether this entity writer can provide more information about each entity instance, such as content length.void
write
(GenericType<T> type, T object, OutputStream outputStream, Headers requestHeaders, WritableHeaders<?> responseHeaders) Write server response entity and close the stream.void
write
(GenericType<T> type, T object, OutputStream outputStream, WritableHeaders<?> headers) Write client request entity and close the stream.
-
Method Details
-
supportsInstanceWriter
default boolean supportsInstanceWriter()Whether this entity writer can provide more information about each entity instance, such as content length.- Returns:
- whether
instanceWriter
methods are supported; If not one of thewrite
methods would be called instead
-
instanceWriter
default InstanceWriter instanceWriter(GenericType<T> type, T object, WritableHeaders<?> requestHeaders) Client request entity instance writer.- Parameters:
type
- type of entityobject
- object to writerequestHeaders
- request headers- Returns:
- instance writer ready to write the provided entity
-
instanceWriter
default InstanceWriter instanceWriter(GenericType<T> type, T object, Headers requestHeaders, WritableHeaders<?> responseHeaders) Server response entity instance writer.- Parameters:
type
- type of entityobject
- object to writerequestHeaders
- request headersresponseHeaders
- response headers- Returns:
- instance writer ready to write the provided entity
-
write
void write(GenericType<T> type, T object, OutputStream outputStream, Headers requestHeaders, WritableHeaders<?> responseHeaders) Write server response entity and close the stream.- Parameters:
type
- type of entityobject
- object to writeoutputStream
- output stream to write torequestHeaders
- request headersresponseHeaders
- response headers
-
write
Write client request entity and close the stream.- Parameters:
type
- type of entityobject
- object to writeoutputStream
- output stream to write toheaders
- request headers
-