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

Add possibility for list -> object #498

Open
StaffanArvidsson opened this issue Aug 7, 2020 · 0 comments
Open

Add possibility for list -> object #498

StaffanArvidsson opened this issue Aug 7, 2020 · 0 comments

Comments

@StaffanArvidsson
Copy link

I would like to have the possibility to go from a list of strings as input to an object, i.e. have an interface similar to IStringConverter that instead take a list of Strings or possibly an array. This would solve issues were a complex type needs to be specified, or one that has dynamic parameters depending on the concrete implementation. For example I take input files that can be of several formats, so I'd like to get a syntax like:
--input-file CSV delimiter:, header:true
But if I instead have a JSON input, the delimiter and header arguments are not possible. I've solved this currently by only taking a List of variable arity and then add conversion into the final object afterward. But that makes the flow in the code somewhat odd and easier to miss doing the conversion. So an interface:

public interface IStringListConverter {
T convert(List values);
}

Or is there any current approach that would solve this in a better way?

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