getNaturalName(String name) with the input DomainRCAdaptor.Domain RCA daptor where as the correct output should be Domain RC Adaptor.Given the input DomainRCAdaptor, the output should be Domain RC Adaptor
Given the input DomainRCAdaptor, the output is Domain RCA daptor
Requesting for the opportunity to rewrite the function getNaturalName at https://github.com/micronaut-projects/micronaut-core/blob/afc3fb377fea37f942c1a251be19b58f9f989b22/cli/src/main/groovy/io/micronaut/cli/util/NameUtils.java#L421
Usage of List<String> words can be avoided. https://github.com/micronaut-projects/micronaut-core/blob/afc3fb377fea37f942c1a251be19b58f9f989b22/cli/src/main/groovy/io/micronaut/cli/util/NameUtils.java#L423
@vinrar If you'd like feel free to submit a PR. If you can also create a test case that ensures the following passes:
NameUtils.getNaturalName("firstName") == "First Name"
NameUtils.getNaturalName("URL") == "URL"
NameUtils.getNaturalName("localURL") == "Local URL"
NameUtils.getNaturalName("URLlocal") == "URL local"
NameUtils.getNaturalName("aURLlocal") == "A URL local"
NameUtils.getNaturalName("MyDomainClass") == "My Domain Class"
NameUtils.getNaturalName("com.myco.myapp.MyDomainClass") == "My Domain Class"
NameUtils.getNaturalName("aName") == "A Name"
@vinrar Are you working on this issue? If not I can take it.
Thanks @koziolk, I would like to attempt it by myself. Will have it ready by Tue/Wed.
@jameskleeh If this is a valid case, What should be the output of NameUtils.getNaturalName("uRLlocal")? And in Java, the alphabet after the acronym is usually a capital letter. So shouldn't NameUtils.getNaturalName("URLlocal") == "URL local" ideally be NameUtils.getNaturalName("URLLocal") == "URL Local"?
I would expect under the current rules:
NameUtils.getNaturalName("uRLlocal") == "U RL Local"
I don't think you can have it both ways. It's impossible to know whether the last capital is supposed to be with the previous segment or the next segment
NameUtils.getNaturalName("URLLocal") == "URL Local" makes sense, but so does NameUtils.getNaturalName("URLlocal") == "URL local".
After thinking about this more I think the current behavior is allowing for a new word to not start with a capital, which is incorrect. NameUtils.getNaturalName("URLlocal") == "UR Llocal" seems to be correct to me.
@jameskleeh Can you please review the PR: https://github.com/micronaut-projects/micronaut-core/pull/1583