3

According to error-setting-a-default-null-value-for-an-annotations-field

its not possible to affect null to an optional default value, here my case

having

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE) 
public @interface SubView {
    Class EntityType();
    String[] Listing();
}

how to encode the default value for the optional SubView property?

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SubTab {
    String name();
    String[] Fields() default {};
    SubView SubView() default ??? ; //this is optional how to code it?
}
Community
  • 1
  • 1
Nassim MOUALEK
  • 4,702
  • 4
  • 25
  • 44

1 Answers1

4

trial and error

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SubTab {
    String name();
    String[] Fields() default {};
    SubView SubView() default @SubView(Listing={}, EntityType=Object.class);
}
Nassim MOUALEK
  • 4,702
  • 4
  • 25
  • 44