I'm sure this is answered somewhere, but I don't have good enough search terms to find it. I am using the io.vavr.control.Try package, and when I try to use getOrElseThrow method on an element in a stream of results, the method is ambiguous with the io.vavr.Value class. Can I specify which method I want to use somehow, or is it impossible?
You have a number of options:
Add an explicit cast to the desired type:
.map(rsp -> rsp.getOrElseThrow((Supplier<NotFoundException>) NotFoundException::new))
.map(rsp -> rsp.getOrElseThrow((Function<? super Throwable, NotFoundException>) NotFoundException::new))
Use a lambda expression instead of a method reference:
.map(rsp -> rsp.getOrElseThrow(() -> new NotFoundException()))
.map(rsp -> rsp.getOrElseThrow(t -> new NotFoundException(t)))
Use an explicit type of the outer lambda parameter:
.map((Value<…> rsp) -> rsp.getOrElseThrow(NotFoundException::new))
.map((Try<…> rsp) -> rsp.getOrElseThrow(NotFoundException::new))