Barodapride
Barodapride

Reputation: 3723

Accessing Groovy properties or methods

I have a simple question. If I have an HttpResponseDecorator(groovyx.net.http.HttpResponseDecorator) how come I can do response.status to get the response code? When I'm debugging I don't see this property available in the object. I looked up the API and I don't see the status property available. How is response.status working? Am I missing a language feature?

Upvotes: 0

Views: 356

Answers (1)

Rotem
Rotem

Reputation: 1379

The Groovy property is a combination of a private field and getters/setters. Groovy will then generate the getters/setters appropriately.

For example:

class Person {
    String name                             
    int age
}

Properties are accessed by name and will call the getter or setter transparently. I would recommend read more in the Groovy documentation for field and properties.

Upvotes: 1

Related Questions