I have a use case in my Spring boot application as follows:
I would like to fetch the id field value from the response with the following function:
String id = getIdFromResponse(response);
If I don't get any id in the response, then I check if the id field is present in the request argument with the following function:
String id = getIdFromRequest(request);
As of now, I am invoking them sequentially. But I would like to make these two functions run parallelly, I would like to stop as soon as I get an id from either of them.
I am wondering if there is any way to implement this using streams in Java 8.