Reputation: 257
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
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