Class StandardSerializers

java.lang.Object
com.exonum.binding.common.serialization.StandardSerializers

public final class StandardSerializers
extends Object
A collection of pre-defined serializers.
  • Method Details

    • bytes

      public static Serializer<byte[]> bytes()
      Returns a serializer of byte arrays, which passes them as is.
    • bool

      public static Serializer<Boolean> bool()
      Returns a serializer of booleans.
    • fixed32

      public static Serializer<Integer> fixed32()
      Returns a serializer of integers as four bytes in little-endian byte order. More efficient than uint32() if values are often greater than 2^28.
    • uint32

      public static Serializer<Integer> uint32()
      Returns a serializer of unsigned integers using variable length encoding. These more efficiently encodes values for the range [0; 2^21-1] than fixed32().
    • sint32

      public static Serializer<Integer> sint32()
      Returns a serializer of signed integers using variable length encoding. These more efficiently encodes values for the range [-2^20; 2^20-1] than fixed32(). If your values are strictly non-negative, consider using uint32().
    • fixed64

      public static Serializer<Long> fixed64()
      Returns a serializer of longs as eight bytes in little-endian byte order. More efficient than uint32() if values are often greater than 2^56.
    • uint64

      public static Serializer<Long> uint64()
      Returns a serializer of unsigned longs using variable length encoding. These more efficiently encodes values for the range [0; 2^49-1] than fixed64().
    • sint64

      public static Serializer<Long> sint64()
      Returns a serializer of signed longs using variable length encoding. These more efficiently encodes values for the range [-2^48; 2^48-1] than fixed64().
    • floats

      public static Serializer<Float> floats()
      Returns a serializer of floats in little-endian byte order.
    • doubles

      public static Serializer<Double> doubles()
      Returns a serializer of doubles in little-endian byte order.
    • string

      public static Serializer<String> 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

      public static Serializer<HashCode> hash()
      Returns a serializer of hash codes.
    • publicKey

      public static Serializer<PublicKey> publicKey()
      Returns a serializer of public keys.
    • privateKey

      public static Serializer<PrivateKey> privateKey()
      Returns a serializer of private keys.
    • transactionMessage

      public static Serializer<TransactionMessage> transactionMessage()
      Returns a serializer of transaction messages.
    • protobuf

      public static <MessageT extends com.google.protobuf.MessageLite> Serializer<MessageT> protobuf​(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:
      IllegalArgumentException - if MessageT does not contain the static factory method #parseFrom(byte[])