Trying to filter a collection using a stream, and trying to pass the following lambda to filter() a Set, which gives the arcane error in the title:
unmatchedIncomingFields.stream().filter(s-> s.matches(fieldMatchPattern))
Meanwhile, creating a Predicate object works:
unmatchedIncomingFields.stream().filter(new Predicate<String>() {
@Override
public boolean test(String s) {
return s.matches(fieldMatchPattern);
}
});
According to the JLS, a lambda body is "value-compatible" if every control path returns a value. matches() always gets called and always returns a boolean, so I don't understand what the problem is.
I've also tried all kinds of variations of the same lambda- with and without parentheses and argument types and using expression and block-with-return bodies.
unmatchedIncomingFields
?Set<String>
or justSet
?