I got a map that extends three layers deep and on the other side I got a plugin that should check if a given three-set of strings is in the map. So far it’s a statically written map directly in the plugin file, but I want to change it so that user of the plugin can freely configure the map.
Needless to say, this is a ton of syntax overhead and not exactly flexible either. My idea was that this could be written in an external .properties file as nested DSL, but I don’t know what the best way to do that.
Unfortunately not, because that would introduce a lot of duplication overhead, the very thing I’m trying to avoid here (e.g. “level1/level21/” would appear multiple times).
My ideal solution would look like this, but I don’t have any idea if there’s a way at all to replicate it:
What you are looking for are named domain object containers. Have a look at the project.container method. That gives you exactly the syntax you are looking for.
test {
serverName = 'http://testserver'
mail {
server = 'mail.testserver'
}
}
prod {
serverName = 'http://www.mrhaki.com'
mail {
port = 552
server = 'mail.host.com'
}
}