mercredi 18 décembre 2019

How to iterate all properties/fields in bean/Object, includes reference Object/Bean

[background]

public class All {

     Private List<CClass> listc;

     private BClass b;

     @customerAnnotation
     Private String all1;
}

public class B {

     @customerAnnotation
     String A;

     String B;

     @customerAnnotation
     Class C
     ...
}

public class C {

     @customerAnnotation
     String d;

     String e;
}

public list<Field> myProcess(All bean) throws BusinessException;

question:

  1. How to get all fields that it has marked by @CustomerAnnotation, includes reference object field?

  2. [field.getAnnotation(customerAnnotation.class)], it just can get the first top, but I want to get second, third...

  3. Is there any Framework or Utils can do that or help me to do that?





Aucun commentaire:

Enregistrer un commentaire