use of com.google.api.codegen.viewmodel.StaticLangStubInterfaceView in project toolkit by googleapis.
the class JavaSurfaceTransformer method transform.
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = surfaceTransformer.createSurfaceNamer(productConfig);
List<ServiceDocView> serviceDocs = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
boolean enableStringFormatFunctions = productConfig.getResourceNameMessageConfigs().isEmpty();
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
StaticLangFileView<StaticLangApiView> apiFile = generateApiFile(context, productConfig);
surfaceDocs.add(apiFile);
serviceDocs.add(apiFile.classView().doc());
StaticLangApiMethodView exampleApiMethod = getExampleApiMethod(apiFile.classView().apiMethods());
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubSettingsView> stubSettingsFile = generateStubSettingsFile(context, productConfig, exampleApiMethod);
context = context.withNewTypeTable(namer.getRootPackageName());
StaticLangFileView<StaticLangSettingsView> settingsFile = generateSettingsFile(context, productConfig, exampleApiMethod, stubSettingsFile.classView());
surfaceDocs.add(settingsFile);
surfaceDocs.add(stubSettingsFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangStubInterfaceView> stubInterfaceFile = generateStubInterfaceFile(context, productConfig);
surfaceDocs.add(stubInterfaceFile);
context = context.withNewTypeTable(namer.getStubPackageName());
StaticLangFileView<StaticLangRpcStubView> grpcStubFile = generateRpcStubClassFile(context, productConfig);
surfaceDocs.add(grpcStubFile);
surfaceDocs.add(generateCallableFactoryClassFile(context, productConfig));
}
PackageInfoView packageInfo = generatePackageInfo(model, productConfig, namer, serviceDocs);
surfaceDocs.add(packageInfo);
return surfaceDocs;
}
use of com.google.api.codegen.viewmodel.StaticLangStubInterfaceView in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateStubInterface.
private StaticLangStubInterfaceView generateStubInterface(InterfaceContext context, GapicProductConfig productConfig) {
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
addStubInterfaceImports(context);
// Stub class has different default package name from methods classes.
InterfaceContext apiMethodsContext = context.withNewTypeTable(context.getNamer().getRootPackageName());
List<StaticLangApiMethodView> methods = generateApiMethods(apiMethodsContext);
for (TypeAlias alias : apiMethodsContext.getImportTypeTable().getTypeTable().getAllImports().values()) {
context.getImportTypeTable().getAndSaveNicknameFor(alias);
}
StaticLangStubInterfaceView.Builder stubInterface = StaticLangStubInterfaceView.newBuilder();
stubInterface.doc(serviceTransformer.generateServiceDoc(context, null, productConfig));
String name = context.getNamer().getApiStubInterfaceName(context.getInterfaceConfig());
stubInterface.releaseLevelAnnotation(context.getNamer().getReleaseAnnotation(packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
stubInterface.name(name);
stubInterface.callableMethods(filterIncludeCallableMethods(methods));
stubInterface.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
return stubInterface.build();
}
Aggregations