List<StandardMethodContract> (List<StandardMethodContract> contracts, @NotNull PsiMethod method, @NotNull Nullability nullability, @NotNull IntPredicate notNullParameter) { final PsiType returnType = method.getReturnType(); if (returnType != null && !(returnType instanceof PsiPrimitiveType)) { contracts = boxReturnValues(contracts); } List<StandardMethodContract> compatible = ContainerUtil.filter(contracts, contract -> { for (int i = 0; i < contract.getParameterCount(); i++) { if (contract.getParameterConstraint(i) == NULL_VALUE && notNullParameter.test(i)) { return false; } } ContractReturnValue retValue = contract.getReturnValue(); if (nullability == Nullability.NOT_NULL && (retValue.equals(ContractReturnValue.returnNotNull()) || retValue.isNull())) return false; if (nullability == Nullability.NULLABLE && retValue.isNotNull() && contract.isTrivial()) return false; return retValue.isMethodCompatible(method); }); if (compatible.size() > MAX_CONTRACT_COUNT) { LOG.debug("Too many contracts for " + PsiUtil.getMemberQualifiedName(method) + ", shrinking the list"); return compatible.subList(0, MAX_CONTRACT_COUNT); } return compatible; }