chain.stream()
// Get the request handler associated with a given name
.map(refName -> requestHandler(request, refName))
// Only SearchHandler instances are allowed in the chain
.filter(SearchHandler.class::isInstance)
// executes the handler logic
.map(handler -> executeQuery(request, response, params, handler))
.filter(qresponse -> howManyFound(qresponse) > 0)
// Stop the iteration when the first condition above has been satisfied
.findFirst()
// or, if we don’t have any positive executions, just returns an empty response.
.orElse(emptyResponse(request, response)));