Class ProtoLiteUtils.MessageMarshaller<T extends com.google.protobuf.MessageLite>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.ThreadLocal<java.lang.ref.Reference<byte[]>> bufs  
      private T defaultInstance  
      private com.google.protobuf.Parser<T> parser  
      private int recursionLimit  
    • Constructor Summary

      Constructors 
      Constructor Description
      MessageMarshaller​(T defaultInstance, int recursionLimit)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Class<T> getMessageClass()
      Returns the Class that this marshaller serializes and deserializes.
      T getMessagePrototype()
      An instance of the expected message type, typically used as a schema and helper for producing other message instances.
      T parse​(java.io.InputStream stream)
      Given an InputStream parse it into an instance of the declared type so that it can be passed to application code.
      private T parseFrom​(com.google.protobuf.CodedInputStream stream)  
      java.io.InputStream stream​(T value)
      Given a message, produce an InputStream for it so that it can be written to the wire.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • bufs

        private static final java.lang.ThreadLocal<java.lang.ref.Reference<byte[]>> bufs
      • parser

        private final com.google.protobuf.Parser<T extends com.google.protobuf.MessageLite> parser
      • defaultInstance

        private final T extends com.google.protobuf.MessageLite defaultInstance
      • recursionLimit

        private final int recursionLimit
    • Constructor Detail

      • MessageMarshaller

        MessageMarshaller​(T defaultInstance,
                          int recursionLimit)
    • Method Detail

      • getMessageClass

        public java.lang.Class<T> getMessageClass()
        Description copied from interface: MethodDescriptor.ReflectableMarshaller
        Returns the Class that this marshaller serializes and deserializes. If inheritance is allowed, this is the base class or interface for all supported classes.
        Specified by:
        getMessageClass in interface MethodDescriptor.ReflectableMarshaller<T extends com.google.protobuf.MessageLite>
        Returns:
        non-null base class for all objects produced and consumed by this marshaller
      • getMessagePrototype

        public T getMessagePrototype()
        Description copied from interface: MethodDescriptor.PrototypeMarshaller
        An instance of the expected message type, typically used as a schema and helper for producing other message instances. The null value may be a special value for the marshaller (like the equivalent of Void), so it is a valid return value. null does not mean "unsupported" or "unknown".

        It is generally expected this would return the same instance each invocation, but it is not a requirement.

        Specified by:
        getMessagePrototype in interface MethodDescriptor.PrototypeMarshaller<T extends com.google.protobuf.MessageLite>
      • stream

        public java.io.InputStream stream​(T value)
        Description copied from interface: MethodDescriptor.Marshaller
        Given a message, produce an InputStream for it so that it can be written to the wire. Where possible implementations should produce streams that are KnownLength to improve transport efficiency.
        Specified by:
        stream in interface MethodDescriptor.Marshaller<T extends com.google.protobuf.MessageLite>
        Parameters:
        value - to serialize.
        Returns:
        serialized value as stream of bytes.
      • parse

        public T parse​(java.io.InputStream stream)
        Description copied from interface: MethodDescriptor.Marshaller
        Given an InputStream parse it into an instance of the declared type so that it can be passed to application code.
        Specified by:
        parse in interface MethodDescriptor.Marshaller<T extends com.google.protobuf.MessageLite>
        Parameters:
        stream - of bytes for serialized value
        Returns:
        parsed value
      • parseFrom

        private T parseFrom​(com.google.protobuf.CodedInputStream stream)
                     throws com.google.protobuf.InvalidProtocolBufferException
        Throws:
        com.google.protobuf.InvalidProtocolBufferException