Package io.grpc.protobuf.lite
Class ProtoLiteUtils.MessageMarshaller<T extends com.google.protobuf.MessageLite>
- java.lang.Object
-
- io.grpc.protobuf.lite.ProtoLiteUtils.MessageMarshaller<T>
-
- All Implemented Interfaces:
MethodDescriptor.Marshaller<T>,MethodDescriptor.PrototypeMarshaller<T>,MethodDescriptor.ReflectableMarshaller<T>
- Enclosing class:
- ProtoLiteUtils
private static final class ProtoLiteUtils.MessageMarshaller<T extends com.google.protobuf.MessageLite> extends java.lang.Object implements MethodDescriptor.PrototypeMarshaller<T>
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.lang.ref.Reference<byte[]>>bufsprivate TdefaultInstanceprivate com.google.protobuf.Parser<T>parserprivate intrecursionLimit
-
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 theClassthat this marshaller serializes and deserializes.TgetMessagePrototype()An instance of the expected message type, typically used as a schema and helper for producing other message instances.Tparse(java.io.InputStream stream)Given anInputStreamparse it into an instance of the declared type so that it can be passed to application code.private TparseFrom(com.google.protobuf.CodedInputStream stream)java.io.InputStreamstream(T value)Given a message, produce anInputStreamfor it so that it can be written to the wire.
-
-
-
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.ReflectableMarshallerReturns theClassthat this marshaller serializes and deserializes. If inheritance is allowed, this is the base class or interface for all supported classes.- Specified by:
getMessageClassin interfaceMethodDescriptor.ReflectableMarshaller<T extends com.google.protobuf.MessageLite>- Returns:
- non-
nullbase class for all objects produced and consumed by this marshaller
-
getMessagePrototype
public T getMessagePrototype()
Description copied from interface:MethodDescriptor.PrototypeMarshallerAn instance of the expected message type, typically used as a schema and helper for producing other message instances. Thenullvalue may be a special value for the marshaller (like the equivalent ofVoid), so it is a valid return value.nulldoes 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:
getMessagePrototypein interfaceMethodDescriptor.PrototypeMarshaller<T extends com.google.protobuf.MessageLite>
-
stream
public java.io.InputStream stream(T value)
Description copied from interface:MethodDescriptor.MarshallerGiven a message, produce anInputStreamfor it so that it can be written to the wire. Where possible implementations should produce streams that areKnownLengthto improve transport efficiency.- Specified by:
streamin interfaceMethodDescriptor.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.MarshallerGiven anInputStreamparse it into an instance of the declared type so that it can be passed to application code.- Specified by:
parsein interfaceMethodDescriptor.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
-
-