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 JRadioButton-binding. What I want to do is specify a property-name of a model which holds a special value (enum). The radio-button shall be selected if this property has a specific value. Now I want to specify the value in the annotation like this:
@RadioButtonBinding(selectedProperty = "selectedItem", selectedValue = MyEnum.FIRST)
JRadioButton firstButton
@RadioButtonBinding(selectedProperty = "selectedItem", selectedValue = MyEnum.FIRST)
JRadioButton secondButton
However, I do not know how to declare the annotation to allow the above and any other enum, too. My first guess was this, but I learned that annotation attributes cannot be generic:
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface RadioButtonBinding {
String selectedItem();
Class<? extends Enum<?>> enumClass();
String enumConstantName();
<T extends Enum<T>> T enumValue();
}
Any ideas how to solve this?