|
| 1 | +package com.google.selective.generate.v1beta1.stub; |
| 2 | + |
| 3 | +import com.google.api.core.BetaApi; |
| 4 | +import com.google.api.gax.core.BackgroundResource; |
| 5 | +import com.google.api.gax.core.BackgroundResourceAggregation; |
| 6 | +import com.google.api.gax.grpc.GrpcCallSettings; |
| 7 | +import com.google.api.gax.grpc.GrpcStubCallableFactory; |
| 8 | +import com.google.api.gax.rpc.BidiStreamingCallable; |
| 9 | +import com.google.api.gax.rpc.ClientContext; |
| 10 | +import com.google.api.gax.rpc.UnaryCallable; |
| 11 | +import com.google.longrunning.stub.GrpcOperationsStub; |
| 12 | +import com.google.selective.generate.v1beta1.EchoRequest; |
| 13 | +import com.google.selective.generate.v1beta1.EchoResponse; |
| 14 | +import io.grpc.MethodDescriptor; |
| 15 | +import io.grpc.protobuf.ProtoUtils; |
| 16 | +import java.io.IOException; |
| 17 | +import java.util.concurrent.TimeUnit; |
| 18 | +import javax.annotation.Generated; |
| 19 | + |
| 20 | +// AUTO-GENERATED DOCUMENTATION AND CLASS. |
| 21 | +/** |
| 22 | + * gRPC stub implementation for the EchoServiceShouldGeneratePartial service API. |
| 23 | + * |
| 24 | + * <p>This class is for advanced usage and reflects the underlying API directly. |
| 25 | + */ |
| 26 | +@BetaApi |
| 27 | +@Generated("by gapic-generator-java") |
| 28 | +public class GrpcEchoServiceShouldGeneratePartialStub extends EchoServiceShouldGeneratePartialStub { |
| 29 | + private static final MethodDescriptor<EchoRequest, EchoResponse> |
| 30 | + echoShouldIncludeMethodDescriptor = |
| 31 | + MethodDescriptor.<EchoRequest, EchoResponse>newBuilder() |
| 32 | + .setType(MethodDescriptor.MethodType.UNARY) |
| 33 | + .setFullMethodName( |
| 34 | + "google.selective.generate.v1beta1.EchoServiceShouldGeneratePartial/EchoShouldInclude") |
| 35 | + .setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance())) |
| 36 | + .setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance())) |
| 37 | + .build(); |
| 38 | + |
| 39 | + private static final MethodDescriptor<EchoRequest, EchoResponse> |
| 40 | + chatShouldIncludeMethodDescriptor = |
| 41 | + MethodDescriptor.<EchoRequest, EchoResponse>newBuilder() |
| 42 | + .setType(MethodDescriptor.MethodType.BIDI_STREAMING) |
| 43 | + .setFullMethodName( |
| 44 | + "google.selective.generate.v1beta1.EchoServiceShouldGeneratePartial/ChatShouldInclude") |
| 45 | + .setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance())) |
| 46 | + .setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance())) |
| 47 | + .build(); |
| 48 | + |
| 49 | + private static final MethodDescriptor<EchoRequest, EchoResponse> |
| 50 | + chatAgainShouldIncludeMethodDescriptor = |
| 51 | + MethodDescriptor.<EchoRequest, EchoResponse>newBuilder() |
| 52 | + .setType(MethodDescriptor.MethodType.BIDI_STREAMING) |
| 53 | + .setFullMethodName( |
| 54 | + "google.selective.generate.v1beta1.EchoServiceShouldGeneratePartial/ChatAgainShouldInclude") |
| 55 | + .setRequestMarshaller(ProtoUtils.marshaller(EchoRequest.getDefaultInstance())) |
| 56 | + .setResponseMarshaller(ProtoUtils.marshaller(EchoResponse.getDefaultInstance())) |
| 57 | + .build(); |
| 58 | + |
| 59 | + private final UnaryCallable<EchoRequest, EchoResponse> echoShouldIncludeCallable; |
| 60 | + private final BidiStreamingCallable<EchoRequest, EchoResponse> chatShouldIncludeCallable; |
| 61 | + private final BidiStreamingCallable<EchoRequest, EchoResponse> chatAgainShouldIncludeCallable; |
| 62 | + |
| 63 | + private final BackgroundResource backgroundResources; |
| 64 | + private final GrpcOperationsStub operationsStub; |
| 65 | + private final GrpcStubCallableFactory callableFactory; |
| 66 | + |
| 67 | + public static final GrpcEchoServiceShouldGeneratePartialStub create( |
| 68 | + EchoServiceShouldGeneratePartialStubSettings settings) throws IOException { |
| 69 | + return new GrpcEchoServiceShouldGeneratePartialStub(settings, ClientContext.create(settings)); |
| 70 | + } |
| 71 | + |
| 72 | + public static final GrpcEchoServiceShouldGeneratePartialStub create(ClientContext clientContext) |
| 73 | + throws IOException { |
| 74 | + return new GrpcEchoServiceShouldGeneratePartialStub( |
| 75 | + EchoServiceShouldGeneratePartialStubSettings.newBuilder().build(), clientContext); |
| 76 | + } |
| 77 | + |
| 78 | + public static final GrpcEchoServiceShouldGeneratePartialStub create( |
| 79 | + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { |
| 80 | + return new GrpcEchoServiceShouldGeneratePartialStub( |
| 81 | + EchoServiceShouldGeneratePartialStubSettings.newBuilder().build(), |
| 82 | + clientContext, |
| 83 | + callableFactory); |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Constructs an instance of GrpcEchoServiceShouldGeneratePartialStub, using the given settings. |
| 88 | + * This is protected so that it is easy to make a subclass, but otherwise, the static factory |
| 89 | + * methods should be preferred. |
| 90 | + */ |
| 91 | + protected GrpcEchoServiceShouldGeneratePartialStub( |
| 92 | + EchoServiceShouldGeneratePartialStubSettings settings, ClientContext clientContext) |
| 93 | + throws IOException { |
| 94 | + this(settings, clientContext, new GrpcEchoServiceShouldGeneratePartialCallableFactory()); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Constructs an instance of GrpcEchoServiceShouldGeneratePartialStub, using the given settings. |
| 99 | + * This is protected so that it is easy to make a subclass, but otherwise, the static factory |
| 100 | + * methods should be preferred. |
| 101 | + */ |
| 102 | + protected GrpcEchoServiceShouldGeneratePartialStub( |
| 103 | + EchoServiceShouldGeneratePartialStubSettings settings, |
| 104 | + ClientContext clientContext, |
| 105 | + GrpcStubCallableFactory callableFactory) |
| 106 | + throws IOException { |
| 107 | + this.callableFactory = callableFactory; |
| 108 | + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); |
| 109 | + |
| 110 | + GrpcCallSettings<EchoRequest, EchoResponse> echoShouldIncludeTransportSettings = |
| 111 | + GrpcCallSettings.<EchoRequest, EchoResponse>newBuilder() |
| 112 | + .setMethodDescriptor(echoShouldIncludeMethodDescriptor) |
| 113 | + .build(); |
| 114 | + GrpcCallSettings<EchoRequest, EchoResponse> chatShouldIncludeTransportSettings = |
| 115 | + GrpcCallSettings.<EchoRequest, EchoResponse>newBuilder() |
| 116 | + .setMethodDescriptor(chatShouldIncludeMethodDescriptor) |
| 117 | + .build(); |
| 118 | + GrpcCallSettings<EchoRequest, EchoResponse> chatAgainShouldIncludeTransportSettings = |
| 119 | + GrpcCallSettings.<EchoRequest, EchoResponse>newBuilder() |
| 120 | + .setMethodDescriptor(chatAgainShouldIncludeMethodDescriptor) |
| 121 | + .build(); |
| 122 | + |
| 123 | + this.echoShouldIncludeCallable = |
| 124 | + callableFactory.createUnaryCallable( |
| 125 | + echoShouldIncludeTransportSettings, |
| 126 | + settings.echoShouldIncludeSettings(), |
| 127 | + clientContext); |
| 128 | + this.chatShouldIncludeCallable = |
| 129 | + callableFactory.createBidiStreamingCallable( |
| 130 | + chatShouldIncludeTransportSettings, |
| 131 | + settings.chatShouldIncludeSettings(), |
| 132 | + clientContext); |
| 133 | + this.chatAgainShouldIncludeCallable = |
| 134 | + callableFactory.createBidiStreamingCallable( |
| 135 | + chatAgainShouldIncludeTransportSettings, |
| 136 | + settings.chatAgainShouldIncludeSettings(), |
| 137 | + clientContext); |
| 138 | + |
| 139 | + this.backgroundResources = |
| 140 | + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); |
| 141 | + } |
| 142 | + |
| 143 | + public GrpcOperationsStub getOperationsStub() { |
| 144 | + return operationsStub; |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public UnaryCallable<EchoRequest, EchoResponse> echoShouldIncludeCallable() { |
| 149 | + return echoShouldIncludeCallable; |
| 150 | + } |
| 151 | + |
| 152 | + @Override |
| 153 | + public BidiStreamingCallable<EchoRequest, EchoResponse> chatShouldIncludeCallable() { |
| 154 | + return chatShouldIncludeCallable; |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public BidiStreamingCallable<EchoRequest, EchoResponse> chatAgainShouldIncludeCallable() { |
| 159 | + return chatAgainShouldIncludeCallable; |
| 160 | + } |
| 161 | + |
| 162 | + @Override |
| 163 | + public final void close() { |
| 164 | + try { |
| 165 | + backgroundResources.close(); |
| 166 | + } catch (RuntimeException e) { |
| 167 | + throw e; |
| 168 | + } catch (Exception e) { |
| 169 | + throw new IllegalStateException("Failed to close resource", e); |
| 170 | + } |
| 171 | + } |
| 172 | + |
| 173 | + @Override |
| 174 | + public void shutdown() { |
| 175 | + backgroundResources.shutdown(); |
| 176 | + } |
| 177 | + |
| 178 | + @Override |
| 179 | + public boolean isShutdown() { |
| 180 | + return backgroundResources.isShutdown(); |
| 181 | + } |
| 182 | + |
| 183 | + @Override |
| 184 | + public boolean isTerminated() { |
| 185 | + return backgroundResources.isTerminated(); |
| 186 | + } |
| 187 | + |
| 188 | + @Override |
| 189 | + public void shutdownNow() { |
| 190 | + backgroundResources.shutdownNow(); |
| 191 | + } |
| 192 | + |
| 193 | + @Override |
| 194 | + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { |
| 195 | + return backgroundResources.awaitTermination(duration, unit); |
| 196 | + } |
| 197 | +} |
0 commit comments