void (PsiMethodCallExpression countCall, boolean isPresent) { PsiBinaryExpression comparison = extractComparison(countCall, isPresent); if (comparison == null) return; PsiExpression countQualifier = countCall.getMethodExpression().getQualifierExpression(); if (countQualifier == null) return; String base = countQualifier.getText(); CommentTracker ct = new CommentTracker(); ct.markUnchanged(countQualifier); if (isPresent) { ct.replaceAndRestoreComments(comparison, base + "." + "findAny().isPresent()"); } else { if (PsiUtil.getLanguageLevel(countCall).isAtLeast(LanguageLevel.JDK_11)) { ct.replaceAndRestoreComments(comparison, base + "." + "findAny().isEmpty()"); } else { ct.replaceAndRestoreComments(comparison, "!" + base + "." + "findAny().isPresent()"); } } }