Interface GrpcMessageDecoder<T>
public interface GrpcMessageDecoder<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final GrpcMessageDecoder<Buffer> static final GrpcMessageDecoder<JsonObject> A decoder in JSON format decoding to instances ofJsonObject.static final GrpcMessageDecoder<Object> A decoder in JSON format decoding arbitrary JSON values:JsonObject,JsonArrayor string/number/boolean/null -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(WireFormat format) Determines whether the givenWireFormatis supported by this decoder.decode(GrpcMessage msg) Decodes a given gRPC message into an object of typeT.static <T> GrpcMessageDecoder<T> decoder(com.google.protobuf.MessageOrBuilder messageOrBuilder) Create a decoder for a given protobufParser.static <T> GrpcMessageDecoder<T> Create a decoder in JSON format decoding to instances of theclazzusingJson.decodeValue(Buffer, Class)(Jackson Databind is required).static <T> GrpcMessageDecoder<T> Create a decoder for a given protobufParser.default com.google.protobuf.Descriptors.DescriptorReturns the protobuf message descriptor if this decoder was created from a protobuf message type,nullotherwise.
-
Field Details
-
IDENTITY
-
JSON_OBJECT
A decoder in JSON format decoding to instances ofJsonObject. -
JSON_VALUE
A decoder in JSON format decoding arbitrary JSON values:JsonObject,JsonArrayor string/number/boolean/null
-
-
Method Details
-
decoder
Create a decoder for a given protobufParser.- Parameters:
messageOrBuilder- the message or builder instance that returns decoded messages of type<T>- Returns:
- the message decoder
-
json
Create a decoder for a given protobufParser.- Parameters:
builder- the supplier of a message builder- Returns:
- the message decoder
-
json
Create a decoder in JSON format decoding to instances of theclazzusingJson.decodeValue(Buffer, Class)(Jackson Databind is required).- Parameters:
clazz- the java type to decode- Returns:
- a decoder that decodes messages to instance of
clazzin JSON format.
-
decode
Decodes a given gRPC message into an object of typeT.- Parameters:
msg- the gRPC message to decode- Returns:
- the decoded message of type
T - Throws:
CodecException- if the decoding process fails
-
accepts
Determines whether the givenWireFormatis supported by this decoder.- Parameters:
format- the wire format to check- Returns:
- true if the given wire format is accepted, false otherwise
-
messageDescriptor
@Unstable default com.google.protobuf.Descriptors.Descriptor messageDescriptor()Returns the protobuf message descriptor if this decoder was created from a protobuf message type,nullotherwise.- Returns:
- the protobuf descriptor or
null
-