public abstract class PayloadUtils extends Object
Payload
from DataBuffer
s
and vice versa.Constructor and Description |
---|
PayloadUtils() |
Modifier and Type | Method and Description |
---|---|
static io.rsocket.Payload |
createPayload(DataBuffer data)
Create a Payload with data only.
|
static io.rsocket.Payload |
createPayload(DataBuffer data,
DataBuffer metadata)
Create a Payload from the given metadata and data.
|
static DataBuffer |
retainDataAndReleasePayload(io.rsocket.Payload payload,
DataBufferFactory bufferFactory)
Use this method to slice, retain and wrap the data portion of the
Payload , and also to release the Payload . |
public static DataBuffer retainDataAndReleasePayload(io.rsocket.Payload payload, DataBufferFactory bufferFactory)
Payload
, and also to release the Payload
. This assumes
the Payload metadata has been read by now and ensures downstream code
need only be aware of DataBuffer
s.payload
- the payload to processbufferFactory
- the DataBufferFactory to wrap withDataBuffer
instancepublic static io.rsocket.Payload createPayload(DataBuffer data, DataBuffer metadata)
If at least one is NettyDataBuffer
then ByteBufPayload
is created with either obtaining the underlying native ByteBuf
or using Unpooled.wrappedBuffer(ByteBuffer...)
if necessary.
Otherwise, if both are DefaultDataBuffer
, then
DefaultPayload
is created.
data
- the data part for the payloadmetadata
- the metadata part for the payloadpublic static io.rsocket.Payload createPayload(DataBuffer data)
ByteBufPayload
if the input is NettyDataBuffer
or
otherwise it is DefaultPayload
.data
- the data part for the payload