chim
chim

Reputation: 8573

How do I get the default value for a grails domain class property

Given a domain that starts

class MyDomain {

    /* pre injuries board */
    Boolean isSomething = false

Is there a way I can get the default value without instantiating an object?

Upvotes: 1

Views: 1071

Answers (1)

Ted Naleid
Ted Naleid

Reputation: 26801

No, not without doing something like this:

class MyDomain {
    public static final Boolean IS_SOMETHING_DEFAULT = false
    Boolean isSomething = IS_SOMETHING_DEFAULT

     ...
}

Later...

Boolean myDomainDefault = MyDomain.IS_SOMETHING_DEFAULT

Upvotes: 3

Related Questions