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

Add the possibility to use @Getter on java 17 record on the different components. #3058

Open
alexandrenavarro opened this issue Dec 5, 2021 · 6 comments
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail enhancement

Comments

@alexandrenavarro
Copy link

Add the possibility to use @Getter on java 17 record on the different components.

The reason why is we don't know when you use a class if it is a record or a class and the way to retrieve attributes or components are different.

With lombok

@Getter
public record MyObject(int id) {
}

Generated

public record MyObject(int id) {

public int getId() {
return id;
}

}

@ehenoma
Copy link

ehenoma commented May 27, 2022

This should not be ignored,
there are cases when one has to work with older frameworks that expect
getXxx naming conventions (Like velocity). In those cases it would be handy
to generate extra accessors.

@rzwitserloot rzwitserloot added enhancement accepted The issue/enhancement is valid, sensible, and explained in sufficient detail labels May 27, 2022
@rzwitserloot
Copy link
Collaborator

We don't allow it now? Huh. Yeah, we should allow you to do this, no need to convince us :)

@mjaggard
Copy link
Contributor

@rzwitserloot do you know if anyone is working on this? If not I'll try to get some time to do it

@mjustin
Copy link

mjustin commented Jul 24, 2023

To clarify: it looks like @Getter currently works when applied to the record components themselves, but not to the class.

Working:

public record MyObject(@Getter int id) {
}

Not yet working

@Getter
public record MyObject(int id) {
}

@mjaggard
Copy link
Contributor

There's a test for this. I wonder how it's not working.
https://github.com/projectlombok/lombok/blob/master/test/transform/resource/before/GetterOnRecord.java

@mjaggard
Copy link
Contributor

OK, I see - the test was checking that it didn't work.
Fixed @rzwitserloot :
#3548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail enhancement
Projects
None yet
Development

No branches or pull requests

5 participants