Groovy for Domain-specific Languages - Second Edition
AST Transformations [ 218 ] Testing the state machine DSL With our state machine complete, we hope now that it will work as well ...
Chapter 8 [ 219 ] ledSwitch.switchOn() then: ledSwitch.state == 'ON' when: ledSwitch.switchOn() then: ledSwitch.state == 'ON' wh ...
AST Transformations [ 220 ] when: "PAUSED" next = "LOADED" event: "unload" when: "LOADED" next = "EMPTY" Those old tape decks we ...
Chapter 8 [ 221 ] Compiling and packaging an AST transformation Within the code examples in this chapter, we have two categories ...
AST Transformations [ 222 ] We mentioned earlier that the Groovy compiler supports custom file extensions. If we add a META-INF/ ...
[ 223 ] Existing Groovy DSLs By now, we have covered a lot of ground in describing the DSL-enabling features of Groovy. In this ...
Existing Groovy DSLs [ 224 ] Grails programmers use GORM classes as a mini language for describing the persistent objects in the ...
Chapter 9 [ 225 ] Grails has a number of shortcut commands that allow us to quickly build out the objects for our model. In this ...
Existing Groovy DSLs [ 226 ] GORM has automatically created a customer table for us in the devDB database. The table has two fie ...
Chapter 9 [ 227 ] when: fred.firstName = "Freddie" fred.save() def customers = Customer.list() then: customers[0].firstName == ' ...
Existing Groovy DSLs [ 228 ] So what does Grails actually do? The answer is all of the tasks mentioned earlier, depending on whi ...
Chapter 9 [ 229 ] If we model our domain directly in the database, we need to build and manage tables, and make associations bet ...
Existing Groovy DSLs [ 230 ] These basic one-to-one associations can be inferred by GORM just by interrogating the fields in eac ...
Chapter 9 [ 231 ] void "belongsTo causes cascaded delete"() { given: def addr = new Address(street:"1 Rock Road", city:"Bedrock" ...
Existing Groovy DSLs [ 232 ] Constraints You will have noticed that every domain class produced by the grails create- domain-cla ...
Chapter 9 [ 233 ] We can illustrate the same technique by using MarkupBuilder. The Markup class in the following code snippet ju ...
Existing Groovy DSLs [ 234 ] To indicate the "has many" associations between Customer/Invoice and Invoice/ SalesOrder, we insert ...
Chapter 9 [ 235 ] invoice.addToOrders(new SalesOrder(sku:"productid02", amount:3, price:1.50)) invoice.addToOrders(new SalesOrde ...
Existing Groovy DSLs [ 236 ] When maintaining a database, it does not matter whether we add songs to artistes or artistes to son ...
Chapter 9 [ 237 ] Composition Composition is used when, instead of having separate tables for each business object, we would lik ...
«
8
9
10
11
12
13
14
15
16
17
»
Free download pdf