You can just pass in a Map of properties to an Object and as long as you don't have any properties in your Map that are not defined in the class, it'll work fine. As an example:
class Person {
String name
Integer age
String address
}
def map = [ name: "Joe", age: 4, address: "Somewhere"]
Person p = new Person(map)
println "Peson name: $p.name, address: $p.address"
This comes in real handy when want you want to populate some groovy sql results into a collection of typed objects. As an example:
def getPersons() {
def persons = []
sql.eachRow("Select * from Person") {
persons << new Person( it.toRowResult() )
}
return persons
}