Java 类io.grpc.MethodDescriptor.PrototypeMarshaller 实例源码

项目:armeria    文件:GrpcJsonUtil.java   
private static Optional<Message> marshallerPrototype(Marshaller<?> marshaller) {
    if (marshaller instanceof PrototypeMarshaller) {
        Object prototype = ((PrototypeMarshaller) marshaller).getMessagePrototype();
        if (prototype instanceof Message) {
            return Optional.of((Message) prototype);
        }
    }
    return Optional.empty();
}
项目:grpc-java    文件:ProtoLiteUtilsTest.java   
@Test
public void introspection() throws Exception {
  Marshaller<Enum> enumMarshaller = ProtoLiteUtils.marshaller(Enum.getDefaultInstance());
  PrototypeMarshaller<Enum> prototypeMarshaller = (PrototypeMarshaller<Enum>) enumMarshaller;
  assertSame(Enum.getDefaultInstance(), prototypeMarshaller.getMessagePrototype());
  assertSame(Enum.class, prototypeMarshaller.getMessageClass());
}
项目:armeria    文件:GrpcMessageMarshaller.java   
private static MessageType marshallerType(Marshaller<?> marshaller) {
    return marshaller instanceof PrototypeMarshaller ? MessageType.PROTOBUF : MessageType.UNKNOWN;
}