What does this syntax mean in Groovy?
class CreateMessagePage extends Page {
static at = { assert title == 'Messages : Create'; true }
static url = 'messages/form'
static content = {
submit { $('input[type=submit]') }
MyVeryStrangeForm { $('form') }
errors(required:false) { $('label.error, .alert-error')?.text() }
}
}
(taken from Spring MVC Test HtmlUnit manual)
The question is about Groovy and I would like know the answer in Groovy terms.
What is content
? Is it a static variable? Is its name is random or predefined by base class of Page
?
What is =
(equal sign) after it? Is it an assignment operator?
What is at the right hand side of =
? Is this a closure? Or if this an anonymous class? Or if these are the same?
What is submit
inside curly braces?
Is this a variable? Why there is no assignment operator after it then?
Is this a function definition? Can I define functions in arbitrary places in Groovy? If this is a function definition, then what is errors
then?
Is submit
is a function call, receiving { $('input[type=submit]') }
as a parameter? If yes, then where is this function can be defined? For example, where is MyVeryStrangeForm
defined (is nowhere)?
If this was function call, then it won't work since it's undefined...
form = { $('form') }
butform { $('form') }
, i.e. without assignment? – Claycomb