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

@ToString over enum to incorporate enum field name #1916

Closed
wizzlerr opened this issue Oct 23, 2018 · 2 comments
Closed

@ToString over enum to incorporate enum field name #1916

wizzlerr opened this issue Oct 23, 2018 · 2 comments

Comments

@wizzlerr
Copy link

Tested on 1.18.2 and 1.16.18

@ToString
enum SampleEnum {
    SOME_FIELD;
}

Currently above enum is compiled into below code.

enum SampleEnum {
    SOME_FIELD;

 public String toString() {
        return "SampleEnum ()";
    }
}

So whenever i run toString on List I will get N "SampleEnum()" strings.

It should be compiled to:

enum SampleEnum {
    SOME_FIELD;

 public String toString() {
        return "SampleEnum (name())";
    }
}

or anything that indicates enums field name.

@rspilker
Copy link
Collaborator

rspilker commented Nov 5, 2018

I suggest to use return "SampleEnum." + name() + "()";

@rzwitserloot
Copy link
Collaborator

this is now available in edge release: https://projectlombok.org/download-edge

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

3 participants