@Value is only supported on a class.

191 views
Skip to first unread message

seakleng

unread,
Jun 2, 2020, 12:26:02 AM6/2/20
to Project Lombok

Hello guys! I have come across a suggestion for @Value which should be used for enum type.

Without this support, we have to use the following screenshot.


Annotation 2020-06-02 095117.png


I really appreciate your contribution to this library.
Looks forward to getting the fix for a future release.


Best Regard,

Seakleng

Martin Grajcar

unread,
Jun 2, 2020, 1:13:24 AM6/2/20
to project...@googlegroups.com
I'm not sure, whether it makes sense. The problem is that @Value implies @ToString and @EqualsAndHashCode. The former is typically unwanted for this kind of enums as the members are constant, so there's no point in showing them again and again. The latter can't be implemented in the usual way as both equals and hashCode are final. So I'm afraid, it'd generate some confusion for not much gain.

Actually, many of my enums look like yours and I'm rather happy with them.

--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/d7139c21-82f6-4a1b-a3cf-4ca8ba44783d%40googlegroups.com.

seakleng

unread,
Jun 2, 2020, 2:57:30 AM6/2/20
to Project Lombok
Thank Maaartin for a prompt reply.

I understand your point. I agree with you and it's not bad to annotate @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) on each enum 😉


On Tuesday, June 2, 2020 at 12:13:24 PM UTC+7, Maaartin G wrote:
I'm not sure, whether it makes sense. The problem is that @Value implies @ToString and @EqualsAndHashCode. The former is typically unwanted for this kind of enums as the members are constant, so there's no point in showing them again and again. The latter can't be implemented in the usual way as both equals and hashCode are final. So I'm afraid, it'd generate some confusion for not much gain.

Actually, many of my enums look like yours and I'm rather happy with them.

On Tue, Jun 2, 2020 at 6:26 AM seakleng <sayse...@gmail.com> wrote:

Hello guys! I have come across a suggestion for @Value which should be used for enum type.

Without this support, we have to use the following screenshot.


Annotation 2020-06-02 095117.png


I really appreciate your contribution to this library.
Looks forward to getting the fix for a future release.


Best Regard,

Seakleng

--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages