Traditionally, a function that want to skip certain items during processing will accept a Collection or var-args argument, but in the Java 8 world I think I should switch to Predicates.Now, since the code I am working on is mainly for testing, most of the exclusion will be ad-hoc literals, so I am suggesting users use the formArrays.of(a, b, ...)::containsI am just wondering how acceptable this is?(I see little value in wrapping the above form in an overload because it will be one more signature to learn and prevents the simple optimisation of extrating this literal to a variable.)Edit:Old function will be likepublic void processUnlessNameIn(String... names)I want the new one to bepublic void processUnlessName(Predicate<String> pred)
How confusing is `new SomeCollection(values...)::contains` as a Predicate?
java;coding style;lambda;java8
To directly answer your question: somewhat confusing, since the code example you gave just doesn't sit right, for me anyway.TBH, if your collection always contains strings, then I think adding predicates/lambdas is overkill in this situation. What does it really get you? If you have a collection of a richer object type, and want the user to be able to operate on that, then supplying a lambda instead of many overrides for every possible filtering choice would be sensible.(Also, I'd rename processUnlessName(...) to processExcept(...), which seems clearer, but that's purely my opinion.)