private List<Class<?>> getGenericParameterClasses(Method setterMethod, int depth) {
        Type t = setterMethod.getGenericParameterTypes()[0];
        ParameterizedType pType = (ParameterizedType) t;
        List<Class<?>> classes = new ArrayList<>();
        for (int i = 0; i < depth; i++) {
            classes.add((Class<?>) pType.getActualTypeArguments()[i]);
        }
        return classes;
    }
private List < Class < ? > > getGenericParameterClasses ( Method setterMethod , int depth ) { Type t = setterMethod . getGenericParameterTypes ( ) [ 0 ] ; ParameterizedType pType = ( ParameterizedType ) t ; List < Class < ? > > classes = new ArrayList < > ( ) ; for ( int i = 0 ; i < depth ; i ++ ) { classes . add ( ( Class < ? > ) pType . getActualTypeArguments ( ) [ i ] ) ; } return classes ; }
Loads the generic parameter classes up to the given depth (1 for lists, 2 for maps)