Groovy for Domain-specific Languages - Second Edition
The Groovy Language [ 58 ] The preceding method returns String object, while the type of the object passed in is dynamic, so Gro ...
Chapter 4 [ 59 ] No matter what value is contained in the last statement in a method, if the return type is void, the value retu ...
The Groovy Language [ 60 ] This code snippet shows how we can optionally use getter/setter methods to manipulate the name field ...
Chapter 4 [ 61 ] When passing the map directly to the Customer constructor, we can omit the map literal square brackets, as seen ...
The Groovy Language [ 62 ] Here, we are asserting a value within a complex structure of arrays and maps. Groovy will happily bre ...
Chapter 4 [ 63 ] For all intents and purposes, you can treat any numeric value as if it is both an object-based numeric value an ...
The Groovy Language [ 64 ] "We don't need to escape quotes in a multi-line string" ''' def name = "Daniel Dewdney" def customerS ...
Chapter 4 [ 65 ] The final assertion shown in the preceding code introduces yet another Groovy string syntax, which goes under t ...
The Groovy Language [ 66 ] You can find JavaDoc under the class documentation for java.util.regex.Pattern. The following is a tr ...
Chapter 4 [ 67 ] Every time we use the match and find operators, behind the scenes, Groovy transforms the regex string into a ja ...
The Groovy Language [ 68 ] Groovy methods look very similar to Java methods except that public visibility is the default, so the ...
Chapter 4 [ 69 ] Closures can look deceptively similar to method calls in their usage. In the next code snippet, we will create ...
The Groovy Language [ 70 ] We can pass a closure as a method parameter. Many useful collection methods take a closure as a param ...
Chapter 4 [ 71 ] if(condition) { } else if (condition) { } else { } Groovy Truth The only difference is in how Groovy interprets ...
The Groovy Language [ 72 ] expect: "it will evaluate to false" !nullString !uninitializedString !customer !array !map !emptyStri ...
Chapter 4 [ 73 ] We can set up a Spock test to assert that this is true for various values of a: given: def b = 'value1' def c = ...
The Groovy Language [ 74 ] The Elvis operator has the added benefit of avoiding a second evaluation of the initial predicate. Th ...
Chapter 4 [ 75 ] where: a | b | c -1 | 1 | 2 0 | 1 | 1 1 | 2 | 1 One of my favorite Groovy shortcuts is what we can do if we com ...
The Groovy Language [ 76 ] The switch statement Groovy adds some neat features to the switch statement by adding some extra opti ...
Chapter 4 [ 77 ] We can iterate all the values of a list without any funky Iterator objects: for ( x in ["apple", "orange", "pea ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf