Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Try.withResources().multi #2934

Open
xenoterracide opened this issue Nov 14, 2024 · 0 comments
Open

feat: Try.withResources().multi #2934

xenoterracide opened this issue Nov 14, 2024 · 0 comments

Comments

@xenoterracide
Copy link

xenoterracide commented Nov 14, 2024

Based on my presumption in #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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant