use of com.google.api.generator.gapic.composer.comment.StubCommentComposer in project gapic-generator-java by googleapis.
the class AbstractTransportServiceStubClassComposer method generate.
@Override
public GapicClass generate(GapicContext context, Service service) {
String pakkage = service.pakkage() + ".stub";
TypeStore typeStore = createDynamicTypes(service, pakkage);
String className = getTransportContext().classNames().getTransportServiceStubClassName(service);
GapicClass.Kind kind = Kind.STUB;
Map<String, VariableExpr> protoMethodNameToDescriptorVarExprs = createProtoMethodNameToDescriptorClassMembers(service, getTransportContext().methodDescriptorClass());
Map<String, VariableExpr> callableClassMemberVarExprs = createCallableClassMembers(service, typeStore);
Map<String, VariableExpr> classMemberVarExprs = new LinkedHashMap<>();
classMemberVarExprs.put(BACKGROUND_RESOURCES_MEMBER_NAME, VariableExpr.withVariable(Variable.builder().setName(BACKGROUND_RESOURCES_MEMBER_NAME).setType(FIXED_TYPESTORE.get("BackgroundResource")).build()));
if (generateOperationsStubLogic(service)) {
// Transport-specific service stub may have only one element of the following, thus get(0).
TypeNode operationsStubType = getTransportOperationsStubType(service);
classMemberVarExprs.put(getTransportContext().transportOperationsStubNames().get(0), VariableExpr.withVariable(Variable.builder().setName(getTransportContext().transportOperationsStubNames().get(0)).setType(operationsStubType).build()));
}
boolean operationPollingMethod = checkOperationPollingMethod(service);
if (operationPollingMethod) {
VariableExpr longRunningVarExpr = declareLongRunningClient();
if (longRunningVarExpr != null) {
classMemberVarExprs.put("longRunningClient", longRunningVarExpr);
}
}
classMemberVarExprs.put(CALLABLE_FACTORY_MEMBER_NAME, VariableExpr.withVariable(Variable.builder().setName(CALLABLE_FACTORY_MEMBER_NAME).setType(getTransportContext().stubCallableFactoryType()).build()));
Map<String, Message> messageTypes = context.messages();
List<Statement> classStatements = createClassStatements(service, protoMethodNameToDescriptorVarExprs, callableClassMemberVarExprs, classMemberVarExprs, messageTypes);
StubCommentComposer commentComposer = new StubCommentComposer(getTransportContext().transportName());
ClassDefinition classDef = ClassDefinition.builder().setPackageString(pakkage).setHeaderCommentStatements(commentComposer.createTransportServiceStubClassHeaderComments(service.name(), service.isDeprecated())).setAnnotations(createClassAnnotations(service)).setScope(ScopeNode.PUBLIC).setName(className).setExtendsType(typeStore.get(getTransportContext().classNames().getServiceStubClassName(service))).setMethods(createClassMethods(context, service, typeStore, classMemberVarExprs, callableClassMemberVarExprs, protoMethodNameToDescriptorVarExprs, classStatements)).setStatements(classStatements).build();
return GapicClass.create(kind, classDef);
}
use of com.google.api.generator.gapic.composer.comment.StubCommentComposer in project gapic-generator-java by googleapis.
the class AbstractServiceCallableFactoryClassComposer method generate.
@Override
public GapicClass generate(GapicContext context, Service service) {
TypeStore typeStore = createTypes(service);
String className = getTransportContext().classNames().getTransportServiceCallableFactoryClassName(service);
GapicClass.Kind kind = Kind.STUB;
String pakkage = String.format("%s.stub", service.pakkage());
StubCommentComposer commentComposer = new StubCommentComposer(getTransportContext().transportName());
ClassDefinition classDef = ClassDefinition.builder().setPackageString(pakkage).setHeaderCommentStatements(commentComposer.createTransportServiceCallableFactoryClassHeaderComments(service.name(), service.isDeprecated())).setAnnotations(createClassAnnotations(service, typeStore)).setImplementsTypes(createClassImplements(service, typeStore)).setName(className).setMethods(createClassMethods(service, typeStore)).setScope(ScopeNode.PUBLIC).build();
return GapicClass.create(kind, classDef);
}
Aggregations