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

Fix getting property name from method like 'getXField' #2608

Closed
wants to merge 1 commit into from
Closed

Fix getting property name from method like 'getXField' #2608

wants to merge 1 commit into from

Conversation

tanyaofei
Copy link

No description provided.

@wuwen5
Copy link
Contributor

wuwen5 commented Jul 8, 2022

Your fix is incorrect.

Please refer to the Java Bean specification document
https://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf
8.8 Capitalization of inferred names.

Thus when we extract a property or event name from the middle of an existing Java name, we
normally convert the first character to lower case. However to support the occasional use of all
upper-case names, we check if the first two characters of the name are both upper case and if
so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”

example:
getXField > XField
getXxField > xxField

@tanyaofei
Copy link
Author

Your fix is incorrect.

Please refer to the Java Bean specification document https://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf 8.8 Capitalization of inferred names.

Thus when we extract a property or event name from the middle of an existing Java name, we
normally convert the first character to lower case. However to support the occasional use of all
upper-case names, we check if the first two characters of the name are both upper case and if
so leave it alone. So for example,
“FooBah” becomes “fooBah”
“Z” becomes “z”
“URL” becomes “URL”

example: getXField > XField getXxField > xxField

I see, looks like i am confused by Lombok

@tanyaofei tanyaofei closed this Jul 8, 2022
@wuwen5
Copy link
Contributor

wuwen5 commented Jul 8, 2022

BTW:
Avoid naming with the second uppercase, which is easy to be confused. For example, the automatic generation of IDEA may be different from Lombok

  • idea ✅
private String xField;

public String getxField();
  • Lombok 😕
private String xField;

public String getXField();

@tanyaofei this is a known issue in Lombok, projectlombok/lombok#2693

@harawata
Copy link
Member

harawata commented Jul 9, 2022

Just for future reference, they added a new switch in the latest version (v1.18.24), it seems (I didn't test it, though).
projectlombok/lombok#2996

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

Successfully merging this pull request may close these issues.

None yet

3 participants