@Override protected void visitSwitchNode(SwitchNode node) {
TranslateToJavaExprVisitor ttjev =
translateToJavaExprVisitorFactory.create(localVarTranslations);
JavaExpr switchValueJavaExpr = ttjev.exec(node.getExpr());
String switchValueVarName = "switchValue" + node.getId();
javaCodeBuilder.appendLine(
"com.google.template.soy.data.SoyData ", switchValueVarName, " = ",
switchValueJavaExpr.getText(), ";");
boolean isFirstCase = true;
for (SoyNode child : node.getChildren()) {
if (child instanceof SwitchCaseNode) {
SwitchCaseNode scn = (SwitchCaseNode) child;
StringBuilder conditionExprText = new StringBuilder();
boolean isFirstCaseValue = true;
for (ExprNode caseExpr : scn.getExprList()) {
JavaExpr caseJavaExpr = ttjev.exec(caseExpr);
if (isFirstCaseValue) {
isFirstCaseValue = false;
} else {
conditionExprText.append(" || ");
}
conditionExprText.append(switchValueVarName).append(".equals(")
.append(caseJavaExpr.getText()).append(')');
}
if (isFirstCase) {
isFirstCase = false;
javaCodeBuilder.appendLine("if (", conditionExprText.toString(), ") {");