mardi 23 juin 2015

Inspect and print nested Javabean properties

I have nested Javabeans, for example:

public BeanX {
   private int x1;
   private int x2;
   private List<BeanY> beany;
   …// getters and setters
}

public BeanY {
   private int x3;
   private int x4;
   private List<String> strings;
   …// getters and setters
}

In Java code, I only know the name of the first Javabean (BeanX). Is it possible to discover all properties of all types used by BeanX and print them for example as follows:

BeanX.x1
BeanX.x2
BeanX.beany (BeanY)
BeanY.x3
BeabY.x4
BeanY.strings  (String)

Reference: Javabean Introspector - what is in my List?





Aucun commentaire:

Enregistrer un commentaire