How can I get a map of the key/values of only the user-defined properties on one of my domain objects?
Problem is if I do this myself, I get my properties plus class
Try this
class Person{
String name
String address
}
def filtered = ['class', 'active', 'metaClass']
def alex = new Person(name:'alex', address:'my home')
def props = alex.properties.collect{it}.findAll{!filtered.contains(it.key)}
props.each{
println it
}
It also works if you use alex.metaClass.surname = 'such'. This property will be displayed in the each loop