Here you can find the source of getGenericTypeName(Method method)
Parameter | Description |
---|---|
method | a parameter |
public static String getGenericTypeName(Method method)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { /**//w ww . j a v a 2s .c o m * Get generic type of specific method's return type in string. * <p> * If the return type of method is not generic, null will be returned. * </p> * @author Fangwei_Cai * @create 2016-7-23 15:56:32 * @param method * @return */ public static String getGenericTypeName(Method method) { String genericTypeName = null; String returnTypeName = method.getGenericReturnType().toString(); if (returnTypeName.matches(".*<.*>")) { genericTypeName = returnTypeName.substring(returnTypeName.indexOf("<") + 1, returnTypeName.indexOf(">")); } return genericTypeName; } }