protected < T > CompletionStage < Optional < T > > doWithServiceImpl ( String name , Descriptor . Call < ? , ? > serviceCall , Function < URI , CompletionStage < T > > block ) { return locate ( name , serviceCall ) . thenCompose ( uri -> { return uri . map ( u -> block . apply ( u ) . thenApply ( Optional :: of ) ) . orElseGet ( ( ) -> CompletableFuture . completedFuture ( Optional . empty ( ) ) ) ; } ) ; }
Do the given block with the given service looked up .