groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adithyank <>
Subject Re: Java object conversion using ConfigSlurper
Date Tue, 15 May 2018 07:15:31 GMT
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

2. I will add below new method in ConfigObject

   T getAs(Class<T> dataStructure)
       return, Class<T>

3. So, the callers of the method can do the below steps

   a. ConfigObject co = new ConfigSlurper().parse(...)
   b. Do required co.merge(...)
   c. MyConfig mc = co.getAs(MyConfig)
   d. use mc further

4. Optionally, we can implement `asType(Class)` method in `ConfigObject`
   so that callers can use below syntax

   c. MyConfig mc = co as MyConfig


K Adithyan

Daniel.Sun wrote
> 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)

Sent from:

View raw message