Add ifSuccessOrElse method to Try for unified handling of success or failure cases#36
Conversation
|
Hey @vesav-mms! Thanks for the PR. I think I understand the intent behind the change, and I believe that it goes against the functional API approach. Can you provide your opinion as to why this change should be merged with an example of the use case you are trying to achieve? |
|
Intention is to be able to do following operations that otherwise do not look straight forward that are possible: Basically, I want to turn operations like the following one that is not that intuitive in the construct above. |
|
@vesav-mms as I suspected. Instead of implementing these operations like you propose, how about we implement method: void ifSuccessOrElse(ThrowableConsumer<? super T> valueConsumer, ThrowableConsumer<Throwable> throwableConsumer), which would follow the same logic as ifPresentOrElse method from Java 9 My reason to avoid having the ability to chain for Try.of(...)
.ifSuccess(....)
.ifFailure(...)
.map(...)
.filter(...)
.ifSuccess(....)
.ifFailure(...) |
… in `Try`" This reverts commit 2287015.
… or failure cases
ifSuccess and ifFailure in TryifSuccessOrElse method to Try for unified handling of success or failure cases
|
@SuppieRK changes done! |
No description provided.