Typed tags
#3581
Replies: 1 comment
-
That's unfortunately not possible in Java. Although an annotation can have an attribute with an enum type, it must be a concrete In other words, there is no way to declare an annotation attribute that can be assigned any enum constant value. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There is a similar discussion in this feature request.
Meta-and composed annotations are a good solution for stricter tag typing but it does not solve one, as it seems to me, common case.
Let's say we have a test classification consisting of 10+ sometimes changing values:
That means we need either 10+ meta annotations:
@Red
@Green
or, for example, use @tag annotation and a storage class for 10+ constants:
Tag(Color.RED)
Tag(Color.GREEN)
A better approach would be the ability to pass, for example, an enum to @tag annotation with the ability to get the desired text from it.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions