> On 16 May 2018, at 16.00, adithyank <[email protected]> wrote:
>
> It works. But, If that `MyConfig` class has fields of `List` or `Map` types,
> then it does not work.
Actually it does work, too:
ConfigObject co = new ConfigSlurper().parse("""
myownconfig {
name = 'Threadpool'
displayLabel = "Thread Pool"
threadCount = 12
bleh {
y = "not"
}
fleep = [ 'a', 'b' ]
nested {
threadCount = 12
}
}
""")
public class MyConfig
{
String name
String displayLabel
int threadCount
Map bleh
List fleep
MyConfig nested
}
> I am looking this feature as a way of converting
> `ConfigObject` (inturn Map<String, Map<Stirng, Map<String,
> Map<String>>>>....) of any levels to its respective java object with
> nested `List<anyclass>`, `Map<anyclass>`, `Other classes`.
>
Anyway, I'm sure you can find examples which aren't covered now.
>
> 1. I will look on the existing coercion codes to some how fit this use case
> of creating nested objects recursively
> or
> 2. `T ConfigObject.getAs(Class<T>)` can be implemented without affecting the
> existing semantics of `Map as SomeClass`
>
I'd go for option "2" in that case - not that I can vote :-)
-Jesper