The Pragmatic Bookshelf, 2008. – 303 p.
Why Dynamic Languages?
What’s Groovy?
Why Groovy?
What’s in This Book?
Who Is This Book For?Beginning Groovy.
Getting Started.
Getting Groovy.
Installing Groovy.
Test-Drive Using groovysh.
Using groovy Console.
Running Groovy on the Command Line.
Using an IDE.
Groovy for the Java Eyes.
From Java to Groovy.
JavaBeans.
Optional Parameters.
Implementing Interfaces.
Groovy boolean Evaluation.
Operator Overloading.
Support of Java 5 Language Features.
Gotchas.
Dynamic Typing.
Typing in Java.
Dynamic Typing.
Dynamic Typing != Weak Typing.
Design by Capability.
Optional Typing.
Types in Groovy.
Multimethods.
Dynamic: To Be or Not to Be?
Using Closures.
Closures.
Use of Closures.
Working with Closures.
Closure and Resource Cleanup.
Closures and Coroutines.
Curried Closure.
Dynamic Closures.
Closure Delegation.
Using Closures.
Working with Strings.
Literals and Expressions.
GString Lazy Evaluation Problem.
Multiline String.
String Convenience Methods.
Regular Expressions.
Working with Collections.
Using List.
Iterating Over an ArrayList.
Finder Methods.
Collections’ Convenience Methods.
Using Map.
Iterating Over Map.
Map Convenience Methods.
Using Groovy.
Exploring the GDK.
Object Extensions.
Other Extensions.
Working with XML.
Parsing XML.
Creating XML.
Working with Databases.
Connecting to a Database.
Database Select.
Transforming Data to XML.
Using DataSet.
Inserting and Updating.
Accessing Microsoft Excel.
Working with Scripts and Classes.
The Melting Pot of Java and Groovy.
Running Groovy.
Using Groovy Classes from Groovy.
Using Groovy Classes from Java.
Using Java Classes from Groovy.
Using Groovy Scripts from Groovy.
Using Groovy Scripts from Java.
Ease of Integration.
MOPping Groovy.
Exploring Meta-Object Protocol (MOP).
Groovy Object.
Querying Methods and Properties.
Dynamically Accessing Objects.
Intercepting Methods Using MOP.
Intercepting Methods Using GroovyInterceptable.
Intercepting Methods Using MetaClass.
MOP Method Injection and Synthesis.
Injecting Methods Using Categories.
Injecting Methods Using ExpandoMetaClass.
Injecting Methods into Specific Instances.
Method Synthesis Using methodMissing.
Method Synthesis Using ExpandoMetaClass.
Synthesizing Methods for Specific Instances.
MOPping Up.
Creating Dynamic Classes with Expando.
Method Delegation: Putting It All Together.
Review of MOP Techniques.
Unit Testing and Mocking.
Code in This Book and Automated Unit Tests.
Unit Testing Java and Groovy Code.
Testing for Exceptions.
Mocking.
Mocking by Overriding.
Mocking Using Categories.
Mocking Using ExpandoMetaClass.
Mocking Using Expando.
Mocking Using Map.
Mocking Using the Groovy Mock Library.
Groovy Builders.
Building XML.
Building Swing.
Custom Builder Using Metaprogramming.
Using BuilderSupport.
Using FactoryBuilderSupport.
Creating DSLs in Groovy.
Context.
Fluency.
Types of DSLs.
Designing Internal DSLs.
Groovy and DSLs.
Closures and DSLs.
Method Interception and DSLs.
The Parentheses Limitation and a Workaround.
Categories and DSLs.
ExpandoMetaClass and DSLs.