• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

iterate to all List type property of my objects recursively

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

maybe some expert in reflection can help me with my problem.

i need a way to access a List property on my object, but this must also recursively parse any List property it may find on the List Object.

just a simple traversing with system.out will do. please help. thanks.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look into reflection, ie using the methods on the Class class. Look at the JavaDoc for Class getFields() and getDeclaredFields(). Many frameworks that convert objects to XML or move objects in and out of databases use these tricks to get and set fields. Take a shot at making them work from the doc and let us know how it goes!
 
Jay Richards
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, just wanna share

listing the properties of a class and checking if its a list was easy



ReflectionUtils


just posted my code just in case someone needs a similar approach.

hth,
 
reply
    Bookmark Topic Watch Topic
  • New Topic