Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How To: Java Reflection for has-a-relationship?

 
Prathamesh Gaddam
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

I'm willing to define a map with key as methodName and value as related 'java.lang.reflect.Method'. However the problem is, to get the methods of the class member -[which should/is an user defined class/object].

e.g:


So, how can I solve:

1. Get methods dynamically [java.lang.reflect] of class B [eg: class/es which has specific annotation '@Entity'], within/from class A?
2. Both the classes has same field type & name 'String value'. How to add/get it to/from my map collection?

Note: Using HashMap<String,Method>.

Thank you in advance!
 
Campbell Ritchie
Sheriff
Posts: 48642
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for beginners. Moving.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic