Hi Kurt,
Using Optional.presentInstances(entities), means that the entities is an Iterable of Optional<Entity>. But in my case, it is not the entity that is Optional but some of its fields.
So it means that I should be able to construct an Iterable<Optional<Entity>> from its Optional<FieldType>, which is not easier as filtering entities from a Predicate.
As for your related link, I read it during my search about this subject but I didn't see a solution in it, except for the proposition of the present() Predicate.
I think it is kind of the same solution provided by the method com.google.common.collect.Ordering#onResultOf, ie, a transformation on the behalf of. We sort entities using transformation form of it.
For the present problem, we want to filter entities using transformation form of it, ie, Optional.isPresent Predicate.
A real business use case of my problem is to filter a List of Order, given that order.getMatchingOrder() return an Optional<Order> when there is a matching Order only.
So I expect retrieving orders with matching using : from(orders).filter(compose(Optional.isPresent(), Order.toMatchingOrder())).
Hope it helps.
Amertum