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

Support for TryRead() methods #23

Open
kbilsted opened this issue Jan 31, 2015 · 2 comments
Open

Support for TryRead() methods #23

kbilsted opened this issue Jan 31, 2015 · 2 comments

Comments

@kbilsted
Copy link
Member

I was thinking that maybe we could introduce TryReadxxx() methods on the reader implementations which do not throw exceptions, rather they may return null/an empty list maybe along with a list of strings for the caller to inspect and react upon. In C# "out parameters" are typically used with TryXXX methods. I'm not sure what to use in Java. Especially if we want to keep compatibility with java 1.5

something like

public boolean TryRead(T bean, string[] nameMapping, List rawLineData)

What are your thoughts? @jamesbassett your thoughts?

@ZioberMichal
Copy link
Collaborator

Interesting idea. 👍

I think, that if we want to implement something like this we should return much more than only "boolean" or "null/empty" value. User probably would like to see complex POJO class with list of columns for which parsing has failed with error messages and all additional data which we can provide.

@kbilsted
Copy link
Member Author

kbilsted commented Sep 3, 2015

Yes that might be a good idea. Originally, when I thought of this I was just thinking about the "standard" try-pattern with a method object Read() throws ... and a bool TryRead(out result) - but since Java does not have the possibility of returning multiple values natively, we need to wrap the result in some resulttuple or something, so we might at well cater for the need of providing more information now that we've gone through the trouble of trying to read.

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

No branches or pull requests

2 participants