use of com.google.api.codegen.config.ResourceNamePatternConfig in project toolkit by googleapis.
the class InitCodeTransformer method createResourceNameOneofInitValueView.
private ResourceNameOneofInitValueView createResourceNameOneofInitValueView(MethodContext context, FieldConfig fieldConfig, InitCodeNode item, boolean convertToString) {
ResourceNameOneofConfig oneofConfig = (ResourceNameOneofConfig) fieldConfig.getResourceNameConfig();
SurfaceNamer namer = context.getNamer();
ImportTypeTable typeTable = context.getTypeTable();
if (context.getFeatureConfig().useStaticCreateMethodForOneofs()) {
ResourceNamePatternConfig pattern = getMatchingResourceNamePattern(item, oneofConfig);
String createMethod = convertToString ? pattern.getFormatMethodName() : pattern.getCreateMethodName();
ImmutableList<String> formatArgs = getFormatFunctionArgs(context, ImmutableList.copyOf(pattern.getBindingVariables()), item.getInitValueConfig());
return ResourceNameOneofInitValueView.newBuilder().resourceOneofTypeName(namer.getAndSaveElementResourceTypeName(typeTable, fieldConfig)).createMethodName(createMethod).formatArgs(formatArgs).build();
} else {
SingleResourceNameConfig singleResourceNameConfig = getMatchingSingleResourceNameConfig(context, item, oneofConfig);
FieldConfig singleResourceNameFieldConfig = fieldConfig.withResourceNameConfig(singleResourceNameConfig);
ResourceNameInitValueView initView = createResourceNameInitValueView(context, singleResourceNameFieldConfig, item).convertToString(convertToString).build();
return ResourceNameOneofInitValueView.newBuilder().resourceOneofTypeName(namer.getAndSaveElementResourceTypeName(typeTable, fieldConfig)).specificResourceNameView(initView).build();
}
}
Aggregations