Datum: 16.05.18 16:00 (GMT+01:00) An: d...@groovy.incubator.apache.org
Betreff: Re: Java object conversion using ConfigSlurper
Yes Jesper,
It works. But, If that `MyConfig` class has fields of `List` or `Map` types,
then it does not work. I am looking this feature as a way of converting
`Config
Datum: 16.05.18 16:00 (GMT+01:00) An: d...@groovy.incubator.apache.org
Betreff: Re: Java object conversion using ConfigSlurper
Yes Jesper,
It works. But, If that `MyConfig` class has fields of `List` or `Map` types,
then it does not work. I am looking this feature as a way of converting
`Config
ff: Re: Java object conversion using ConfigSlurper
Hi Mario Garcia,
Groovy already has Map coercion feature with which the methods of any class
can be delegated to the closures in Map. This uses `as` keyword.
If we implement `asType(Class)` in `ConfigObject` (ConfigObject already
implements Map)
ff: Re: Java object conversion using ConfigSlurper
Hi Mario Garcia,
Groovy already has Map coercion feature with which the methods of any class
can be delegated to the closures in Map. This uses `as` keyword.
If we implement `asType(Class)` in `ConfigObject` (ConfigObject already
implements Map)
Hi Adithyank
> On 16 May 2018, at 12.52, adithyank wrote:
>
> Hi Mario Garcia,
>
> Groovy already has Map coercion feature with which the methods of any class
> can be delegated to the closures in Map. This uses `as` keyword.
>
> If we implement `asType(Class)` in
Hi Mario Garcia,
Groovy already has Map coercion feature with which the methods of any class
can be delegated to the closures in Map. This uses `as` keyword.
If we implement `asType(Class)` in `ConfigObject` (ConfigObject already
implements Map), some of the functionalities of existing coercion
Hi, good work :)
It seems a nice feature, but I'm wondering why having two different methods
doing the same ? asType and getAs.
- I think is always better to avoid having two methods doing the same,
specially when asType can be called both directly or via sugar syntax.
- I also think
I think it is nice for me :-)
Cheers,
Daniel.Sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Ok. Thanks Daniel.
I will proceed in the below way.
Pls advice
1. I will write new class `ConfigCustomObjectBuilder` in
`ConfigSlurper.groovy` to convert given ConfigObject to custom class
instance
2. I will add below new method in ConfigObject
T getAs(Class dataStructure)
{
I think it is useful especially for Java developers. PR is welcome.
P.S. it would be better if the Java class is a Java bean(with getters and
setters)
Cheers,
Daniel.Sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Team,
ConfigSlurper can be used to parse groovy-styled configurations and get
them as *ConfigObject. *As an additional feature, either ConfigSlurper can
be enhanced or a new class can be written to return java object itself from
the configuration. Example below
*config.groovy*
myownconfig {
11 matches
Mail list logo