vavr
vavr copied to clipboard
feat: Try.withResources().multi
Based on my presumption in https://github.com/vavr-io/vavr/issues/2933 a "multi map" option would be nice, although I'm having trouble thinking of a good api so this might be a bad idea. open once, do all operations, then close the resource. I imagine the api would have to be similar in some ways to doing a custom collector for a java stream.
Maybe something like this
var result = Try.withResources(() -> Git.open(new File(""))).multi(Collector.of(MyResult::new,
(gitTry, result) -> result.add(gitTry.map("").get()),
(gitTry, result) -> result.add(gitTry.map("").get()),
) // autoclose resource at end of all.
important, in my use case with jgit there are call() operations after the initial with resources that throw checked exceptions, so any api should consider further checked exceptions may need to be handled.
version at time of writing 0.10.5