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

[BUG] @Data does not generate all the Getters and Setters #3625

Open
Y0Username opened this issue Mar 13, 2024 · 1 comment
Open

[BUG] @Data does not generate all the Getters and Setters #3625

Y0Username opened this issue Mar 13, 2024 · 1 comment

Comments

@Y0Username
Copy link

Y0Username commented Mar 13, 2024

Describe the bug
@Data does not generate all the expected Getters and Setters when there are two class members with and without is prefix. Example: manager v/s isManager. Furthermore Getter and Setter generated also depend on the order of these class members.

Source:

@Data
public class Employee {
    private String manager;
    private boolean isManager;
}

Generated:

public String getManager() {
    return this.manager;
}

public void setManager(String manager) {
    this.manager = manager;
}

^ This does not generate Getter and Setter for isManager

Source:

@Data
public class Employee {
    private boolean isManager;
    private String manager;
}

Generated:

public boolean isManager() {
    return this.isManager;
}

public String getManager() {
    return this.manager;
}

public void setManager(boolean isManager) {
    this.isManager = isManager;
}

^ This does not generate the Setter for manager: setManager(String manager)

To Reproduce
Compile the source:

@Data
public class Employee {
    private String manager;
    private boolean isManager;
}

And check the generated source. Also, change the order of the member variables, compile and check the generated source.

Expected behavior
There should be Getters and Setters for all the members of the class:

public boolean isManager() {
    return this.isManager;
}

public String getManager() {
    return this.manager;
}

public void setManager(boolean isManager) {
    this.isManager = isManager;
}

public void setManager(String manager) {
    this.manager = manager;
}

Version info (please complete the following information):

  • Lombok version: 1.18.30
  • Platform: javac 11.0.22

Additional context
This also messes up how jackson handles serialization.
The workaround is to add lombok.getter.noIsPrefix = true to lombok.config.

@rspilker
Copy link
Collaborator

Yeah, the problem is the beanspec. Both manager and isManager are supposed to have their setter called setManager. Possibly this isn't even a problem because the parameter would be different.

Did you try @Tolerate?

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

No branches or pull requests

2 participants