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

[FEATURE] Getters for AtomicInteger, AtomicLong, etc #3556

Open
magicprinc opened this issue Nov 22, 2023 · 2 comments
Open

[FEATURE] Getters for AtomicInteger, AtomicLong, etc #3556

magicprinc opened this issue Nov 22, 2023 · 2 comments

Comments

@magicprinc
Copy link

magicprinc commented Nov 22, 2023

Getters for AtomicInteger, AtomicLong, etc - usually - look like

public int getCount() {
  return count.get();
}

Lombok @Getter generates

public AtomicInteger getCount() {
  return count;
}

I propose to add option/flag to @Getter annotation or lombok.config to enable "extraction/unwrapping" of such "wrapped" fields,
to generate return count.get() instead of return count.

To make it more "generic", @Getter could have String property using with the name of the method, it should call

@Getter(using="get")
final AtomicInteger count = new AtomicInteger();

It can be also useful for ThreadLocal, Collection.size() and many others

@magicprinc magicprinc changed the title [FEATURE] [FEATURE] Getters for AtomicInteger, AtomicLong, etc Nov 22, 2023
@magicprinc
Copy link
Author

It must be not much harder to implement than @Getter or @Cleanup and makes sense.
Please 🙏😅

@magicprinc
Copy link
Author

magicprinc commented Nov 24, 2023

BTW #3498 are also good to have

IDEA supports them: even suggests removing code that checks this condition ;-)

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

1 participant