troubleshooting Question

PropertyDescriptor getReadMethod and then use that method

Avatar of COMPSUPP
COMPSUPP asked on
Java
6 Comments2 Solutions566 ViewsLast Modified:
Hello,

I am trying to use PropertyDescriptor to find the getter method for a bean property given the property name as a String.

The code below seems to do this. Is it possible to then use the getter method in question to retrieve its value for the bean (if its value is not null?)

Is there an easy tutorial on PropertyDescriptor and its uses out there somewhere ? Could someone please point me in the right direction?

thanks
try{
          PropertyDescriptor p = new PropertyDescriptor("propertyNameAsAString", MyDataBean.class);
          if(p.getReadMethod() != null){
              System.out.println("answer " + p.getReadMethod());
              
          }
         }catch(Exception ex){
             System.err.println("caught");
         }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros