Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get value from POJO using reflection?
    primarykey
    data
    text
    <p>I am just create a One generic method using Method Reflection API. In This Method I am trying to get a particulate method(getter method / setter method) value but I am stuck I don't know how to do this. I am Abel to get all the method Name using Method Reflection API but not Abel to get value of that method. So please help me. </p> <p>here is my code......</p> <p>/*<br> propertyNames List is contain two records.</p> <pre><code> and that records are two different EntityName(Variable Name) ex. in my class i have declared two Entity(Variable) private Integer productId; private Integer bomBucket; so propertyNames List is contain [productId , bomBucket] this two records. </code></pre> <p>*/ </p> <pre><code> public &lt;T&gt;void fillList(List&lt;String&gt; propertyNames , T clas){ try{ for(Object entity : entities.keySet()){ if(propertyNames != null &amp;&amp; propertyNames.size() &gt; 0){ Method[] methodList = clas.getClass().getMethods(); Method methodName; for (String propertyName : propertyNames) { for(Method method : methodList){ if(method.getName().trim().startsWith("set")){ if(propertyName.trim().equalsIgnoreCase(method.getName().substring(3, method.getName().trim().length()))){ methodName = clas.getClass().getMethod(method.getName().trim(),new Class[]{Integer.class}); System.out.println("HERE I GET METHOD NAME ::: " + methodName.getName()); /* * here one by one i am getting all the Setter methods name from the class . * but i want a that Setter methods values. Not return type. */ } } } } } } }catch (Exception e) { e.printStackTrace(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload