@Override public boolean test(final SwitchSection s) { return !s.getCaseLabels().isEmpty() && all( s.getCaseLabels(), new Predicate<CaseLabel>() { @Override public boolean test(final CaseLabel c) { return c.getExpression().isNull() || (c.getExpression() instanceof PrimitiveExpression && ((PrimitiveExpression) c.getExpression()).getValue() instanceof Integer && tableInputMap.containsKey(((PrimitiveExpression) c.getExpression()).getValue())); } } ); } }
@Override public boolean test(final SwitchSection s) { return !s.getCaseLabels().isEmpty() && all( s.getCaseLabels(), new Predicate<CaseLabel>() { @Override public boolean test(final CaseLabel c) { return c.getExpression().isNull() || (c.getExpression() instanceof PrimitiveExpression && ((PrimitiveExpression) c.getExpression()).getValue() instanceof Integer && tableInputMap.containsKey(((PrimitiveExpression) c.getExpression()).getValue())); } } ); } }
@Override public boolean test(final SwitchSection s) { return !s.getCaseLabels().isEmpty() && all( s.getCaseLabels(), new Predicate<CaseLabel>() { @Override public boolean test(final CaseLabel c) { return c.getExpression().isNull() || (c.getExpression() instanceof PrimitiveExpression && ((PrimitiveExpression) c.getExpression()).getValue() instanceof Integer && tableInputMap.containsKey(((PrimitiveExpression) c.getExpression()).getValue())); } } ); } }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof SwitchSection) { final SwitchSection otherSection = (SwitchSection) other; return !otherSection.isNull() && getCaseLabels().matches(otherSection.getCaseLabels(), match) && getStatements().matches(otherSection.getStatements(), match); } return false; } }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof SwitchSection) { final SwitchSection otherSection = (SwitchSection) other; return !otherSection.isNull() && getCaseLabels().matches(otherSection.getCaseLabels(), match) && getStatements().matches(otherSection.getStatements(), match); } return false; } }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof SwitchSection) { final SwitchSection otherSection = (SwitchSection) other; return !otherSection.isNull() && getCaseLabels().matches(otherSection.getCaseLabels(), match) && getStatements().matches(otherSection.getStatements(), match); } return false; } }
for (final CaseLabel caseLabel : section.getCaseLabels()) { final Expression expression = caseLabel.getExpression();
for (final CaseLabel caseLabel : section.getCaseLabels()) { final Expression expression = caseLabel.getExpression();
for (final CaseLabel caseLabel : section.getCaseLabels()) { final Expression expression = caseLabel.getExpression();
for (final CaseLabel caseLabel : section.getCaseLabels()) { final Expression expression = caseLabel.getExpression();
for (final CaseLabel caseLabel : section.getCaseLabels()) { final Expression expression = caseLabel.getExpression();
for (final CaseLabel caseLabel : section.getCaseLabels()) { final Expression expression = caseLabel.getExpression();
for (final CaseLabel label : section.getCaseLabels()) { if (label.getExpression().isNull()) { defaultSection = section;
for (final CaseLabel label : section.getCaseLabels()) { if (label.getExpression().isNull()) { defaultSection = section;
for (final CaseLabel label : section.getCaseLabels()) { if (label.getExpression().isNull()) { defaultSection = section;
final AstNodeCollection<CaseLabel> caseLabels = section.getCaseLabels(); final IfElseStatement test = first(m.<IfElseStatement>get("test")); final List<PrimitiveExpression> stringValues = toList(m.<PrimitiveExpression>get("stringValue")); final AstNodeCollection<CaseLabel> caseLabels = section.getCaseLabels(); defaultSection.getCaseLabels().add(new CaseLabel()); defaultSection.getStatements().add(defaultBreak);
final AstNodeCollection<CaseLabel> caseLabels = section.getCaseLabels(); final IfElseStatement test = first(m.<IfElseStatement>get("test")); final List<PrimitiveExpression> stringValues = toList(m.<PrimitiveExpression>get("stringValue")); final AstNodeCollection<CaseLabel> caseLabels = section.getCaseLabels(); defaultSection.getCaseLabels().add(new CaseLabel()); defaultSection.getStatements().add(defaultBreak);
@Override public Void visitSwitchSection(final SwitchSection node, final Void ignored) { startNode(node); boolean first = true; for (final CaseLabel label : node.getCaseLabels()) { if (!first) { newLine(); } label.acceptVisitor(this, ignored); first = false; } final boolean isBlock = node.getStatements().size() == 1 && firstOrDefault(node.getStatements()) instanceof BlockStatement; if (policy.IndentCaseBody && !isBlock) { formatter.indent(); } if (!isBlock) { newLine(); } for (final Statement statement : node.getStatements()) { statement.acceptVisitor(this, ignored); } if (policy.IndentCaseBody && !isBlock) { formatter.unindent(); } endNode(node); return null; }
@Override public Void visitSwitchSection(final SwitchSection node, final Void ignored) { startNode(node); boolean first = true; for (final CaseLabel label : node.getCaseLabels()) { if (!first) { newLine(); } label.acceptVisitor(this, ignored); first = false; } final boolean isBlock = node.getStatements().size() == 1 && firstOrDefault(node.getStatements()) instanceof BlockStatement; if (policy.IndentCaseBody && !isBlock) { formatter.indent(); } if (!isBlock) { newLine(); } for (final Statement statement : node.getStatements()) { statement.acceptVisitor(this, ignored); } if (policy.IndentCaseBody && !isBlock) { formatter.unindent(); } endNode(node); return null; }
@Override public Void visitSwitchSection(final SwitchSection node, final Void ignored) { startNode(node); boolean first = true; for (final CaseLabel label : node.getCaseLabels()) { if (!first) { newLine(); } label.acceptVisitor(this, ignored); first = false; } final boolean isBlock = node.getStatements().size() == 1 && firstOrDefault(node.getStatements()) instanceof BlockStatement; if (policy.IndentCaseBody && !isBlock) { formatter.indent(); } if (!isBlock) { newLine(); } for (final Statement statement : node.getStatements()) { statement.acceptVisitor(this, ignored); } if (policy.IndentCaseBody && !isBlock) { formatter.unindent(); } endNode(node); return null; }