void (String expressionText, List<SwitchStatementBranch.LabelElement> caseElements, boolean firstBranch, boolean useEquals, boolean useRequireNonNullMethod, CommentTracker commentTracker, @NonNls StringBuilder out) { out.append("if("); boolean firstCaseValue = true; for (SwitchStatementBranch.LabelElement element : caseElements) { if (!firstCaseValue) { out.append("||"); } final String newExpressionText = firstBranch && firstCaseValue && useRequireNonNullMethod ? "java.util.Objects.requireNonNull(" + expressionText + ")" : expressionText; firstCaseValue = false; PsiCaseLabelElement caseElement = element.element(); if (caseElement instanceof PsiExpression) { PsiExpression caseExpression = PsiUtil.skipParenthesizedExprDown((PsiExpression)caseElement); String caseValue = getCaseValueText(caseExpression, commentTracker); if (useEquals && caseExpression != null && !(caseExpression.getType() instanceof PsiPrimitiveType)) { if (PsiPrecedenceUtil.getPrecedence(caseExpression) > PsiPrecedenceUtil.METHOD_CALL_PRECEDENCE) { caseValue = "(" + caseValue + ")"; } out.append(expressionText).append(".equals(").append(caseValue).append(')'); } else if (caseValue.equals("true")) { out.append(newExpressionText); } else if (caseValue.equals("false")) { out.append("!(").append(newExpressionText).append(")"); } else { out.append(newExpressionText).append("==").append(caseValue); } } else { final String patternCondition; PsiExpression guard = element.guard(); if (caseElement instanceof PsiPattern pattern) { patternCondition = createIfCondition(pattern, guard, newExpressionText, commentTracker); } else { patternCondition = null; } if (patternCondition != null) { out.append(patternCondition); } else { //incomplete/red code out.append(caseElement.getText()); } } } out.append(')'); }