Interface GrpcMessageDecoder<T>


  • public interface GrpcMessageDecoder<T>
    • Method Detail

      • decoder

        static <T> GrpcMessageDecoder<T> decoder​(com.google.protobuf.MessageOrBuilder messageOrBuilder)
        Create a decoder for a given protobuf Parser.
        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 protobuf Parser.
        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 the clazz using Json.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
        Decodes a given gRPC message into an object of type T.
        Parameters:
        msg - the gRPC message to decode
        Returns:
        the decoded message of type T
        Throws:
        CodecException - if the decoding process fails
      • accepts

        boolean accepts​(WireFormat format)
        Determines whether the given WireFormat is 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, null otherwise.
        Returns:
        the protobuf descriptor or null