Here you can find the source of getGenericTypes(Type[] genericParameterTypes)
Parameter | Description |
---|---|
genericParameterTypes | The genericParameterTypes mentioned above |
public static List<Class<?>> getGenericTypes(Type[] genericParameterTypes)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.*; import java.util.*; public class Main { /**// ww w.j av a2 s. c om * Returns a list of class's for every generic parameter type * given by {@link Method#getGenericParameterTypes()} or {@link Class#getGenericInterfaces()} * * @param genericParameterTypes The genericParameterTypes mentioned above * @return The list of types as class's * @see #getGenericType(Type[]) */ public static List<Class<?>> getGenericTypes(Type[] genericParameterTypes) { List<Class<?>> l = new ArrayList<>(); if (genericParameterTypes == null) return l; try { for (Type t : genericParameterTypes) { ParameterizedType pType = (ParameterizedType) t; for (Type type : pType.getActualTypeArguments()) { l.add((Class<?>) type); } } } catch (Exception e) { // couldn't fetch them .. just returning an empty list .. return new ArrayList<>(); } return l; } }