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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

mysqli - Php Mysqli_fetch_assoc Error : "Warning: Illegal string offset 'name' in" -

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