Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting the map's value object's class name

I have a param Map which can contain strings as well as custom object types as value. How can I get the class name of the Maps value entry.

Right now if I do 
 paramMap.each {
    println(it.value.class.name) 
}

It gives me all entries as java.util.LinkedHashMap$Entry How can I get the actual type of the value stored in the map like String, Configuration, SecurityConfig... etc.

Thanks in advance

like image 340
pri_dev Avatar asked Nov 25 '25 03:11

pri_dev


1 Answers

This should work:

paramMap.each { key, value ->
    println( value.getClass().name )
}
like image 71
tim_yates Avatar answered Nov 27 '25 22:11

tim_yates



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!