jsonschema2pojo icon indicating copy to clipboard operation
jsonschema2pojo copied to clipboard

#1100 Legal characters are now not limited to [0-9a-zA-Z_]

Open asympro opened this issue 5 years ago • 8 comments
trafficstars

asympro avatar Mar 06 '20 11:03 asympro

@joelittlejohn please take a look.

asympro avatar Mar 30 '20 11:03 asympro

Hi @asympro. Thanks for working on this. As per CONTRIBUTING.md we do need an integration test for this.

joelittlejohn avatar Mar 31 '20 11:03 joelittlejohn

I don't actually understand why you've introduced a new approach to handling unsupported characters. Why is it that sometimes chars that can't be supported in the identifier are replaced with _ and other times chars that can't be supported are in the identifier are omitted?

Chars that are illegal (can't be supported) should always be replaced by underscores. When allowNonLatinNames = false, this will be any character outside [a-zA-Z0-9], when allowNonLatinNames = true, this will be any character where isJavaIdentifierPart returns false.

If isJavaIdentifierStart returns false for the first char, stick an underscore on the front of the name (prepend).

I'm finding the current logic hard to follow and complicated, I think it can be a lot simpler, and more consistent with how jsonschema2pojo currently works.

joelittlejohn avatar Mar 31 '20 11:03 joelittlejohn

You are totally right. Will implement anew like you suggested. As for the coding style - I tried to optimize it (losing in readability though), possibly it is due to my "build is always taking too long" mental issue.

asympro avatar Mar 31 '20 11:03 asympro

Thanks @asympro! Let me know when you want me to take another look at your changes and I'll review 👍

joelittlejohn avatar Mar 31 '20 12:03 joelittlejohn

@joelittlejohn IT test written, reimplementation ready, please review

asympro avatar Mar 31 '20 16:03 asympro

It's much better. I vote for this implementation.

eirnym avatar Mar 31 '20 16:03 eirnym

@joelittlejohn eirnym and I both prefer new implementation. Please review if you have time.

asympro avatar Apr 01 '20 14:04 asympro