1 // Copyright 2020 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package com.google.api.generator.gapic.model; 16 17 import com.google.auto.value.AutoValue; 18 import com.google.common.collect.ImmutableMap; 19 import java.util.Collections; 20 import java.util.Map; 21 22 /** Represents the LRO retry settings in a gapic.yaml file. */ 23 @AutoValue 24 public abstract class GapicLanguageSettings { 25 // The Java package mapping. pakkage()26 public abstract String pakkage(); 27 28 // Private. protoServiceToJavaClassname()29 abstract ImmutableMap<String, String> protoServiceToJavaClassname(); 30 getJavaServiceName(String protoPackage, String protoServiceName)31 public String getJavaServiceName(String protoPackage, String protoServiceName) { 32 String protoFullName = String.format("%s.%s", protoPackage, protoServiceName); 33 String finalProtoRpcName = protoServiceName; 34 if (protoServiceToJavaClassname().containsKey(protoFullName)) { 35 finalProtoRpcName = protoServiceToJavaClassname().get(protoFullName); 36 } 37 return finalProtoRpcName; 38 } 39 builder()40 public static Builder builder() { 41 return new AutoValue_GapicLanguageSettings.Builder() 42 .setProtoServiceToJavaClassname(Collections.emptyMap()); 43 } 44 45 @AutoValue.Builder 46 public abstract static class Builder { setPakkage(String pakkage)47 public abstract Builder setPakkage(String pakkage); 48 setProtoServiceToJavaClassname( Map<String, String> protoServiceToJavaClassname)49 public abstract Builder setProtoServiceToJavaClassname( 50 Map<String, String> protoServiceToJavaClassname); 51 build()52 public abstract GapicLanguageSettings build(); 53 } 54 } 55