Groovy for Domain-specific Languages - Second Edition
Building a Builder [ 258 ] """createNode(customers) createNode(customer) setParent(customers, customer) createNode(id, 1001) set ...
Chapter 10 [ 259 ] Now that we understand the building mechanism, it is a trivial matter to change our LogBuilder script to crea ...
Building a Builder [ 260 ] indent.times {print " "} println "</${node}>" } } given: def builder = new PoorMansTagBuilder20 ...
Chapter 10 [ 261 ] A database builder Every application that includes a database needs some means of setting up seed, demo, or t ...
Building a Builder [ 262 ] Grails has a migration plugin that can be installed. The migration tool will execute a SQL update scr ...
Chapter 10 [ 263 ] Ideally, we want to be able to describe our data in a declarative style. The syntax of the data definition sh ...
Building a Builder [ 264 ] amount(3) price(1.00) } } } } This will work. However, it is not immediately clear to a reader of thi ...
Chapter 10 [ 265 ] return new Customer(firstName:"", lastName:"") case "invoice": return new Invoice() case "salesOrder": return ...
Building a Builder [ 266 ] Here, we have implemented all four createNode methods. The method tag is passed as the name parameter ...
Chapter 10 [ 267 ] FactoryBuilderSupport BuilderSupport is the base class for many of the builder classes provided in the Groovy ...
Building a Builder [ 268 ] To implement a builder with the FactoryBuilderSupport class, we must first declare a Factory class fo ...
Chapter 10 [ 269 ] We then define a factory class for the customer object. The methods that we need to implement are isLeaf (ret ...
Building a Builder [ 270 ] else invoice = new Invoice() if (value != null && value instanceof Customer) value.addToInvoi ...
Chapter 10 [ 271 ] parent.addToOrders(sales_order) } public void onNodeCompleted(FactoryBuilderSupport builder, Object parent, O ...
Building a Builder [ 272 ] } def registerSalesOrder() { registerFactory("sales_order", new SalesOrderFactory()) } FactoryBuilder ...
Chapter 10 [ 273 ] Summary In Chapter 7, Power Groovy DSL Features, we discussed how builders worked via the Groovy MOP. In this ...
http://www.ebook3000.com ...
[ 275 ] Implementing a Rules DSL In this chapter, we will look at how we can use Groovy to build a DSL that is capable of implem ...
Implementing a Rules DSL [ 276 ] Groovy bindings Every Groovy script has an associated binding object. The binding is where inst ...
Chapter 11 [ 277 ] Most of the examples we have encountered in the book are written to be run as Spock tests. The next few examp ...
«
10
11
12
13
14
15
16
17
18
19
»
Free download pdf