Specifically, I have TabPane, and I would like to know if there is element with specific ID in it.
So, I would like to do this with lambda expression in Java:
<
The above answers require you to malloc a new stream object.
public
boolean containsByLambda(Collection extends T> c, Predicate super T> p) {
for (final T z : c) {
if (p.test(z)) {
return true;
}
}
return false;
}
public boolean containsTabById(TabPane tabPane, String id) {
return containsByLambda(tabPane.getTabs(), z -> z.getId().equals(id));
}
...
if (containsTabById(tabPane, idToCheck))) {
...
}