Here you can find the source of getGenericType(Method setter)
private static Class<?> getGenericType(Method setter)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; public class Main { private static Class<?> getGenericType(Method setter) { if (setter != null) { Type[] genericParameterTypes = setter.getGenericParameterTypes(); for (int i = 0; i < genericParameterTypes.length; i++) { if (genericParameterTypes[i] instanceof ParameterizedType) { Type[] parameters = ((ParameterizedType) genericParameterTypes[i]).getActualTypeArguments(); if (parameters != null && parameters.length == 1) { return (Class<?>) parameters[0]; }//from ww w . j a v a2 s . co m } } } return null; } }