Agreed: "transform" means something different for Futures than it does
for Lists, Maps, etc. If we were starting from scratch, we'd probably
name one of the two concepts differently, even if only something like
"transformedView." Ironically, the Futures method that behaves like
Lists.transform doesn't get that name:
https://www.corp.google.com/~engdocs/nonconf/java/common/com/google/common/util/concurrent/Futures.html#lazyTransform%28java.util.concurrent.Future,%20com.google.common.base.Function%29
FluentListenableFuture is on our list of things to try. Arguably it
has a better case than common.base classes like FluentPredicate, but
we happen to have written those ones first, so it may be a while. A
few comments while it's on my mind:
- Some Futures methods apply only to multiple Futures or certain types
of Futures, and others may one day be removed. The ones I'd feel most
comfortable seeing replicated to FluentListenableFuture are probably
addCallback, get, getUnchecked, transform (both), and withFallback.
- We could take this opportunity to "fix" the generics on transform,
replacing "? extends O" with plain "O" on the transform parameters.
(It's not clear that that's the right decision overall, but it's the
pattern we've tried to follow elsewhere; the Futures.transform methods
slipped through.)
- One crazy idea is to allow a FLF to have an Executor associated with
it, one that would be used by calls to transform, etc. This would
mean we would no longer need 2 copies of each method. I'm kind of
nervous about this, since it makes Futures.transform(future, function)
and future.transform(function) behave differently, so I'm leaning
against it, but I thought I'd throw it out there.
If you're interested in putting together a CL to speed things along
(though the review may be a bit slow and nitpicky), I could take a
look.