S
- the least-specific type this codec will accept when encodingT
- the type of instances this codec will build when decodingM
- the generated protobuf message classpublic interface PersistCodec<S,T extends S,M extends com.google.protobuf.Message>
Modifier and Type | Method and Description |
---|---|
T |
fromByteArray(byte[] data)
Given an encoded representation generated by
toByteArray(S) ,
decode and build an instance of T (always exactly this type,
regardless of the actual type previously passed to toByteArray(S) ) |
T |
fromMessage(M message)
Given a protobuf message returned from
toMessage(S) ,
decode and build an instance of T. |
byte[] |
toByteArray(S data)
Given an instance of S, encode it to a byte-array representation using
the encoding rules associated with this codec.
|
M |
toMessage(S data)
Given an instance of S, encode it as a protobuf message.
|
byte[] toByteArray(S data) throws EncodeException
data
- the instance to encodenull
if data
was null
EncodeException
- if the data could not be encodedT fromByteArray(byte[] data) throws DecodeException
toByteArray(S)
,
decode and build an instance of T (always exactly this type,
regardless of the actual type previously passed to toByteArray(S)
)data
- the encoded form to decodenull
if data
was null
DecodeException
- if the data could not be decodedM toMessage(S data)
data
- the data object to encodenull
if data
was null
EncodeException
- if the data could not be encodedT fromMessage(M message)
toMessage(S)
,
decode and build an instance of T.message
- the message instance to decode, or null
if message
was null
DecodeException
- if the message could not be decoded