|
24 | 24 | import com.google.api.gax.grpc.GrpcStubCallableFactory; |
25 | 25 | import com.google.api.gax.rpc.ClientContext; |
26 | 26 | import com.google.api.gax.rpc.OperationCallable; |
27 | | -import com.google.api.gax.rpc.RequestParamsExtractor; |
28 | 27 | import com.google.api.gax.rpc.UnaryCallable; |
29 | 28 | import com.google.cloud.translate.v3.BatchTranslateMetadata; |
30 | 29 | import com.google.cloud.translate.v3.BatchTranslateResponse; |
|
50 | 49 | import io.grpc.MethodDescriptor; |
51 | 50 | import io.grpc.protobuf.ProtoUtils; |
52 | 51 | import java.io.IOException; |
53 | | -import java.util.Map; |
54 | 52 | import java.util.concurrent.TimeUnit; |
55 | 53 | import javax.annotation.Generated; |
56 | 54 |
|
@@ -213,107 +211,83 @@ protected GrpcTranslationServiceStub( |
213 | 211 | GrpcCallSettings.<TranslateTextRequest, TranslateTextResponse>newBuilder() |
214 | 212 | .setMethodDescriptor(translateTextMethodDescriptor) |
215 | 213 | .setParamsExtractor( |
216 | | - new RequestParamsExtractor<TranslateTextRequest>() { |
217 | | - @Override |
218 | | - public Map<String, String> extract(TranslateTextRequest request) { |
219 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
220 | | - params.put("parent", String.valueOf(request.getParent())); |
221 | | - return params.build(); |
222 | | - } |
| 214 | + request -> { |
| 215 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 216 | + params.put("parent", String.valueOf(request.getParent())); |
| 217 | + return params.build(); |
223 | 218 | }) |
224 | 219 | .build(); |
225 | 220 | GrpcCallSettings<DetectLanguageRequest, DetectLanguageResponse> |
226 | 221 | detectLanguageTransportSettings = |
227 | 222 | GrpcCallSettings.<DetectLanguageRequest, DetectLanguageResponse>newBuilder() |
228 | 223 | .setMethodDescriptor(detectLanguageMethodDescriptor) |
229 | 224 | .setParamsExtractor( |
230 | | - new RequestParamsExtractor<DetectLanguageRequest>() { |
231 | | - @Override |
232 | | - public Map<String, String> extract(DetectLanguageRequest request) { |
233 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
234 | | - params.put("parent", String.valueOf(request.getParent())); |
235 | | - return params.build(); |
236 | | - } |
| 225 | + request -> { |
| 226 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 227 | + params.put("parent", String.valueOf(request.getParent())); |
| 228 | + return params.build(); |
237 | 229 | }) |
238 | 230 | .build(); |
239 | 231 | GrpcCallSettings<GetSupportedLanguagesRequest, SupportedLanguages> |
240 | 232 | getSupportedLanguagesTransportSettings = |
241 | 233 | GrpcCallSettings.<GetSupportedLanguagesRequest, SupportedLanguages>newBuilder() |
242 | 234 | .setMethodDescriptor(getSupportedLanguagesMethodDescriptor) |
243 | 235 | .setParamsExtractor( |
244 | | - new RequestParamsExtractor<GetSupportedLanguagesRequest>() { |
245 | | - @Override |
246 | | - public Map<String, String> extract(GetSupportedLanguagesRequest request) { |
247 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
248 | | - params.put("parent", String.valueOf(request.getParent())); |
249 | | - return params.build(); |
250 | | - } |
| 236 | + request -> { |
| 237 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 238 | + params.put("parent", String.valueOf(request.getParent())); |
| 239 | + return params.build(); |
251 | 240 | }) |
252 | 241 | .build(); |
253 | 242 | GrpcCallSettings<BatchTranslateTextRequest, Operation> batchTranslateTextTransportSettings = |
254 | 243 | GrpcCallSettings.<BatchTranslateTextRequest, Operation>newBuilder() |
255 | 244 | .setMethodDescriptor(batchTranslateTextMethodDescriptor) |
256 | 245 | .setParamsExtractor( |
257 | | - new RequestParamsExtractor<BatchTranslateTextRequest>() { |
258 | | - @Override |
259 | | - public Map<String, String> extract(BatchTranslateTextRequest request) { |
260 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
261 | | - params.put("parent", String.valueOf(request.getParent())); |
262 | | - return params.build(); |
263 | | - } |
| 246 | + request -> { |
| 247 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 248 | + params.put("parent", String.valueOf(request.getParent())); |
| 249 | + return params.build(); |
264 | 250 | }) |
265 | 251 | .build(); |
266 | 252 | GrpcCallSettings<CreateGlossaryRequest, Operation> createGlossaryTransportSettings = |
267 | 253 | GrpcCallSettings.<CreateGlossaryRequest, Operation>newBuilder() |
268 | 254 | .setMethodDescriptor(createGlossaryMethodDescriptor) |
269 | 255 | .setParamsExtractor( |
270 | | - new RequestParamsExtractor<CreateGlossaryRequest>() { |
271 | | - @Override |
272 | | - public Map<String, String> extract(CreateGlossaryRequest request) { |
273 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
274 | | - params.put("parent", String.valueOf(request.getParent())); |
275 | | - return params.build(); |
276 | | - } |
| 256 | + request -> { |
| 257 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 258 | + params.put("parent", String.valueOf(request.getParent())); |
| 259 | + return params.build(); |
277 | 260 | }) |
278 | 261 | .build(); |
279 | 262 | GrpcCallSettings<ListGlossariesRequest, ListGlossariesResponse> |
280 | 263 | listGlossariesTransportSettings = |
281 | 264 | GrpcCallSettings.<ListGlossariesRequest, ListGlossariesResponse>newBuilder() |
282 | 265 | .setMethodDescriptor(listGlossariesMethodDescriptor) |
283 | 266 | .setParamsExtractor( |
284 | | - new RequestParamsExtractor<ListGlossariesRequest>() { |
285 | | - @Override |
286 | | - public Map<String, String> extract(ListGlossariesRequest request) { |
287 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
288 | | - params.put("parent", String.valueOf(request.getParent())); |
289 | | - return params.build(); |
290 | | - } |
| 267 | + request -> { |
| 268 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 269 | + params.put("parent", String.valueOf(request.getParent())); |
| 270 | + return params.build(); |
291 | 271 | }) |
292 | 272 | .build(); |
293 | 273 | GrpcCallSettings<GetGlossaryRequest, Glossary> getGlossaryTransportSettings = |
294 | 274 | GrpcCallSettings.<GetGlossaryRequest, Glossary>newBuilder() |
295 | 275 | .setMethodDescriptor(getGlossaryMethodDescriptor) |
296 | 276 | .setParamsExtractor( |
297 | | - new RequestParamsExtractor<GetGlossaryRequest>() { |
298 | | - @Override |
299 | | - public Map<String, String> extract(GetGlossaryRequest request) { |
300 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
301 | | - params.put("name", String.valueOf(request.getName())); |
302 | | - return params.build(); |
303 | | - } |
| 277 | + request -> { |
| 278 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 279 | + params.put("name", String.valueOf(request.getName())); |
| 280 | + return params.build(); |
304 | 281 | }) |
305 | 282 | .build(); |
306 | 283 | GrpcCallSettings<DeleteGlossaryRequest, Operation> deleteGlossaryTransportSettings = |
307 | 284 | GrpcCallSettings.<DeleteGlossaryRequest, Operation>newBuilder() |
308 | 285 | .setMethodDescriptor(deleteGlossaryMethodDescriptor) |
309 | 286 | .setParamsExtractor( |
310 | | - new RequestParamsExtractor<DeleteGlossaryRequest>() { |
311 | | - @Override |
312 | | - public Map<String, String> extract(DeleteGlossaryRequest request) { |
313 | | - ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
314 | | - params.put("name", String.valueOf(request.getName())); |
315 | | - return params.build(); |
316 | | - } |
| 287 | + request -> { |
| 288 | + ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); |
| 289 | + params.put("name", String.valueOf(request.getName())); |
| 290 | + return params.build(); |
317 | 291 | }) |
318 | 292 | .build(); |
319 | 293 |
|
@@ -443,7 +417,13 @@ public UnaryCallable<DeleteGlossaryRequest, Operation> deleteGlossaryCallable() |
443 | 417 |
|
444 | 418 | @Override |
445 | 419 | public final void close() { |
446 | | - shutdown(); |
| 420 | + try { |
| 421 | + backgroundResources.close(); |
| 422 | + } catch (RuntimeException e) { |
| 423 | + throw e; |
| 424 | + } catch (Exception e) { |
| 425 | + throw new IllegalStateException("Failed to close resource", e); |
| 426 | + } |
447 | 427 | } |
448 | 428 |
|
449 | 429 | @Override |
|
0 commit comments