0

This question is similar to Strange autogenerated getter and setter in eclipse, but I don't find a proper answer for me there or into the linked questions.

Say I have this class. Pay attention on capitalization:

public class Foo {
    private String xxxxx;
    private String yYyyy;
    private String zzZzz;
}

From my point of view, it follows naming conventions, since all attributes begin with a lowercase letter. So I expect Eclipse to autogenerate these getters and setters:

getXxxxx()...
setXxxxx(String xxxxx)...
getYYyyy()...
setYYyyy(String yYyyy)...
getZzZzz()...
setZzZzz(String zzZzz)...

But Eclipse autogenerator does this instead (pay attention to yYyyy getter/setter differences):

getXxxxx()... // Ok
setXxxxx(String xxxxx)... // Ok
getyYyyy()... // Different!
setyYyyy(String yYyyy)... // Different!
getZzZzz()... // Ok
setZzZzz(String zzZzz)... // Ok

Ok, so my guess is: "Naming convention forbids an attribute to begin with a lowercase letter followed by an uppercase one. You need at least 2 lowercase letters.".

My questions are:

1) Is this assumption OK? If yes, why is it that way?

2) Why does Eclipse behave like that on "yYyyy" case? If we assume that the attribute naming is not OK, it seems to me that Eclipse makes it even worse. Is it a bug? Is there any reason for that?

Thanks.

Community
  • 1
  • 1
Dertalai
  • 198
  • 1
  • 9
  • This is strange ! – minigeek Feb 03 '17 at 11:12
  • 1
    As described in the duplicate question this is actually the correct behavior according to the JavaBeans API spec. – greg-449 Feb 03 '17 at 11:28
  • Thanks, greg-449. The accepted answer on that question points **what**'s correct. And with a little bit of searching through comments and links I got to know **why** too. – Dertalai Feb 03 '17 at 11:51

0 Answers0