groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "K Adithyan (tech)" <>
Subject Java object conversion using ConfigSlurper
Date Thu, 10 May 2018 19:33:25 GMT

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


myownconfig {
      name = 'Threadpool'
     displayLabel = "Thread Pool"
     threadCount = 12


public class MyConfig
     String name;
     String displayLabel
     int threadCount

MyConfig myConfig = new ConfigClassConver().object('myownconfig',
println ...

I have implemented this functionality for one of my project needs. If the
team feels, it can be added groovy itself, then the discussion can proceed
in what could be the class name, what features, etc.

What I have given is a sample only. There are couple of other features,
like ConfigSlurper.merge(), parsing multiple files in one directory
(optionally, recursive too), etc.

I feel this will be a good addition to groovy itself.

Pls comment


K Adithyan

View raw message