title: Call JsonProperty setter method from a dependent class
body: <p>I have a class as follows:</p>
  <pre><code>public class MyClass {
     @JsonProperty(&quot;my_id&quot;)
     private String id;
  
     @JsonProperty(&quot;my_list&quot;)
      private List&lt;SecondClass&gt; myList;
  
     public getId() {
        return this.id;
     }
  
     public setId(String id) {
        this.id = id;
     }
  
     public getMyList() {
        return this.myList;
     }
  
     public setMyList(List&lt;SecondClass&gt; myList) {
        this.myList = myList;
     }
  }
  </code></pre>
  <p>My class has a dependency on another class called SecondClass [through the List entity]</p>
  <pre><code>public class SecondClass {
     @JsonProperty(&quot;my_name&quot;)
     private String name;
  
     public getName() {
        return this.name;
     }
  
     public setName(String name) {
        this.name = name;
     }
  }
  </code></pre>
  <p>I know how to access the getters and setters of <strong>&quot;MyClass&quot;</strong> using Reflection based on the <strong>JsonProperty</strong> name, as shown below:</p>
  <pre><code>public void myMethod(MyClass myClass, String jsonProperty, String newId) throws IllegalAccessException {
      for (Field field : MyClass.class.getDeclaredFields()) {
          JsonProperty jsonPropAnnotation = field.getAnnotation(JsonProperty.class);
          if (jsonPropAnnotation != null)
              if (jsonPropAnnotation.value().equals(jsonProperty)) {
                  field.setAccessible(true);
                  field.set(myClass, newId);
              }
      }
  }
  </code></pre>
  <p>But, my question is, is there a way to fetch the getter and setter from <strong>SecondClass</strong> via <strong>MyClass</strong> based on the JsonProperty name using Reflection?</p>
  <p><em>As an example I would like to call getList() based on JsonProperty value &quot;my_list&quot; and then setName() based on the JsonProperty value &quot;my_name&quot;.</em></p>
  <p>Is this a possibility using reflection?</p>