CallHandler<CallChainSimplification> () { return CallHandler.of(STREAM_MATCH, call -> { PsiMethodCallExpression qualifierCall = getQualifierMethodCall(call); if (!STREAM_MAP.test(qualifierCall)) return null; PsiExpression qualifierArg = skipParenthesizedExprDown(qualifierCall.getArgumentList().getExpressions()[0]); PsiExpression predicate = call.getArgumentList().getExpressions()[0]; boolean invert = false; if (!isBooleanIdentity(predicate)) { Boolean target = getBooleanEqualsTarget(predicate); if (target == null || (!target && "anyMatch".equals(call.getMethodExpression().getReferenceName()))) return null; invert = !target; if (qualifierArg instanceof PsiMethodReferenceExpression) { PsiMethod method = tryCast(((PsiMethodReferenceExpression)qualifierArg).resolve(), PsiMethod.class); if (method == null) return null; if (!PsiTypes.booleanType().equals(method.getReturnType()) && !NullableNotNullManager.isNotNull(method)) return null; } else if (!(qualifierArg instanceof PsiLambdaExpression) || DfaUtil.inferLambdaNullability((PsiLambdaExpression)qualifierArg) != Nullability.NOT_NULL) { return null; } } else { if (adaptToPredicate(qualifierArg) == null) return null; } return new RemoveBooleanIdentityFix(invert); }); }