@Override public void run() { Preconditions.checkArgument( !ran, "%s:%s: only one field of OutputSpec may be set", context.getMethodModel().getSimpleName(), valueSet.getId()); ran = true; } };
@Override public String getStaticLangReturnTypeName(MethodContext methodContext) { return methodContext .getMethodModel() .getOutputTypeName(methodContext.getTypeTable()) .getFullName(); }
@Override public String getAndSavePagedResponseTypeName( MethodContext methodContext, FieldConfig resourcesFieldConfig) { return methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); }
/** The name of the return type of the given grpc streaming method. */ public String getGrpcStreamingApiReturnTypeName( MethodContext methodContext, ImportTypeTable typeTable) { return publicClassName( Name.upperCamel(methodContext.getMethodModel().getOutputTypeSimpleName())); }
@Override public String getModifyMethodName(MethodContext methodContext) { String[] nameParts = methodContext .getMethodModel() .getInputTypeName(methodContext.getTypeTable()) .getNickname() .split("::"); String name = nameParts[nameParts.length - 1]; return "Modify_" + privateMethodName(Name.upperCamel(name)); }
@Override public String getGenericAwareResponseTypeName(MethodContext methodContext) { MethodModel method = methodContext.getMethodModel(); if (method.isOutputTypeEmpty()) { return "Void"; } else { return method.getOutputTypeName(methodContext.getTypeTable()).getFullName(); } }
@Override public String getStaticLangReturnTypeName(MethodContext methodContext) { MethodModel method = methodContext.getMethodModel(); if (method.isOutputTypeEmpty()) { return "void"; } return method.getOutputTypeName(methodContext.getTypeTable()).getFullName(); }
@Override public String getStaticLangAsyncReturnTypeName(MethodContext methodContext) { MethodModel method = methodContext.getMethodModel(); if (method.isOutputTypeEmpty()) { return "System.Threading.Tasks.Task"; } return "System.Threading.Tasks.Task<" + method.getOutputTypeName(methodContext.getTypeTable()).getFullName() + ">"; }
@Override public String getStaticLangReturnTypeName(MethodContext methodContext) { MethodModel method = methodContext.getMethodModel(); if (method.isOutputTypeEmpty()) { return "void"; } return method.getOutputTypeName(methodContext.getTypeTable()).getFullName(); }
@Override protected void setServiceResponseTypeName( MethodContext context, StaticLangApiMethodView.Builder methodViewBuilder) { String responseTypeName = context .getMethodModel() .getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()); methodViewBuilder.serviceResponseTypeName(responseTypeName); }
@Override public String getDynamicLangReturnTypeName(MethodContext methodContext) { MethodModel method = methodContext.getMethodModel(); if (method.isOutputTypeEmpty()) { return ""; } return method.getOutputTypeName(methodContext.getTypeTable()).getFullName(); }
public List<SimpleParamDocView> getRequestObjectParamDocs(MethodContext context) { MethodModel method = context.getMethodModel(); SimpleParamDocView doc = SimpleParamDocView.newBuilder() .paramName("request") .typeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer())) .lines( Arrays.<String>asList( "The request object containing all of the parameters for the API call.")) .build(); return ImmutableList.of(doc); } }
@Override public String getGrpcStreamingApiReturnTypeName( MethodContext methodContext, ImportTypeTable typeTable) { // Unsafe string manipulation: The name looks like "LibraryService_StreamShelvesClient", // neither camel or underscore. MethodModel method = methodContext.getMethodModel(); return method.getParentNickname(converter) + "_" + publicClassName(Name.upperCamel(method.getSimpleName()).join("client")); }
@Override public String getAndSavePagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { ImportTypeTable typeTable = methodContext.getTypeTable(); String inputTypeName = methodContext .getMethodModel() .getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String outputTypeName = methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig); return typeTable.getAndSaveNicknameForContainer( "Google.Api.Gax.PagedEnumerable", inputTypeName, outputTypeName, resourceTypeName); }
@Override public String getAndSaveCallerPagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { ImportTypeTable typeTable = methodContext.getTypeTable(); String outputTypeName = methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig); return typeTable.getAndSaveNicknameForContainer( "Google.Api.Gax.PagedEnumerable", outputTypeName, resourceTypeName); }
@Override public String getAndSaveCallerAsyncPagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { ImportTypeTable typeTable = methodContext.getTypeTable(); String outputTypeName = methodContext .getMethodModel() .getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer()); String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig); return typeTable.getAndSaveNicknameForContainer( "Google.Api.Gax.PagedAsyncEnumerable", outputTypeName, resourceTypeName); }
@Before public void setUp() { valueSet = SampleValueSet.newBuilder().setId("test-sample-value-set-id").build(); parent = new OutputTransformer.ScopeTable(); child = new OutputTransformer.ScopeTable(parent); MockitoAnnotations.initMocks(this); when(context.getFeatureConfig()).thenReturn(featureConfig); when(context.getMethodConfig()).thenReturn(config); when(context.getMethodModel()).thenReturn(model); when(context.getNamer()).thenReturn(namer); when(context.getTypeTable()).thenReturn(typeTable); when(model.getSimpleName()).thenReturn("methodSimpleName"); when(namer.getSampleResponseVarName(context)).thenReturn("sampleResponseVarName"); }
@Override public String getAndSavePagedResponseTypeName( MethodContext methodContext, FieldConfig resourceFieldConfig) { // TODO(michaelbausor) make sure this uses the typeTable correctly ImportTypeTable typeTable = methodContext.getTypeTable(); String fullPackageWrapperName = typeTable.getImplicitPackageFullNameFor( getApiWrapperClassName(methodContext.getInterfaceConfig())); String pagedResponseShortName = getPagedResponseTypeInnerName( methodContext.getMethodModel(), typeTable, resourceFieldConfig.getField()); return typeTable.getAndSaveNicknameForInnerType(fullPackageWrapperName, pagedResponseShortName); }
public StaticLangApiMethodView generatePagedCallableMethod(MethodContext context) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder(); setCommonFields(context, methodViewBuilder); methodViewBuilder.name(namer.getPagedCallableMethodName(method)); methodViewBuilder.exampleName(namer.getPagedCallableMethodExampleName(method)); setListMethodFields(context, Synchronicity.Sync, methodViewBuilder); setCallableMethodFields( context, namer.getPagedCallableName(method), methodViewBuilder, Arrays.asList(CallingForm.CallablePaged)); return methodViewBuilder.type(ClientMethodType.PagedCallableMethod).build(); }
private void setCommonApiCallableFields( MethodContext context, ApiCallableView.Builder apiCallableBuilder) { MethodModel method = context.getMethodModel(); SurfaceNamer namer = context.getNamer(); MethodConfig methodConfig = context.getMethodConfig(); apiCallableBuilder.methodName( namer.getApiMethodName(method, context.getMethodConfig().getVisibility())); apiCallableBuilder.asyncMethodName( namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC)); apiCallableBuilder.memberName(namer.getSettingsMemberName(method)); apiCallableBuilder.settingsFunctionName(namer.getSettingsFunctionName(method)); apiCallableBuilder.grpcClientVarName(namer.getReroutedGrpcClientVarName(methodConfig)); apiCallableBuilder.transportSettingsVar(namer.getTransportSettingsVar(method)); apiCallableBuilder.httpMethod(generateHttpFields(context)); }