Skip to content

Add builder method that accepts iterable#350

Merged
stevehu merged 1 commit intonetworknt:masterfrom
wheelerlaw:add_helper_method
Nov 21, 2020
Merged

Add builder method that accepts iterable#350
stevehu merged 1 commit intonetworknt:masterfrom
wheelerlaw:add_helper_method

Conversation

@wheelerlaw
Copy link
Copy Markdown
Contributor

This lets me do something like this:

JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7))
            .uriFetcher(new JenkinsWorkspaceFileFetcher(), JenkinsWorkspaceFileFetcher.SUPPORTED_SCHEMES)

JenkinsWorkspaceFileFetcher.SUPPORTED_SCHEMES is a Set<String>, which can't be passed into varargs. But varargs can be passed into an Iterable<String> if you wrap it with Arrays.asList(varargs), and it is cheap too since an ArrayList<> is just backed by an array.

@stevehu stevehu merged commit 0d442fd into networknt:master Nov 21, 2020
@stevehu
Copy link
Copy Markdown
Contributor

stevehu commented Nov 21, 2020

@wheelerlaw It makes perfect sense. Thanks a lot for your help.

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

Successfully merging this pull request may close these issues.

2 participants