/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

    package com.ywt.gapi.third.taihe;

import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.PathResolver;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.ServerService;
import org.apache.dubbo.rpc.TriRpcStatus;
import org.apache.dubbo.rpc.model.MethodDescriptor;
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.rpc.model.StubMethodDescriptor;
import org.apache.dubbo.rpc.model.StubServiceDescriptor;
import org.apache.dubbo.rpc.stub.BiStreamMethodHandler;
import org.apache.dubbo.rpc.stub.ServerStreamMethodHandler;
import org.apache.dubbo.rpc.stub.StubInvocationUtil;
import org.apache.dubbo.rpc.stub.StubInvoker;
import org.apache.dubbo.rpc.stub.StubMethodHandler;
import org.apache.dubbo.rpc.stub.StubSuppliers;
import org.apache.dubbo.rpc.stub.UnaryStubMethodHandler;

import com.google.protobuf.Message;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.concurrent.CompletableFuture;

public final class DubboTaiheServiceTriple {

    public static final String SERVICE_NAME = TaiheService.SERVICE_NAME;

    private static final StubServiceDescriptor serviceDescriptor = new StubServiceDescriptor(SERVICE_NAME,TaiheService.class);

    static {
        org.apache.dubbo.rpc.protocol.tri.service.SchemaDescriptorRegistry.addSchemaDescriptor(SERVICE_NAME,ThirdTaiheProto.getDescriptor());
        StubSuppliers.addSupplier(SERVICE_NAME, DubboTaiheServiceTriple::newStub);
        StubSuppliers.addSupplier(TaiheService.JAVA_SERVICE_NAME,  DubboTaiheServiceTriple::newStub);
        StubSuppliers.addDescriptor(SERVICE_NAME, serviceDescriptor);
        StubSuppliers.addDescriptor(TaiheService.JAVA_SERVICE_NAME, serviceDescriptor);
    }

    @SuppressWarnings("all")
    public static TaiheService newStub(Invoker<?> invoker) {
        return new TaiheServiceStub((Invoker<TaiheService>)invoker);
    }

    private static final StubMethodDescriptor getPatientInfoMethod = new StubMethodDescriptor("getPatientInfo",
    GetPatientInfoRequest.class, GetPatientInfoResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), GetPatientInfoRequest::parseFrom,
    GetPatientInfoResponse::parseFrom);

    private static final StubMethodDescriptor getPatientInfoAsyncMethod = new StubMethodDescriptor("getPatientInfo",
    GetPatientInfoRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), GetPatientInfoRequest::parseFrom,
    GetPatientInfoResponse::parseFrom);

    private static final StubMethodDescriptor getPatientInfoProxyAsyncMethod = new StubMethodDescriptor("getPatientInfoAsync",
    GetPatientInfoRequest.class, GetPatientInfoResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), GetPatientInfoRequest::parseFrom,
    GetPatientInfoResponse::parseFrom);

    private static final StubMethodDescriptor createPatInfoMethod = new StubMethodDescriptor("createPatInfo",
    CreatePatInfoRequest.class, CreatePatInfoResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), CreatePatInfoRequest::parseFrom,
    CreatePatInfoResponse::parseFrom);

    private static final StubMethodDescriptor createPatInfoAsyncMethod = new StubMethodDescriptor("createPatInfo",
    CreatePatInfoRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), CreatePatInfoRequest::parseFrom,
    CreatePatInfoResponse::parseFrom);

    private static final StubMethodDescriptor createPatInfoProxyAsyncMethod = new StubMethodDescriptor("createPatInfoAsync",
    CreatePatInfoRequest.class, CreatePatInfoResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), CreatePatInfoRequest::parseFrom,
    CreatePatInfoResponse::parseFrom);

    private static final StubMethodDescriptor getOutpatientListMethod = new StubMethodDescriptor("getOutpatientList",
    com.ywt.gapi.third.taihe.GetOutpatientListRequest.class, com.ywt.gapi.third.taihe.GetOutpatientListResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), com.ywt.gapi.third.taihe.GetOutpatientListRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetOutpatientListResponse::parseFrom);

    private static final StubMethodDescriptor getOutpatientListAsyncMethod = new StubMethodDescriptor("getOutpatientList",
    com.ywt.gapi.third.taihe.GetOutpatientListRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), com.ywt.gapi.third.taihe.GetOutpatientListRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetOutpatientListResponse::parseFrom);

    private static final StubMethodDescriptor getOutpatientListProxyAsyncMethod = new StubMethodDescriptor("getOutpatientListAsync",
    com.ywt.gapi.third.taihe.GetOutpatientListRequest.class, com.ywt.gapi.third.taihe.GetOutpatientListResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), com.ywt.gapi.third.taihe.GetOutpatientListRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetOutpatientListResponse::parseFrom);

    private static final StubMethodDescriptor lockOrderMethod = new StubMethodDescriptor("lockOrder",
    LockOrderRequest.class, LockOrderResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), LockOrderRequest::parseFrom,
    LockOrderResponse::parseFrom);

    private static final StubMethodDescriptor lockOrderAsyncMethod = new StubMethodDescriptor("lockOrder",
    LockOrderRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), LockOrderRequest::parseFrom,
    LockOrderResponse::parseFrom);

    private static final StubMethodDescriptor lockOrderProxyAsyncMethod = new StubMethodDescriptor("lockOrderAsync",
    LockOrderRequest.class, LockOrderResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), LockOrderRequest::parseFrom,
    LockOrderResponse::parseFrom);

    private static final StubMethodDescriptor payMethod = new StubMethodDescriptor("pay",
    PayRequest.class, PayResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), PayRequest::parseFrom,
    PayResponse::parseFrom);

    private static final StubMethodDescriptor payAsyncMethod = new StubMethodDescriptor("pay",
    PayRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), PayRequest::parseFrom,
    PayResponse::parseFrom);

    private static final StubMethodDescriptor payProxyAsyncMethod = new StubMethodDescriptor("payAsync",
    PayRequest.class, PayResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), PayRequest::parseFrom,
    PayResponse::parseFrom);

    private static final StubMethodDescriptor payFreeMethod = new StubMethodDescriptor("payFree",
    PayFreeRequest.class, PayFreeResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), PayFreeRequest::parseFrom,
    PayFreeResponse::parseFrom);

    private static final StubMethodDescriptor payFreeAsyncMethod = new StubMethodDescriptor("payFree",
    PayFreeRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), PayFreeRequest::parseFrom,
    PayFreeResponse::parseFrom);

    private static final StubMethodDescriptor payFreeProxyAsyncMethod = new StubMethodDescriptor("payFreeAsync",
    PayFreeRequest.class, PayFreeResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), PayFreeRequest::parseFrom,
    PayFreeResponse::parseFrom);

    private static final StubMethodDescriptor getScheduleListMethod = new StubMethodDescriptor("getScheduleList",
    GetScheduleListRequest.class, com.ywt.gapi.third.taihe.GetScheduleListResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), GetScheduleListRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetScheduleListResponse::parseFrom);

    private static final StubMethodDescriptor getScheduleListAsyncMethod = new StubMethodDescriptor("getScheduleList",
    GetScheduleListRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), GetScheduleListRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetScheduleListResponse::parseFrom);

    private static final StubMethodDescriptor getScheduleListProxyAsyncMethod = new StubMethodDescriptor("getScheduleListAsync",
    GetScheduleListRequest.class, com.ywt.gapi.third.taihe.GetScheduleListResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), GetScheduleListRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetScheduleListResponse::parseFrom);

    private static final StubMethodDescriptor takeMethod = new StubMethodDescriptor("take",
    TakeRequest.class, TakeResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), TakeRequest::parseFrom,
    TakeResponse::parseFrom);

    private static final StubMethodDescriptor takeAsyncMethod = new StubMethodDescriptor("take",
    TakeRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), TakeRequest::parseFrom,
    TakeResponse::parseFrom);

    private static final StubMethodDescriptor takeProxyAsyncMethod = new StubMethodDescriptor("takeAsync",
    TakeRequest.class, TakeResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), TakeRequest::parseFrom,
    TakeResponse::parseFrom);

    private static final StubMethodDescriptor cancelMethod = new StubMethodDescriptor("cancel",
    CancelRequest.class, CancelResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), CancelRequest::parseFrom,
    CancelResponse::parseFrom);

    private static final StubMethodDescriptor cancelAsyncMethod = new StubMethodDescriptor("cancel",
    CancelRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), CancelRequest::parseFrom,
    CancelResponse::parseFrom);

    private static final StubMethodDescriptor cancelProxyAsyncMethod = new StubMethodDescriptor("cancelAsync",
    CancelRequest.class, CancelResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), CancelRequest::parseFrom,
    CancelResponse::parseFrom);

    private static final StubMethodDescriptor getDiagnoseRecordMethod = new StubMethodDescriptor("getDiagnoseRecord",
    com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest.class, com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse::parseFrom);

    private static final StubMethodDescriptor getDiagnoseRecordAsyncMethod = new StubMethodDescriptor("getDiagnoseRecord",
    com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse::parseFrom);

    private static final StubMethodDescriptor getDiagnoseRecordProxyAsyncMethod = new StubMethodDescriptor("getDiagnoseRecordAsync",
    com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest.class, com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest::parseFrom,
    com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse::parseFrom);

    private static final StubMethodDescriptor registerMethod = new StubMethodDescriptor("register",
    RegisterRequest.class, RegisterResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), RegisterRequest::parseFrom,
    RegisterResponse::parseFrom);

    private static final StubMethodDescriptor registerAsyncMethod = new StubMethodDescriptor("register",
    RegisterRequest.class, CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), RegisterRequest::parseFrom,
    RegisterResponse::parseFrom);

    private static final StubMethodDescriptor registerProxyAsyncMethod = new StubMethodDescriptor("registerAsync",
    RegisterRequest.class, RegisterResponse.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
    obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), RegisterRequest::parseFrom,
    RegisterResponse::parseFrom);





    public static class TaiheServiceStub implements TaiheService{
        private final Invoker<TaiheService> invoker;

        public TaiheServiceStub(Invoker<TaiheService> invoker) {
            this.invoker = invoker;
        }

        @Override
        public GetPatientInfoResponse getPatientInfo(GetPatientInfoRequest request){
            return StubInvocationUtil.unaryCall(invoker, getPatientInfoMethod, request);
        }

        public CompletableFuture<GetPatientInfoResponse> getPatientInfoAsync(GetPatientInfoRequest request){
            return StubInvocationUtil.unaryCall(invoker, getPatientInfoAsyncMethod, request);
        }

        @Override
        public void getPatientInfo(GetPatientInfoRequest request, StreamObserver<GetPatientInfoResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, getPatientInfoMethod , request, responseObserver);
        }
        @Override
        public CreatePatInfoResponse createPatInfo(CreatePatInfoRequest request){
            return StubInvocationUtil.unaryCall(invoker, createPatInfoMethod, request);
        }

        public CompletableFuture<CreatePatInfoResponse> createPatInfoAsync(CreatePatInfoRequest request){
            return StubInvocationUtil.unaryCall(invoker, createPatInfoAsyncMethod, request);
        }

        @Override
        public void createPatInfo(CreatePatInfoRequest request, StreamObserver<CreatePatInfoResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, createPatInfoMethod , request, responseObserver);
        }
        @Override
        public com.ywt.gapi.third.taihe.GetOutpatientListResponse getOutpatientList(com.ywt.gapi.third.taihe.GetOutpatientListRequest request){
            return StubInvocationUtil.unaryCall(invoker, getOutpatientListMethod, request);
        }

        public CompletableFuture<com.ywt.gapi.third.taihe.GetOutpatientListResponse> getOutpatientListAsync(com.ywt.gapi.third.taihe.GetOutpatientListRequest request){
            return StubInvocationUtil.unaryCall(invoker, getOutpatientListAsyncMethod, request);
        }

        @Override
        public void getOutpatientList(com.ywt.gapi.third.taihe.GetOutpatientListRequest request, StreamObserver<com.ywt.gapi.third.taihe.GetOutpatientListResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, getOutpatientListMethod , request, responseObserver);
        }
        @Override
        public LockOrderResponse lockOrder(LockOrderRequest request){
            return StubInvocationUtil.unaryCall(invoker, lockOrderMethod, request);
        }

        public CompletableFuture<LockOrderResponse> lockOrderAsync(LockOrderRequest request){
            return StubInvocationUtil.unaryCall(invoker, lockOrderAsyncMethod, request);
        }

        @Override
        public void lockOrder(LockOrderRequest request, StreamObserver<LockOrderResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, lockOrderMethod , request, responseObserver);
        }
        @Override
        public PayResponse pay(PayRequest request){
            return StubInvocationUtil.unaryCall(invoker, payMethod, request);
        }

        public CompletableFuture<PayResponse> payAsync(PayRequest request){
            return StubInvocationUtil.unaryCall(invoker, payAsyncMethod, request);
        }

        @Override
        public void pay(PayRequest request, StreamObserver<PayResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, payMethod , request, responseObserver);
        }
        @Override
        public PayFreeResponse payFree(PayFreeRequest request){
            return StubInvocationUtil.unaryCall(invoker, payFreeMethod, request);
        }

        public CompletableFuture<PayFreeResponse> payFreeAsync(PayFreeRequest request){
            return StubInvocationUtil.unaryCall(invoker, payFreeAsyncMethod, request);
        }

        @Override
        public void payFree(PayFreeRequest request, StreamObserver<PayFreeResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, payFreeMethod , request, responseObserver);
        }
        @Override
        public com.ywt.gapi.third.taihe.GetScheduleListResponse getScheduleList(GetScheduleListRequest request){
            return StubInvocationUtil.unaryCall(invoker, getScheduleListMethod, request);
        }

        public CompletableFuture<com.ywt.gapi.third.taihe.GetScheduleListResponse> getScheduleListAsync(GetScheduleListRequest request){
            return StubInvocationUtil.unaryCall(invoker, getScheduleListAsyncMethod, request);
        }

        @Override
        public void getScheduleList(GetScheduleListRequest request, StreamObserver<com.ywt.gapi.third.taihe.GetScheduleListResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, getScheduleListMethod , request, responseObserver);
        }
        @Override
        public TakeResponse take(TakeRequest request){
            return StubInvocationUtil.unaryCall(invoker, takeMethod, request);
        }

        public CompletableFuture<TakeResponse> takeAsync(TakeRequest request){
            return StubInvocationUtil.unaryCall(invoker, takeAsyncMethod, request);
        }

        @Override
        public void take(TakeRequest request, StreamObserver<TakeResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, takeMethod , request, responseObserver);
        }
        @Override
        public CancelResponse cancel(CancelRequest request){
            return StubInvocationUtil.unaryCall(invoker, cancelMethod, request);
        }

        public CompletableFuture<CancelResponse> cancelAsync(CancelRequest request){
            return StubInvocationUtil.unaryCall(invoker, cancelAsyncMethod, request);
        }

        @Override
        public void cancel(CancelRequest request, StreamObserver<CancelResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, cancelMethod , request, responseObserver);
        }
        @Override
        public com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse getDiagnoseRecord(com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest request){
            return StubInvocationUtil.unaryCall(invoker, getDiagnoseRecordMethod, request);
        }

        public CompletableFuture<com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse> getDiagnoseRecordAsync(com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest request){
            return StubInvocationUtil.unaryCall(invoker, getDiagnoseRecordAsyncMethod, request);
        }

        @Override
        public void getDiagnoseRecord(com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest request, StreamObserver<com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, getDiagnoseRecordMethod , request, responseObserver);
        }
        @Override
        public RegisterResponse register(RegisterRequest request){
            return StubInvocationUtil.unaryCall(invoker, registerMethod, request);
        }

        public CompletableFuture<RegisterResponse> registerAsync(RegisterRequest request){
            return StubInvocationUtil.unaryCall(invoker, registerAsyncMethod, request);
        }

        @Override
        public void register(RegisterRequest request, StreamObserver<RegisterResponse> responseObserver){
            StubInvocationUtil.unaryCall(invoker, registerMethod , request, responseObserver);
        }



    }

    public static abstract class TaiheServiceImplBase implements TaiheService, ServerService<TaiheService> {

        private <T, R> BiConsumer<T, StreamObserver<R>> syncToAsync(java.util.function.Function<T, R> syncFun) {
            return new BiConsumer<T, StreamObserver<R>>() {
                @Override
                public void accept(T t, StreamObserver<R> observer) {
                    try {
                        R ret = syncFun.apply(t);
                        observer.onNext(ret);
                        observer.onCompleted();
                    } catch (Throwable e) {
                        observer.onError(e);
                    }
                }
            };
        }

        @Override
        public final Invoker<TaiheService> getInvoker(URL url) {
            PathResolver pathResolver = url.getOrDefaultFrameworkModel()
            .getExtensionLoader(PathResolver.class)
            .getDefaultExtension();
            Map<String,StubMethodHandler<?, ?>> handlers = new HashMap<>();

            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getPatientInfo" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getPatientInfoAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/createPatInfo" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/createPatInfoAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getOutpatientList" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getOutpatientListAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/lockOrder" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/lockOrderAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/pay" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/payAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/payFree" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/payFreeAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getScheduleList" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getScheduleListAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/take" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/takeAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/cancel" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/cancelAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getDiagnoseRecord" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/getDiagnoseRecordAsync" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/register" );
            pathResolver.addNativeStub( "/" + SERVICE_NAME + "/registerAsync" );

            BiConsumer<GetPatientInfoRequest, StreamObserver<GetPatientInfoResponse>> getPatientInfoFunc = this::getPatientInfo;
            handlers.put(getPatientInfoMethod.getMethodName(), new UnaryStubMethodHandler<>(getPatientInfoFunc));
            BiConsumer<GetPatientInfoRequest, StreamObserver<GetPatientInfoResponse>> getPatientInfoAsyncFunc = syncToAsync(this::getPatientInfo);
            handlers.put(getPatientInfoProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(getPatientInfoAsyncFunc));
            BiConsumer<CreatePatInfoRequest, StreamObserver<CreatePatInfoResponse>> createPatInfoFunc = this::createPatInfo;
            handlers.put(createPatInfoMethod.getMethodName(), new UnaryStubMethodHandler<>(createPatInfoFunc));
            BiConsumer<CreatePatInfoRequest, StreamObserver<CreatePatInfoResponse>> createPatInfoAsyncFunc = syncToAsync(this::createPatInfo);
            handlers.put(createPatInfoProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(createPatInfoAsyncFunc));
            BiConsumer<com.ywt.gapi.third.taihe.GetOutpatientListRequest, StreamObserver<com.ywt.gapi.third.taihe.GetOutpatientListResponse>> getOutpatientListFunc = this::getOutpatientList;
            handlers.put(getOutpatientListMethod.getMethodName(), new UnaryStubMethodHandler<>(getOutpatientListFunc));
            BiConsumer<com.ywt.gapi.third.taihe.GetOutpatientListRequest, StreamObserver<com.ywt.gapi.third.taihe.GetOutpatientListResponse>> getOutpatientListAsyncFunc = syncToAsync(this::getOutpatientList);
            handlers.put(getOutpatientListProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(getOutpatientListAsyncFunc));
            BiConsumer<LockOrderRequest, StreamObserver<LockOrderResponse>> lockOrderFunc = this::lockOrder;
            handlers.put(lockOrderMethod.getMethodName(), new UnaryStubMethodHandler<>(lockOrderFunc));
            BiConsumer<LockOrderRequest, StreamObserver<LockOrderResponse>> lockOrderAsyncFunc = syncToAsync(this::lockOrder);
            handlers.put(lockOrderProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(lockOrderAsyncFunc));
            BiConsumer<PayRequest, StreamObserver<PayResponse>> payFunc = this::pay;
            handlers.put(payMethod.getMethodName(), new UnaryStubMethodHandler<>(payFunc));
            BiConsumer<PayRequest, StreamObserver<PayResponse>> payAsyncFunc = syncToAsync(this::pay);
            handlers.put(payProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(payAsyncFunc));
            BiConsumer<PayFreeRequest, StreamObserver<PayFreeResponse>> payFreeFunc = this::payFree;
            handlers.put(payFreeMethod.getMethodName(), new UnaryStubMethodHandler<>(payFreeFunc));
            BiConsumer<PayFreeRequest, StreamObserver<PayFreeResponse>> payFreeAsyncFunc = syncToAsync(this::payFree);
            handlers.put(payFreeProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(payFreeAsyncFunc));
            BiConsumer<GetScheduleListRequest, StreamObserver<com.ywt.gapi.third.taihe.GetScheduleListResponse>> getScheduleListFunc = this::getScheduleList;
            handlers.put(getScheduleListMethod.getMethodName(), new UnaryStubMethodHandler<>(getScheduleListFunc));
            BiConsumer<GetScheduleListRequest, StreamObserver<com.ywt.gapi.third.taihe.GetScheduleListResponse>> getScheduleListAsyncFunc = syncToAsync(this::getScheduleList);
            handlers.put(getScheduleListProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(getScheduleListAsyncFunc));
            BiConsumer<TakeRequest, StreamObserver<TakeResponse>> takeFunc = this::take;
            handlers.put(takeMethod.getMethodName(), new UnaryStubMethodHandler<>(takeFunc));
            BiConsumer<TakeRequest, StreamObserver<TakeResponse>> takeAsyncFunc = syncToAsync(this::take);
            handlers.put(takeProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(takeAsyncFunc));
            BiConsumer<CancelRequest, StreamObserver<CancelResponse>> cancelFunc = this::cancel;
            handlers.put(cancelMethod.getMethodName(), new UnaryStubMethodHandler<>(cancelFunc));
            BiConsumer<CancelRequest, StreamObserver<CancelResponse>> cancelAsyncFunc = syncToAsync(this::cancel);
            handlers.put(cancelProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(cancelAsyncFunc));
            BiConsumer<com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest, StreamObserver<com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse>> getDiagnoseRecordFunc = this::getDiagnoseRecord;
            handlers.put(getDiagnoseRecordMethod.getMethodName(), new UnaryStubMethodHandler<>(getDiagnoseRecordFunc));
            BiConsumer<com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest, StreamObserver<com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse>> getDiagnoseRecordAsyncFunc = syncToAsync(this::getDiagnoseRecord);
            handlers.put(getDiagnoseRecordProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(getDiagnoseRecordAsyncFunc));
            BiConsumer<RegisterRequest, StreamObserver<RegisterResponse>> registerFunc = this::register;
            handlers.put(registerMethod.getMethodName(), new UnaryStubMethodHandler<>(registerFunc));
            BiConsumer<RegisterRequest, StreamObserver<RegisterResponse>> registerAsyncFunc = syncToAsync(this::register);
            handlers.put(registerProxyAsyncMethod.getMethodName(), new UnaryStubMethodHandler<>(registerAsyncFunc));




            return new StubInvoker<>(this, url, TaiheService.class, handlers);
        }


        @Override
        public GetPatientInfoResponse getPatientInfo(GetPatientInfoRequest request){
            throw unimplementedMethodException(getPatientInfoMethod);
        }

        @Override
        public CreatePatInfoResponse createPatInfo(CreatePatInfoRequest request){
            throw unimplementedMethodException(createPatInfoMethod);
        }

        @Override
        public com.ywt.gapi.third.taihe.GetOutpatientListResponse getOutpatientList(com.ywt.gapi.third.taihe.GetOutpatientListRequest request){
            throw unimplementedMethodException(getOutpatientListMethod);
        }

        @Override
        public LockOrderResponse lockOrder(LockOrderRequest request){
            throw unimplementedMethodException(lockOrderMethod);
        }

        @Override
        public PayResponse pay(PayRequest request){
            throw unimplementedMethodException(payMethod);
        }

        @Override
        public PayFreeResponse payFree(PayFreeRequest request){
            throw unimplementedMethodException(payFreeMethod);
        }

        @Override
        public com.ywt.gapi.third.taihe.GetScheduleListResponse getScheduleList(GetScheduleListRequest request){
            throw unimplementedMethodException(getScheduleListMethod);
        }

        @Override
        public TakeResponse take(TakeRequest request){
            throw unimplementedMethodException(takeMethod);
        }

        @Override
        public CancelResponse cancel(CancelRequest request){
            throw unimplementedMethodException(cancelMethod);
        }

        @Override
        public com.ywt.gapi.third.taihe.GetDiagnoseRecordResponse getDiagnoseRecord(com.ywt.gapi.third.taihe.GetDiagnoseRecordRequest request){
            throw unimplementedMethodException(getDiagnoseRecordMethod);
        }

        @Override
        public RegisterResponse register(RegisterRequest request){
            throw unimplementedMethodException(registerMethod);
        }





        @Override
        public final ServiceDescriptor getServiceDescriptor() {
            return serviceDescriptor;
        }
        private RpcException unimplementedMethodException(StubMethodDescriptor methodDescriptor) {
            return TriRpcStatus.UNIMPLEMENTED.withDescription(String.format("Method %s is unimplemented",
                "/" + serviceDescriptor.getInterfaceName() + "/" + methodDescriptor.getMethodName())).asException();
        }
    }

}
