Search in sources :

Example 1 with ParseResourceFunctionView

use of com.google.api.codegen.viewmodel.ParseResourceFunctionView in project toolkit by googleapis.

the class PathTemplateTransformer method generateParseResourceFunctions.

public List<ParseResourceFunctionView> generateParseResourceFunctions(InterfaceContext context) {
    List<ParseResourceFunctionView> functions = new ArrayList<>();
    if (!context.getFeatureConfig().enableStringFormatFunctions()) {
        return functions;
    }
    SurfaceNamer namer = context.getNamer();
    InterfaceConfig interfaceConfig = context.getInterfaceConfig();
    for (SingleResourceNameConfig resourceNameConfig : getSingleResourceNameConfigsUsedByInterface(context)) {
        for (String var : resourceNameConfig.getNameTemplate().vars()) {
            ParseResourceFunctionView.Builder function = ParseResourceFunctionView.newBuilder().entityName(resourceNameConfig.getEntityName()).name(namer.getParseFunctionName(var, resourceNameConfig)).pathTemplateName(namer.getPathTemplateName(interfaceConfig, resourceNameConfig)).pathTemplateGetterName(namer.getPathTemplateNameGetter(interfaceConfig, resourceNameConfig)).entityNameParamName(namer.getEntityNameParamName(resourceNameConfig)).outputResourceId(var);
            functions.add(function.build());
        }
    }
    return functions;
}
Also used : InterfaceConfig(com.google.api.codegen.config.InterfaceConfig) ParseResourceFunctionView(com.google.api.codegen.viewmodel.ParseResourceFunctionView) ArrayList(java.util.ArrayList) SingleResourceNameConfig(com.google.api.codegen.config.SingleResourceNameConfig)

Aggregations

InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)1 SingleResourceNameConfig (com.google.api.codegen.config.SingleResourceNameConfig)1 ParseResourceFunctionView (com.google.api.codegen.viewmodel.ParseResourceFunctionView)1 ArrayList (java.util.ArrayList)1