List<StandardMethodContract> (List<StandardMethodContract> contractClauses) { // If there's a pair of contracts yielding the same value like "null,_->true", "!null,_->true" // then trivial contract should be used like "_,_->true" StandardMethodContract soleContract = StreamEx.ofPairs(contractClauses, (c1, c2) -> { if (c1.getReturnValue() != c2.getReturnValue()) return null; int idx = -1; for (int i = 0; i < c1.getParameterCount(); i++) { ValueConstraint left = c1.getParameterConstraint(i); ValueConstraint right = c2.getParameterConstraint(i); if (left == ValueConstraint.ANY_VALUE && right == ValueConstraint.ANY_VALUE) continue; if (idx >= 0 || !right.canBeNegated() || left != right.negate()) return null; idx = i; } return c1; }).nonNull().findFirst().orElse(null); if (soleContract != null) { contractClauses = Collections.singletonList(StandardMethodContract.trivialContract(soleContract.getParameterCount(), soleContract.getReturnValue())); } return contractClauses; }