package io.seata.integration.grpc.interceptor.proto;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.27.1)",
    comments = "Source: contextTest.proto")
public final class ContextRpcGrpc {

  private ContextRpcGrpc() {}

  public static final String SERVICE_NAME = "ContextRpc";

  // Static method descriptors that strictly reflect the proto.
  private static volatile io.grpc.MethodDescriptor<io.seata.integration.grpc.interceptor.proto.Request,
      io.seata.integration.grpc.interceptor.proto.Response> getContextRpcMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "ContextRpc",
      requestType = io.seata.integration.grpc.interceptor.proto.Request.class,
      responseType = io.seata.integration.grpc.interceptor.proto.Response.class,
      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
  public static io.grpc.MethodDescriptor<io.seata.integration.grpc.interceptor.proto.Request,
      io.seata.integration.grpc.interceptor.proto.Response> getContextRpcMethod() {
    io.grpc.MethodDescriptor<io.seata.integration.grpc.interceptor.proto.Request, io.seata.integration.grpc.interceptor.proto.Response> getContextRpcMethod;
    if ((getContextRpcMethod = ContextRpcGrpc.getContextRpcMethod) == null) {
      synchronized (ContextRpcGrpc.class) {
        if ((getContextRpcMethod = ContextRpcGrpc.getContextRpcMethod) == null) {
          ContextRpcGrpc.getContextRpcMethod = getContextRpcMethod =
              io.grpc.MethodDescriptor.<io.seata.integration.grpc.interceptor.proto.Request, io.seata.integration.grpc.interceptor.proto.Response>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ContextRpc"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  io.seata.integration.grpc.interceptor.proto.Request.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  io.seata.integration.grpc.interceptor.proto.Response.getDefaultInstance()))
              .setSchemaDescriptor(new ContextRpcMethodDescriptorSupplier("ContextRpc"))
              .build();
        }
      }
    }
    return getContextRpcMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static ContextRpcStub newStub(io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<ContextRpcStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<ContextRpcStub>() {
        @java.lang.Override
        public ContextRpcStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new ContextRpcStub(channel, callOptions);
        }
      };
    return ContextRpcStub.newStub(factory, channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static ContextRpcBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<ContextRpcBlockingStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<ContextRpcBlockingStub>() {
        @java.lang.Override
        public ContextRpcBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new ContextRpcBlockingStub(channel, callOptions);
        }
      };
    return ContextRpcBlockingStub.newStub(factory, channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static ContextRpcFutureStub newFutureStub(
      io.grpc.Channel channel) {
    io.grpc.stub.AbstractStub.StubFactory<ContextRpcFutureStub> factory =
      new io.grpc.stub.AbstractStub.StubFactory<ContextRpcFutureStub>() {
        @java.lang.Override
        public ContextRpcFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
          return new ContextRpcFutureStub(channel, callOptions);
        }
      };
    return ContextRpcFutureStub.newStub(factory, channel);
  }

  /**
   */
  public static abstract class ContextRpcImplBase implements io.grpc.BindableService {

    /**
     */
    public void contextRpc(io.seata.integration.grpc.interceptor.proto.Request request,
        io.grpc.stub.StreamObserver<io.seata.integration.grpc.interceptor.proto.Response> responseObserver) {
      asyncUnimplementedUnaryCall(getContextRpcMethod(), responseObserver);
    }

    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getContextRpcMethod(),
            asyncUnaryCall(
              new MethodHandlers<
                io.seata.integration.grpc.interceptor.proto.Request,
                io.seata.integration.grpc.interceptor.proto.Response>(
                  this, METHODID_CONTEXT_RPC)))
          .build();
    }
  }

  /**
   */
  public static final class ContextRpcStub extends io.grpc.stub.AbstractAsyncStub<ContextRpcStub> {
    private ContextRpcStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected ContextRpcStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new ContextRpcStub(channel, callOptions);
    }

    /**
     */
    public void contextRpc(io.seata.integration.grpc.interceptor.proto.Request request,
        io.grpc.stub.StreamObserver<io.seata.integration.grpc.interceptor.proto.Response> responseObserver) {
      asyncUnaryCall(
          getChannel().newCall(getContextRpcMethod(), getCallOptions()), request, responseObserver);
    }
  }

  /**
   */
  public static final class ContextRpcBlockingStub extends io.grpc.stub.AbstractBlockingStub<ContextRpcBlockingStub> {
    private ContextRpcBlockingStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected ContextRpcBlockingStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new ContextRpcBlockingStub(channel, callOptions);
    }

    /**
     */
    public io.seata.integration.grpc.interceptor.proto.Response contextRpc(io.seata.integration.grpc.interceptor.proto.Request request) {
      return blockingUnaryCall(
          getChannel(), getContextRpcMethod(), getCallOptions(), request);
    }
  }

  /**
   */
  public static final class ContextRpcFutureStub extends io.grpc.stub.AbstractFutureStub<ContextRpcFutureStub> {
    private ContextRpcFutureStub(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected ContextRpcFutureStub build(
        io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
      return new ContextRpcFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<io.seata.integration.grpc.interceptor.proto.Response> contextRpc(
        io.seata.integration.grpc.interceptor.proto.Request request) {
      return futureUnaryCall(
          getChannel().newCall(getContextRpcMethod(), getCallOptions()), request);
    }
  }

  private static final int METHODID_CONTEXT_RPC = 0;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final ContextRpcImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(ContextRpcImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_CONTEXT_RPC:
          serviceImpl.contextRpc((io.seata.integration.grpc.interceptor.proto.Request) request,
              (io.grpc.stub.StreamObserver<io.seata.integration.grpc.interceptor.proto.Response>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class ContextRpcBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    ContextRpcBaseDescriptorSupplier() {}

    @java.lang.Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return io.seata.integration.grpc.interceptor.proto.ContextRpcTest.getDescriptor();
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("ContextRpc");
    }
  }

  private static final class ContextRpcFileDescriptorSupplier
      extends ContextRpcBaseDescriptorSupplier {
    ContextRpcFileDescriptorSupplier() {}
  }

  private static final class ContextRpcMethodDescriptorSupplier
      extends ContextRpcBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    ContextRpcMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (ContextRpcGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new ContextRpcFileDescriptorSupplier())
              .addMethod(getContextRpcMethod())
              .build();
        }
      }
    }
    return result;
  }
}
