use of com.google.api.codegen.viewmodel.ResourceNameOneofInitValueView in project toolkit by googleapis.
the class TestCaseTransformer method requireProjectIdInSmokeTest.
private boolean requireProjectIdInSmokeTest(FieldSettingView settingsView, SurfaceNamer namer) {
InitCodeLineView line = settingsView.initCodeLine();
if (line.lineType() == InitCodeLineType.SimpleInitLine) {
SimpleInitCodeLineView simpleLine = (SimpleInitCodeLineView) line;
String projectVarName = namer.localVarReference(Name.from(InitFieldConfig.PROJECT_ID_VARIABLE_NAME));
if (simpleLine.initValue() instanceof ResourceNameInitValueView) {
ResourceNameInitValueView initValue = (ResourceNameInitValueView) simpleLine.initValue();
return initValue.formatArgs().contains(projectVarName);
} else if (simpleLine.initValue() instanceof ResourceNameOneofInitValueView) {
ResourceNameOneofInitValueView initValue = (ResourceNameOneofInitValueView) simpleLine.initValue();
ResourceNameInitValueView subValue = initValue.specificResourceNameView();
return subValue.formatArgs().contains(projectVarName);
} else if (simpleLine.initValue() instanceof SimpleInitValueView) {
SimpleInitValueView initValue = (SimpleInitValueView) simpleLine.initValue();
return initValue.initialValue().equals(projectVarName);
} else if (simpleLine.initValue() instanceof FormattedInitValueView) {
FormattedInitValueView initValue = (FormattedInitValueView) simpleLine.initValue();
return initValue.formatArgs().contains(projectVarName);
}
}
return false;
}
Aggregations