I am trying to find a way to get all the fields instances of X type by ReflectionUtil.
A extends of X:
List<X> xList;
X arg1;
B extends of X:
String argB;
C extends of X:
X argC;
initialization:
List<C> list = new ArrayList();
B item1 = new B("item1")
B item2 = new B("item2")
list.add(item1)
list.add(item2)
B b = new B("test")
A myAClass = new A(list,b)
I can access to myAClass object and I want to get all the nested fields instances of X type.
In above example after the initialization the types are:
MyAClass is:
List<C> xList;
B arg1;
C class is:
B argC;
B class is:
String argB;
The result that I expected for is: [C, B , B, B] where [C - List xList , B - an item of xList , B - an item of xList, B - an argB]
Aucun commentaire:
Enregistrer un commentaire