Is there any difference between?
MyObject myWantedObj = Iterables.tryFind(myListOfObjects, new Predicate<MyObject>() {
public boolean apply(MyObject myObj) {
return myObj.getSomeAttribute().equals(someFinalVariable);
}
}).orNull();
and
MyObject myWantedObj = FluentIterable.from(myListOfObjects).firstMatch(new Predicate<MyObject>() {
public boolean apply(MyObject myObj) {
return myObj.getSomeAttribute().equals(someFinalVariable);
}
}).orNull();
Iterables.tryFind and FluentIterable.firstMatch Javadoc are equals to:
Returns an
Optional
containing the first element in iterable that satisfies the given predicate, if such an element exists.
I missing something?