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

Field-based @ToString and @EqualsAndHashCode of and exclude parameters #1492

Closed
wants to merge 4 commits into from

Conversation

sim642
Copy link

@sim642 sim642 commented Oct 12, 2017

This PR adds Of and Exclude subannotations for @ToString and @EqualsAndHashCode to allow specifying explicitly included or excluded fields directly at the field declaration, not as variable name strings in the annotation parameter on the class. See included test cases for concrete examples.

Past issues requesting such feature: #1163 and #123. Subannotation syntax similar to #1393.

@Maaartinus
Copy link
Contributor

Cool!

I'd prefer Include to Of as it's more obviously an opposite. While @ToString(of={"a", "b"}) reads better than @ToString(include={"a", "b"}), for the repeated @ToString.Of, it's IMHO no more true. Especially, when it gets arguments like

@ToString.Of(limit=80, omitIfNull=true)
String someString;

or something like I proposed in #512 (comment).

@sim642
Copy link
Author

sim642 commented Oct 13, 2017

The Of vs Include naming issue definitely occurred to me, especially because internally the handlers call them includes as well and I agree with your reasoning. At the moment I went with Of because it closely emphasizes the subannotation's relationship to the of annotation parameter and follows the existing naming of things. Would definitely be good to hear some more opinions about this and I'm willing to make the necessary changes if needed.

@rzwitserloot
Copy link
Collaborator

Not sure we're gonna go with this PR, but, we're working on this. See: Working on it: https://github.com/rzwitserloot/lombok/wiki/FEATURE-IDEA:-Annotation-based-Include-Exclude-for-ToString,-EqualsAHC,-etc

@rzwitserloot
Copy link
Collaborator

ToString take on this is now on the master branch as a trial: ad21a15

We'll expand it to EqualsAndHashCode and probably a newly minted @SomeArgsConstructor too.

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.

3 participants