Package io.vertx.grpc.common
Interface GrpcMessageDecoder<T>
-
public interface GrpcMessageDecoder<T>
-
-
Field Summary
Fields Modifier and Type Field Description static GrpcMessageDecoder<Buffer>IDENTITYstatic GrpcMessageDecoder<JsonObject>JSON_OBJECTA decoder in JSON format decoding to instances ofJsonObject.static GrpcMessageDecoder<Object>JSON_VALUEA decoder in JSON format decoding arbitrary JSON values:JsonObject,JsonArrayor string/number/boolean/null
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaccepts(WireFormat format)Tdecode(GrpcMessage msg)static <T> GrpcMessageDecoder<T>decoder(com.google.protobuf.MessageOrBuilder messageOrBuilder)Create a decoder for a given protobufParser.static <T> GrpcMessageDecoder<T>json(Class<T> clazz)Create a decoder in JSON format decoding to instances of theclazzusingJson.decodeValue(Buffer, Class)(Jackson Databind is required).static <T> GrpcMessageDecoder<T>json(Supplier<com.google.protobuf.Message.Builder> builder)Create a decoder for a given protobufParser.
-
-
-
Field Detail
-
IDENTITY
static final GrpcMessageDecoder<Buffer> IDENTITY
-
JSON_OBJECT
static final GrpcMessageDecoder<JsonObject> JSON_OBJECT
A decoder in JSON format decoding to instances ofJsonObject.
-
JSON_VALUE
static final GrpcMessageDecoder<Object> JSON_VALUE
A decoder in JSON format decoding arbitrary JSON values:JsonObject,JsonArrayor string/number/boolean/null
-
-
Method Detail
-
decoder
static <T> GrpcMessageDecoder<T> decoder(com.google.protobuf.MessageOrBuilder messageOrBuilder)
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
static <T> GrpcMessageDecoder<T> json(Supplier<com.google.protobuf.Message.Builder> builder)
Create a decoder for a given protobufParser.- Parameters:
builder- the supplier of a message builder- Returns:
- the message decoder
-
json
static <T> GrpcMessageDecoder<T> json(Class<T> clazz)
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
T decode(GrpcMessage msg) throws CodecException
- Throws:
CodecException
-
accepts
boolean accepts(WireFormat format)
-
-