Groovy web console

subscribe to the feed Subscribe
to this
site

map.iteration.closurecalls

Published 2 weeks ago by Daniel with tags map closure iteration
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def map = [
    'settings' : [ "bootStrap" : { log("Main Settings bootstrap") } ],
    "ac": [
        "settings": [ "bootStrap": { log("AC Settings bootstrap") } ],
        "categories": [
            "Arch": [ "settings": [ "bootStrap" : { log("Category bootstrap") } ] ]
        ]
    ]
]

def topLevelBootStrap = map["settings"]["bootStrap"]

topLevelBootStrap()

map.each { root ->
    if (root.key != "settings") {
        log("Working with Key: $root.key")
        def typeLevelBootStrap = root.value["settings"]["bootStrap"]
        typeLevelBootStrap()

        root.value.each { type ->
            if (type.key != "settings") {
                log("Working with Key: $type.key")
                type.value.each { category ->
                    log("Working with Key: $category.key") 
                    def categoryLevelBootStrap = category.value["settings"]["bootStrap"]
                    categoryLevelBootStrap()
                }
            }
        }
    }
}

def log(String message) {
    println "$message"
}