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

GIAI Builder returns null when input RFID tag is not valid #10

Open
yolave opened this issue Dec 15, 2020 · 1 comment
Open

GIAI Builder returns null when input RFID tag is not valid #10

yolave opened this issue Dec 15, 2020 · 1 comment

Comments

@yolave
Copy link

yolave commented Dec 15, 2020

When using org.epctagcoder.parse.GIAI.ParseGIAI.Builder() to create a new instance, setting an invalid RFID tag in the method org.epctagcoder.parse.GIAI.ParseGIAI.ChoiceStep.withRFIDTag(String) produces a NullPointerException when finally calling org.epctagcoder.parse.GIAI.ParseGIAI.BuildStep.build() method.

For example, the following snippet will fail:

ParseGIAI.Builder()
.withRFIDTag("anyNonComplaintValue").build()
 .getGIAI() 

Instead of null, the org.epctagcoder.parse.GIAI.ParseGIAI.BuildStep.build() method might throw a ParseException (or any other dedicated exception) or even better, it could return a java.util.Optional to be easier to check the result of the parsing.

Thank you for this awesome library!

@jlcout
Copy link
Owner

jlcout commented Dec 18, 2020

Hi Yolave!

I'm analyzing, I prefer Optional. I don't particularly like the idea of ​​throwing an exception, although it is very easy to implement.

As I implemented using the step builder pattern I will have problems cascading Optional.
It would be a good challenge.

Thank you for the idea.

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