validation - Can java annotations be overridden? If so? How? -


i built validation mechanism around application based on java annotations - similar java bean validation, sole exception mine easier - has value , type of value float.

@target({ field }) @retention(runtime) @documented public @interface min {        float value() default 0f;  } 

now need extend mechanism support integer values. possible provide overriding of annotation? like:

@target({ field }) @retention(runtime) @documented public @interface min {        int value() default 0;  } 

or possible 1 of 2 properties present? like:

@target({ field }) @retention(runtime) @documented public @interface min {        float value() default 0f;     int intvalue(); } 

any other mechanism welcomed.

thank you!

an annotation type cannot declare superclass or superinterface; see jls 9.6 details.

here couple of options:

  • modify annotation support 2 values
  • create second annotation different name , value, , have annotation processor handle both annotations.

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -