Common superclass for Optional<T> and primitive variants?
Paul Benedict
pbenedict at apache.org
Mon Mar 4 12:47:21 PST 2013
I think it would be a good idea to give the four Optional classes a common
super class. This would allow heterogeneous collections of OptionalXXX
objects to be returned.
I can understand why Optional<T> is NOT the superclass so that unnecessary
boxing is avoided. That's not what I'm suggesting. It could simply be a
marker interface, if necessary, but I think equals/hashCode/toString could
be shared code.
If the current Optional<T> was renamed to OptionalObj, then the name
Optional would free up for the common superclass.
Paul
More information about the lambda-dev
mailing list