Here you can find the source of getGenericlyTypeCount(Field field)
public static int getGenericlyTypeCount(Field field)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 Robert "Unlogic" Olofsson (unlogic@unlogic.se). * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0-standalone.html ******************************************************************************/ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.WildcardType; public class Main { public static int getGenericlyTypeCount(Field field) { if (field.getGenericType() instanceof ParameterizedType) { ParameterizedType type = (ParameterizedType) field.getGenericType(); return type.getActualTypeArguments().length; }/*ww w . j a v a2 s . c o m*/ return 0; } public static int getGenericlyTypeCount(Method method) { return method.getGenericParameterTypes().length; } public static Type getGenericType(Field field) { Type type = ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; if (type instanceof WildcardType) { //TODO do a little bit more research on this part... return ((WildcardType) type).getUpperBounds()[0]; } else { return type; } } public static Object getGenericType(Method method) { return method.getGenericParameterTypes()[0]; } }