mardi 10 octobre 2017

How to get annotation value without default value?

I'm writing some of program using java annotation. but, here is little problem.

I want to get annotation field only declared by me. but, get all annotation field and default value in annotation class after compile.

I want to Except default field and value in annotation class.

Any help ?

ps. sorry english

this code is annotation class

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.SOURCE)
  public @interface Grider {
  String gName() default "";
  boolean sort() default false;
}

how to use the annotation

@Grider(gName="gridtest1")

result I want(using reflection) gName=gridtest1

but, result is gName=gridtest1, sort=false

I want to get result first one.





Aucun commentaire:

Enregistrer un commentaire