So when I override the toString() method using the method below (the same way I use in almost every one of my other Domain classes across many projects), it causes a null pointer when creating an instance of this object. Removing the toString() fixes this error. No clue why. 🙁
class Vertical {
String name
static constraints = {
name(nullable: true)
}
@Override
String toString() {
return name
}
}
I would be a little bit more defensive and go with:
Just to make sure not to send back nulls, since the toString ought to be printable.