RFR(m): 8140281 deprecate Optional.get()
Victor Polischuk
victor2 at ukr.net
Thu Apr 28 09:26:17 UTC 2016
I am sorry if my comment would be inappropriate, but is there a reason not to introduce "Optional<T> ifAbsent(Runnable emptyAction)" and change signature of ifPresent to "Optional<T> ifPresent(Consumer<? super T> consumer)"?
In that case method chaining would be more natural and it will give a decent way to have more than one simple action assigned to Optional without creating messy java block.
--- Original message ---
From: "Stuart Marks" <stuart.marks at oracle.com>
Date: 28 April 2016, 05:50:45
> > Is there a better way of doing this? We'd almost need a
> > ifPresentElse(Consumer<? super T> consumer, Runnable action) method I guess.
> Close. In JDK 9 we added
>
> ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction)
>
> s'marks
More information about the core-libs-dev
mailing list