• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc.cronet;
18 
19 import io.grpc.CallOptions;
20 import io.grpc.Internal;
21 import java.util.Collection;
22 import java.util.Collections;
23 
24 /**
25  * Internal accessor class for call options using with the Cronet transport. This is intended for
26  * usage internal to the gRPC team. If you *really* think you need to use this, contact the gRPC
27  * team first.
28  */
29 @Internal
30 public final class InternalCronetCallOptions {
31 
32   // Prevent instantiation
InternalCronetCallOptions()33   private InternalCronetCallOptions() {}
34 
withAnnotation(CallOptions callOptions, Object annotation)35   public static CallOptions withAnnotation(CallOptions callOptions, Object annotation) {
36     return CronetClientStream.withAnnotation(callOptions, annotation);
37   }
38 
39   /**
40    * Returns Cronet annotations for gRPC included in the given {@code callOptions}. Annotations
41    * are attached via {@link #withAnnotation(CallOptions, Object)}.
42    */
getAnnotations(CallOptions callOptions)43   public static Collection<Object> getAnnotations(CallOptions callOptions) {
44     Collection<Object> annotations =
45         callOptions.getOption(CronetClientStream.CRONET_ANNOTATIONS_KEY);
46     if (annotations == null) {
47       annotations = Collections.emptyList();
48     }
49     return annotations;
50   }
51 }
52