title: how to fill a composite object using java reflection?
body: <p>I have a config file like this:</p>
  
  <p><code>Provider Search,ConfigURL,http://myUrl</code></p>
  
  <p>I want to fill this object using reflection</p>
  
  <pre><code>public class MyPrefrences {
  
      public ProviderSearch ProviderSearch;
  }
  
  
  
      public class ProviderSearch {
  
          public String ConfigURL;
  
      }
  </code></pre>
  
  <p>here is my code, but I fail to set the composite object:</p>
  
  <pre><code>    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);
      }
  </code></pre>
  
  <p>how would you do it</p>
  
  <p>a) if all leaves members are String?</p>
  
  <p>b) if I the leaves can be primitives and non-primitives?</p>