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 Object
implements MethodDescriptor.PrototypeMarshaller<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ThreadLocal
<Reference<byte[]>> private final T
private final com.google.protobuf.Parser
<T> private final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns theClass
that this marshaller serializes and deserializes.An instance of the expected message type, typically used as a schema and helper for producing other message instances.parse
(InputStream stream) Given anInputStream
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) Given a message, produce anInputStream
for it so that it can be written to the wire.
-
Field Details
-
bufs
-
parser
-
defaultInstance
-
recursionLimit
private final int recursionLimit
-
-
Constructor Details
-
MessageMarshaller
MessageMarshaller(T defaultInstance, int recursionLimit)
-
-
Method Details
-
getMessageClass
Description copied from interface:MethodDescriptor.ReflectableMarshaller
Returns theClass
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 interfaceMethodDescriptor.ReflectableMarshaller<T extends com.google.protobuf.MessageLite>
- Returns:
- non-
null
base class for all objects produced and consumed by this marshaller
-
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. Thenull
value may be a special value for the marshaller (like the equivalent ofVoid
), 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 interfaceMethodDescriptor.PrototypeMarshaller<T extends com.google.protobuf.MessageLite>
-
stream
Description copied from interface:MethodDescriptor.Marshaller
Given a message, produce anInputStream
for it so that it can be written to the wire. Where possible implementations should produce streams that areKnownLength
to improve transport efficiency.- Specified by:
stream
in interfaceMethodDescriptor.Marshaller<T extends com.google.protobuf.MessageLite>
- Parameters:
value
- to serialize.- Returns:
- serialized value as stream of bytes.
-
parse
Description copied from interface:MethodDescriptor.Marshaller
Given anInputStream
parse it into an instance of the declared type so that it can be passed to application code.- Specified by:
parse
in 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
-