jeudi 31 décembre 2015

Get inner attribute class value with class.name String

Let's say this case

class A {
    int bla;
    B B;
}

class B {
    public int foo;
}

And I have an array {"B.foo", "bla"}. Now getting the Class A and without any idea about his internal structure how can I use reflection, or another third party, to extract the values of those attributes that I have on my array.

Of course I know reflection and how get an attribute in the first class level(A.bla), but If I want to get get B.foo without add any business logic how can I get that value from A just using the String Class-attribute?





Aucun commentaire:

Enregistrer un commentaire