How to get name of method parameter/argument in gr

2019-08-09 00:11发布

问题:

I have groovy script that has a function with 2 arguments, one of which is a hashmap. I want to check the name of a hashmap variable contains a substring or not, inside a function. How do i do it?

def myfunc(String var, HashMap var2)
{
    // need a routine to retrive the name of the variable var2
} 

回答1:

It's well explained here : Getting the name of a method parameter

To access groovy script's method follow syntax :

metaClass.methods