vendredi 16 janvier 2015

I am working on this problem for about 2 days and I still can not solve it. I have this the method:



public List<T> findByKeyValue(String key, String value, Object t) {
Field field;
Class<?> clazz = t.getClass();

field = clazz.getDeclaredField(key);
Type type = field.getType();

if(type.equals(List.class)) {

// HERE IS THE PROBLEM, the value of "field" is "public java.util.List com.cacobr.model.Video.categoryCollection" and categoryCollection is a List <Category>
// **I need to get the class "Category" with Reflection**
// The "field.getGenericType()" command returns "java.util.List <com.cacobr.model.Category>"
// If I could use something like ".getActualTypeArguments()[0]" could return the class "Category" but I can't use this method after a "getGenericType()"

....
}


Can I get the class Category?






Aucun commentaire:

Enregistrer un commentaire