Groovy for Domain-specific Languages - Second Edition
Power Groovy DSL Features [ 158 ] Using GPath to navigate a node tree We've used GPath in the preceding code to access the node ...
Chapter 7 [ 159 ] Any Swing app I've ever worked on has been a mess of component initialization code, intermingled with anonymou ...
Power Groovy DSL Features [ 160 ] }) } scrollPane (constraints:BorderLayout.SOUTH){ results = table() { tableModel(list:[]) { pr ...
Chapter 7 [ 161 ] The following result is a quick and nasty UI for Twitter searching: Method pointers Groovy allows you to assig ...
Power Groovy DSL Features [ 162 ] The difficulty with method pointers to instance methods is being sure what instance the method ...
Chapter 7 [ 163 ] try { Class iClazz = Class.forName("java.lang.Integer"); Field[] fields = iClazz.getDeclaredFields(); System.o ...
Power Groovy DSL Features [ 164 ] Groovy reflection shortcuts Groovy, as we would expect by now, provides shortcuts that let us ...
Chapter 7 [ 165 ] Expandos An Expando is a dynamic representation of a typical Groovy bean. Expandos support typical get and set ...
Power Groovy DSL Features [ 166 ] A neat trick with expandos is what happens when we store a closure in a property. As we would ...
Chapter 7 [ 167 ] Here we create a CustomerPrinter class that pretty prints a customer object. We can then make use of this clas ...
Power Groovy DSL Features [ 168 ] id: 1001 street: 1 Rock Road surname: Flintstone Customer has following properties city: Bedro ...
Chapter 7 [ 169 ] Conveniently, this pattern is the same as the one used in Groovy categories, which means that the Apache Commo ...
Power Groovy DSL Features [ 170 ] given: def fred = new Customer(id:1001,firstName:"Fred", surname:"Flintstone", street:"1 Rock ...
Chapter 7 [ 171 ] /** * Sets the given property to the new value. */ void setProperty(String propertyName, Object newValue); /** ...
Power Groovy DSL Features [ 172 ] The Groovy runtime maintains a single MetaClass per Groovy class, and these operate in close q ...
Chapter 7 [ 173 ] def customerList = [ fred, barney] when: for (customer in customerList) customer.prettyPrint() then: """Custom ...
Power Groovy DSL Features [ 174 ] In addition to the this keyword, Groovy has two other keywords that are referred only in the c ...
Chapter 7 [ 175 ] } } given: "A class with an Instance method" def clazz = new Clazz() when: "In a class instance method 'this' ...
Power Groovy DSL Features [ 176 ] Running the preceding code will output the following text: Class method this is : class Clazz ...
Chapter 7 [ 177 ] No matter how far you look in the documentation for MarkupBuilder, you won't find anything about it having a c ...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf