Add simple BINARY_BYTE_MARSHALLER

This commit is contained in:
Lukasz Strzalkowski 2016-02-17 15:14:29 +01:00 committed by Eric Anderson
parent ab1bc05f07
commit af6a2650af
1 changed files with 23 additions and 0 deletions

View File

@ -69,6 +69,29 @@ public final class Metadata {
*/
public static final String BINARY_HEADER_SUFFIX = "-bin";
/**
* Simple metadata marshaller that encodes bytes as is.
*
* <p>This should be used when raw bytes are favored over un-serialized version of object. Can be
* helpful in situations where more processing to bytes is needed on application side, avoids
* double encoding/decoding.</p>
*
* <p>Both #toBytes and #parseBytes methods return copy of the byte array</p>
*/
public static final BinaryMarshaller<byte[]> BINARY_BYTE_MARSHALLER =
new BinaryMarshaller<byte[]>() {
@Override
public byte[] toBytes(byte[] value) {
return value.clone();
}
@Override
public byte[] parseBytes(byte[] serialized) {
return serialized.clone();
}
};
/**
* Simple metadata marshaller that encodes strings as is.
*