Is there a way to declare an annotation attribute for *any* enum?

前端 未结 3 2118
终归单人心
终归单人心 2021-02-07 04:04

At the moment I am developing an annotation-based binding-framework for Java Swing that uses JGoodies Binding under the hood. Unfortunately I am stuck with an annotation for a J

3条回答
  •  天涯浪人
    2021-02-07 04:44

    I was trying to solve this exact same problem, and as far as I know, it can not be done. It's a real bummer.

    In my case, I wanted to specify @Version annotation, where any enumeration can be used, and enum values can be compared by ordinal (to find ordering of versions). Looks like I need to do what some other frameworks (like Guice I think) do and use doubles instead; bit ugly, but works ok for >= and <= checks.

提交回复
热议问题