user3914455
user3914455

Reputation: 257

Grails , domain properties .. How can i get at the value?

In a domain class I have a property

class Domain {
   String someValue
}

I can get at that directly via the property value - domainInstance.someValue

I now have a requirement to create a hierarchy such that if someValue isn't set I get it from some other property of the domain ..

So I implemented my own version of getSomeValue

...

getSomeValue(){
  someValue ?: someOtherValue 
}  

But this just invokes itself .. Can I get at the value 'someValue' directly or will it always invoke the getSomeValue method?

Upvotes: 2

Views: 212

Answers (1)

Gleydson S. Tavares
Gleydson S. Tavares

Reputation: 600

Groovy automatically generates gets and sets:

class Domain {
 String someValue  
}
Domain domain = new Domain(somevalue:"somevalue")
//or domain.setSomeValue("someValue)
println domain.getSomeValue

if you want to access directly just do:

domain.@someValue

Upvotes: 1

Related Questions