lundi 9 juillet 2018

How to find the return type of a method in Groovy

I am trying to convert a Map <String, String> to an Object. Currently getting the groovy.lang.MissingMethodException. Here is the code:

mapToClass(Map map, Object input) {
    map.each { key, value ->
        input."set${key}" value
    }
}

I need to identify the type of input."get${key}" and cast value to the same type before assigning it.

Any ideas?

Thanks.





Aucun commentaire:

Enregistrer un commentaire