ConditionalExpressionGenerator (PsiExpression condition, PsiExpression thenExpression, PsiExpression elseExpression, Boolean thenValue, Boolean elseValue) { if (thenValue != null) { if (thenValue) { return new ConditionalExpressionGenerator("||", ct -> joinConditions(condition, elseExpression, false, ct)); } return new ConditionalExpressionGenerator("&&", ct -> BoolUtils.getNegatedExpressionText(condition, ParenthesesUtils.AND_PRECEDENCE, ct) + " && " + ct.text(elseExpression, ParenthesesUtils.AND_PRECEDENCE)); } if (!elseValue) { return new ConditionalExpressionGenerator("&&", ct -> joinConditions(condition, thenExpression, true, ct)); } return new ConditionalExpressionGenerator("||", ct -> BoolUtils.getNegatedExpressionText(condition, ParenthesesUtils.OR_PRECEDENCE, ct) + " || " + ct.text(thenExpression, ParenthesesUtils.OR_PRECEDENCE)); }