jeudi 29 octobre 2015

How to get name parametr in List with reflection [duplicate]

This question already has an answer here:

I have a Lot List like this:

..
public java.util.List<ComId> comIds;
public java.util.List<Notification> notifications;
public java.util.List<ProductItem> productItems;
..

And i using java reflection to read this.

Input:

for (Field f : fields) {
    Class<?> type = f.getType();
    String genName = f.getGenericType().getTypeName().toString();
}

I get such a result:

java.util.List<my.package.Customer.ComId>
java.util.List<my.package.Customer.Notification>
java.util.List<my.package.Customer.ProductItem>
..

I just want get only:

ComId
Notification
ProductItem
..

How i can do that?





Aucun commentaire:

Enregistrer un commentaire