Side effect method in option <T>?
I am looking for a way to accomplish a task that can do side effects.
I am trying the following:
getOptionalHumanObject()
.map((Human h1) -> human::getName)
.do((String name) -> System.out::printLn)
.do((String name) -> invokeImportentHttpPostRequest(x))
.map((String name) -> name.length())
...
Now the only way I think is to use a filter / map is to do my side effect and return true / the same object.
Are you using additional class methods for side effects before the terminal operation, such as ifPresent?
+3
source to share