Groovy web console

subscribe to the feed Subscribe
to this
site

Untitled

Published 2 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Foo {
    def properties = [
        blah: true,
        fasel: false,
        blubb: true
    ]

    boolean isDirty(String s) {
        return properties[s]
    }
}

def foo = new Foo()

def dirtyMap = [:]
foo.properties.each {
    if(foo.isDirty(it.key)) {
        dirtyMap.put(it.key,it.value)
    }
}

assert dirtyMap == [blah: true, blubb: true]

assert foo.properties.findAll { foo.isDirty(it.key) } == [blah: true, blubb: true]