public class EncoderHttpMessageWriter<T> extends java.lang.Object implements HttpMessageWriter<T>
HttpMessageWriter
interface that delegates
to an Encoder
.Modifier and Type | Field and Description |
---|---|
private Encoder<T> |
encoder |
private java.util.List<MediaType> |
writableMediaTypes |
Constructor and Description |
---|
EncoderHttpMessageWriter(Encoder<T> encoder)
Create a
CodecHttpMessageConverter with the given Encoder . |
Modifier and Type | Method and Description |
---|---|
boolean |
canWrite(ResolvableType elementType,
MediaType mediaType)
Indicates whether the given class can be written by this converter.
|
protected MediaType |
getDefaultContentType(ResolvableType elementType)
Return the default content type for the given
ResolvableType . |
java.util.List<MediaType> |
getWritableMediaTypes()
Return the list of
MediaType objects that can be written by this converter. |
<any> |
write(<any> inputStream,
ResolvableType elementType,
MediaType mediaType,
ReactiveHttpOutputMessage outputMessage,
java.util.Map<java.lang.String,java.lang.Object> hints)
Write an given object to the given output message.
|
private final java.util.List<MediaType> writableMediaTypes
public boolean canWrite(ResolvableType elementType, MediaType mediaType)
HttpMessageWriter
canWrite
in interface HttpMessageWriter<T>
elementType
- the stream element type to test for writabilitymediaType
- the media type to write, can be null
if not specified.
Typically the value of an Accept
header.true
if writable; false
otherwisepublic java.util.List<MediaType> getWritableMediaTypes()
HttpMessageWriter
MediaType
objects that can be written by this converter.getWritableMediaTypes
in interface HttpMessageWriter<T>
public <any> write(<any> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, java.util.Map<java.lang.String,java.lang.Object> hints)
HttpMessageWriter
write
in interface HttpMessageWriter<T>
inputStream
- the input stream to writeelementType
- the stream element type to process. This type must have previously
been passed to the HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType)
canWrite} method of this interface, which must
have returned true
.mediaType
- the content type to use when writing, typically the value of an
Accept
header. May be null
to indicate that the default content
type of the converter must be used.outputMessage
- the message to write tohints
- additional information about how to writeMono
that indicates completion or errorprotected MediaType getDefaultContentType(ResolvableType elementType)
ResolvableType
.
Used when write(<any>, org.springframework.core.ResolvableType, org.springframework.http.MediaType, org.springframework.http.ReactiveHttpOutputMessage, java.util.Map<java.lang.String, java.lang.Object>)
is called without a concrete content type.
By default returns the first of encodableMimeTypes
that is concrete(MimeType.isConcrete()
), if any.
elementType
- the type of element for encodingnull