One of the problems I've run into is trying to write generic code for
Java 8. It would seem reasonable to be able to write a function that can accept either an
Optional or a
Stream and perform a
flatMap on that argument... but I can't convince generics to let me do this and there's no common interface for those types. That same problem exists for
filter and
map (and probably others).
Questions to Richard:
Do you feel the absence of these common interfaces is a mistake?Do you have any recommendations for writing truly generic code in the absence of such interfaces?