Class StandardSerializers
java.lang.Object
com.exonum.binding.common.serialization.StandardSerializers
public final class StandardSerializers
extends java.lang.Object
A collection of pre-defined serializers.
-
Method Summary
Modifier and Type Method Description static Serializer<java.lang.Boolean>
bool()
Returns a serializer of booleans.static Serializer<byte[]>
bytes()
Returns a serializer of byte arrays, which passes them as is.static Serializer<java.lang.Double>
doubles()
Returns a serializer of doubles in little-endian byte order.static Serializer<java.lang.Integer>
fixed32()
Returns a serializer of integers as four bytes in little-endian byte order.static Serializer<java.lang.Long>
fixed64()
Returns a serializer of longs as eight bytes in little-endian byte order.static Serializer<java.lang.Float>
floats()
Returns a serializer of floats in little-endian byte order.static Serializer<HashCode>
hash()
Returns a serializer of hash codes.static Serializer<PrivateKey>
privateKey()
Returns a serializer of private keys.static <MessageT extends com.google.protobuf.MessageLite>
Serializer<MessageT>protobuf(java.lang.Class<MessageT> messageType)
Returns a serializer for the given protocol buffer message type.static Serializer<PublicKey>
publicKey()
Returns a serializer of public keys.static Serializer<java.lang.Integer>
sint32()
Returns a serializer of signed integers using variable length encoding.static Serializer<java.lang.Long>
sint64()
Returns a serializer of signed longs using variable length encoding.static Serializer<java.lang.String>
string()
Returns a serializer of strings in UTF-8.static Serializer<TransactionMessage>
transactionMessage()
Returns a serializer of transaction messages.static Serializer<java.lang.Integer>
uint32()
Returns a serializer of unsigned integers using variable length encoding.static Serializer<java.lang.Long>
uint64()
Returns a serializer of unsigned longs using variable length encoding.
-
Method Details
-
bytes
Returns a serializer of byte arrays, which passes them as is. -
bool
Returns a serializer of booleans. -
fixed32
Returns a serializer of integers as four bytes in little-endian byte order. More efficient thanuint32()
if values are often greater than2^28
. -
uint32
Returns a serializer of unsigned integers using variable length encoding. These more efficiently encodes values for the range[0; 2^21-1]
thanfixed32()
. -
sint32
-
fixed64
Returns a serializer of longs as eight bytes in little-endian byte order. More efficient thanuint32()
if values are often greater than2^56
. -
uint64
Returns a serializer of unsigned longs using variable length encoding. These more efficiently encodes values for the range[0; 2^49-1]
thanfixed64()
. -
sint64
Returns a serializer of signed longs using variable length encoding. These more efficiently encodes values for the range[-2^48; 2^48-1]
thanfixed64()
. -
floats
Returns a serializer of floats in little-endian byte order. -
doubles
Returns a serializer of doubles in little-endian byte order. -
string
Returns a serializer of strings in UTF-8. Deserializer will reject malformed input, but replace the characters not representable in UTF-16 with the default replacement character. -
hash
Returns a serializer of hash codes. -
publicKey
Returns a serializer of public keys. -
privateKey
Returns a serializer of private keys. -
transactionMessage
Returns a serializer of transaction messages. -
protobuf
public static <MessageT extends com.google.protobuf.MessageLite> Serializer<MessageT> protobuf(java.lang.Class<MessageT> messageType)Returns a serializer for the given protocol buffer message type. The returned serializer uses deterministic serialization mode.- Type Parameters:
MessageT
- the type of a message; must have a public static#parseFrom(byte[])
method — as any auto-generated protobuf message does- Parameters:
messageType
- the class of a protobuf message- Throws:
java.lang.IllegalArgumentException
- ifMessageT
does not contain the static factory method#parseFrom(byte[])
-