Package io.vertx.grpc.common
Interface GrpcMessageDecoder<T>
-
public interface GrpcMessageDecoder<T>
-
-
Field Summary
Fields Modifier and Type Field Description static GrpcMessageDecoder<Buffer>
IDENTITY
static GrpcMessageDecoder<JsonObject>
JSON_OBJECT
A decoder in JSON format decoding to instances ofJsonObject
.static GrpcMessageDecoder<Object>
JSON_VALUE
A decoder in JSON format decoding arbitrary JSON values:JsonObject
,JsonArray
or string/number/boolean/null
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description T
decode(GrpcMessage msg)
static <T> GrpcMessageDecoder<T>
decoder(com.google.protobuf.Parser<T> parser)
Create a decoder for a given protobufParser
.WireFormat
format()
static <T> GrpcMessageDecoder<T>
json(Class<T> clazz)
Create a decoder in JSON format decoding to instances of theclazz
usingJson.decodeValue(Buffer, Class)
(Jackson Databind is required).static <T> GrpcMessageDecoder<T>
json(java.util.function.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
,JsonArray
or string/number/boolean/null
-
-
Method Detail
-
decoder
static <T> GrpcMessageDecoder<T> decoder(com.google.protobuf.Parser<T> parser)
Create a decoder for a given protobufParser
.- Parameters:
parser
- the parser that returns decoded messages of type<T>
- Returns:
- the message decoder
-
json
static <T> GrpcMessageDecoder<T> json(java.util.function.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 theclazz
usingJson.decodeValue(Buffer, Class)
(Jackson Databind is required).- Parameters:
clazz
- the java type to decode- Returns:
- a decoder that decodes messages to instance of
clazz
in JSON format.
-
decode
T decode(GrpcMessage msg) throws CodecException
- Throws:
CodecException
-
format
WireFormat format()
-
-