根据error-setting-a-default-null-value-for-an-annotations-field
不可能将null影响到可选的默认值,这里是我的情况
有
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SubView {
Class EntityType();
String[] Listing();
}
如何编码可选SubView属性的默认值?
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SubTab {
String name();
String[] Fields() default {};
SubView SubView() default ??? ; //this is optional how to code it?
}
答案 0 :(得分:3)
反复试验
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SubTab {
String name();
String[] Fields() default {};
SubView SubView() default @SubView(Listing={}, EntityType=Object.class);
}