I have a config file like this:
Provider Search,ConfigURL,http://myUrl
I want to fill this object using reflection
public class MyPrefrences {
public ProviderSearch ProviderSearch;
}
public class ProviderSearch {
public String ConfigURL;
}
here is my code, but I fail to set the composite object:
MyPrefrences myPrefrences = new MyPrefrences();
try {
Field field = myPrefrences.getClass().getDeclaredField(normalizedCategory);
Field field2 = field.getClass().getDeclaredField(normalizedKey);
field2.set(field, val);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
how would you do it
a) if all leaves members are String?
b) if I the leaves can be primitives and non-primitives?
Aucun commentaire:
Enregistrer un commentaire