I have the following:
class Foo implements Inter {
void doSomething();
}
Optional<Inter> getPossible() {
Optional<Foo> possible = ...;
possible.ifPresent(Foo::doSomething);
return possible.map(f -> f);
}
getPossible
needs to return an Optional<Inter>
because it's overriding a superclass's implementation.
That map at the end of the method is purely to convert the type. Is there a more elegant option?