Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve toString generation for enums. Fixes #1916
- Loading branch information
Showing
11 changed files
with
168 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
enum ToStringEnum1 { | ||
CONSTANT; | ||
@java.lang.Override | ||
@java.lang.SuppressWarnings("all") | ||
public java.lang.String toString() { | ||
return "ToStringEnum1." + this.name(); | ||
} | ||
} | ||
enum ToStringEnum2 { | ||
CONSTANT; | ||
int x; | ||
String name; | ||
@java.lang.Override | ||
@java.lang.SuppressWarnings("all") | ||
public java.lang.String toString() { | ||
return "ToStringEnum2." + this.name() + "(x=" + this.x + ", name=" + this.name + ")"; | ||
} | ||
} | ||
class ToStringEnum3 { | ||
enum MemberEnum { | ||
CONSTANT; | ||
@java.lang.Override | ||
@java.lang.SuppressWarnings("all") | ||
public java.lang.String toString() { | ||
return "ToStringEnum3.MemberEnum." + this.name(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import lombok.ToString; | ||
@ToString enum ToStringEnum1 { | ||
CONSTANT(), | ||
<clinit>() { | ||
} | ||
ToStringEnum1() { | ||
super(); | ||
} | ||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { | ||
return ("ToStringEnum1." + this.name()); | ||
} | ||
} | ||
@ToString enum ToStringEnum2 { | ||
CONSTANT(), | ||
int x; | ||
String name; | ||
<clinit>() { | ||
} | ||
ToStringEnum2() { | ||
super(); | ||
} | ||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { | ||
return (((((("ToStringEnum2." + this.name()) + "(x=") + this.x) + ", name=") + this.name) + ")"); | ||
} | ||
} | ||
class ToStringEnum3 { | ||
@ToString enum MemberEnum { | ||
CONSTANT(), | ||
<clinit>() { | ||
} | ||
MemberEnum() { | ||
super(); | ||
} | ||
public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { | ||
return ("ToStringEnum3.MemberEnum." + this.name()); | ||
} | ||
} | ||
ToStringEnum3() { | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import lombok.ToString; | ||
@ToString | ||
enum ToStringEnum1 { | ||
CONSTANT; | ||
} | ||
@ToString | ||
enum ToStringEnum2 { | ||
CONSTANT(); | ||
int x; | ||
String name; | ||
} | ||
class ToStringEnum3 { | ||
@ToString | ||
enum MemberEnum { | ||
CONSTANT; | ||
} | ||
} |