void (@NotNull Project project, @NotNull PsiElement comparisonToken, @NotNull ModPsiUpdater updater) { final PsiElement parent = comparisonToken.getParent(); if (!(parent instanceof PsiBinaryExpression expression)) { return; } final PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(expression.getLOperand()); final PsiExpression rhs = PsiUtil.skipParenthesizedExprDown(expression.getROperand()); if (lhs == null || rhs == null) { return; } CommentTracker tracker = new CommentTracker(); final String lhsText = tracker.text(lhs); final String rhsText = tracker.text(rhs); @NonNls final StringBuilder newExpression = new StringBuilder(); if (PsiUtil.isLanguageLevel7OrHigher(expression) && ClassUtils.findClass("java.util.Objects", expression) != null) { if (JavaTokenType.NE.equals(expression.getOperationTokenType())) { newExpression.append('!'); } newExpression.append("java.util.Objects.equals(").append(lhsText).append(',').append(rhsText).append(')'); } else { newExpression.append(lhsText).append("==null?").append(rhsText).append(expression.getOperationSign().getText()).append(" null:"); if (JavaTokenType.NE.equals(expression.getOperationTokenType())) { newExpression.append('!'); } if (ParenthesesUtils.getPrecedence(lhs) > ParenthesesUtils.METHOD_CALL_PRECEDENCE) { newExpression.append('(').append(lhsText).append(')'); } else { newExpression.append(lhsText); } newExpression.append(".equals(").append(rhsText).append(')'); } PsiReplacementUtil.replaceExpressionAndShorten(expression, newExpression.toString(), tracker); }