Skip to content

feat: Try.withResources().multi #2934

@xenoterracide

Description

@xenoterracide

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions