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

Native Lombok support not working for @Getter and @Setter on classes #543

Closed
peter-janssen opened this issue Nov 14, 2016 · 1 comment
Closed
Labels
Milestone

Comments

@peter-janssen
Copy link
Contributor

peter-janssen commented Nov 14, 2016

Original question on #182

For some strange reason I can't get lombok support working. After running the archetype I've changed the pom according to the wiki. And I added @Getter and @Setter to both Persona.class and Name.class and removed all getter and setter methods. After running maven the parameters are no longer shown in the Json nor xml datatypes. They are also no longer present in swagger.
I also tried the jackson2-api-lombok example. This works out of the box (tag v2.7.0) but I noticed the getter and setter methods in for example Name.class and Person.class are still present. After removing these (in the case of Person only for id) these are also no longer present in the docs. What am I missing here?

reply by @stoicflame

@peter-janssen, I'm not seeing the problem. When I remove the getId and setId methods on Person in the jackson2-api-lombok, the property still shows up.

See this patch.

If you can provide more details about what you're seeing, let's open a new issue to track it.

As requested I opened a new issue. I did some further investigation it seems that when the annotations @Getter and @Setter are on the class level they do not work. @Data does work though. See this patch

I had a look at your code and there should probably be a check in the LombokMethodGenerator. The methods shouldGenerateGetters and shouldGenerateSetters check for @Getter and @Setter respectively on the field and for @Data on the class (decoratedTypeElement). There should be check for @Getter and @Setter on the class as well.
Something like:

if (field.getAnnotation(Getter.class) != null 
    || decoratedTypeElement.getAnnotation(Getter.class)  != null) {
    return true;
}

For now I will probably fallback to the pre 2.7.0 way. After some discussion with colleagues this seems to be the better way of going about this anyway. As for @markozi's comment on #182. This should probably be solved in the lombok project. As far as I can see this has already been addressed in projectlombok/lombok#132 and projectlombok/lombok#170.

@stoicflame stoicflame added the bug label Nov 14, 2016
@stoicflame stoicflame added this to the 2.8.0 milestone Nov 14, 2016
@stoicflame
Copy link
Owner

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

No branches or pull requests

2 participants