As you mention there is no method like that on vavr, however you could made some workarounds:
using tupples:
Try.success(authorizationHeader)
.map(mapper::hcpFrom)
.map(hcp -> Tuple.of(hcp, mapper.toSaveNoteRequest(noteId, patientId, requestBody, clock)))
.map(t2 -> saveNoteUseCase.execute(t2._1(), t2._2()))
.map(mapper::toHcpNoteResponse)
.map(response -> accepted().body(response))
.get();
using For with yield:
For(Try.success(authorizationHeader).map(mapper::hcpFrom), Try.success(mapper.toSaveNoteRequest(noteId, patientId, requestBody, clock)))
.yield(saveNoteUseCase::execute)
.map(mapper::toHcpNoteResponse)
.map(response -> accepted().body(response))
.get();
using code inside flatMap:
Try.success(authorizationHeader)
.map(mapper::hcpFrom)
.flatMap(hcp-> Try.of(() -> mapper.toSaveNoteRequest(noteId, patientId, requestBody, clock)).map(saveNoteRequest -> saveNoteUseCase.execute(hcp, saveNoteRequest)))
.map(mapper::toHcpNoteResponse)
.map(response -> accepted().body(response))
.get();
And finally using futures(like api, however not recommended)
Try.success(authorizationHeader).map(mapper::hcpFrom).toCompletableFuture()
.thenCombine(Try.success(mapper.toSaveNoteRequest(noteId, patientId, requestBody, clock)).toCompletableFuture(), saveNoteUseCase::execute)
.thenApply(mapper::toHcpNoteResponse)
.thenApply(response -> accepted().body(response))
.join();
Kind regards.