Program Listings

Listing 7.1 — Abstract classes in Factory Method
Listing 7.2 — Interface usage in Flyweight
Listing 7.3 — Composition as an alternative to abstract classes in Iterator
Listing 7.4 — Static and dynamic usage of generics in Factory Method
Listing 7.5 — Dynamic usage of generics in Chain of Responsibility
Listing 7.6 — Inner classes used for adaptation in Observer
Listing 7.7 — Anonymous classes used as concrete strategies in Adapter
Listing 7.8 — Enumeration constants as states in State
Listing 7.9Singleton—as—Single—Constant idiom used to implement Singleton
Listing 7.10try—catch—finally idiom used for method combination in Proxy
Listing 7.11 — Covariant return types for prototypical and composite behaviour in Command
Listing 7.12 — Decoration and adaptation required for covariant return types in Builder
Listing 7.13 — Varargs usage in Template Method
Listing 7.14 — Class literals in Interpreter
Listing 7.15 — Stack trace and identification of class members used for sub—classing in Singleton
Listing 7.16 — Stack trace and class literals used to identify caller in Memento
Listing 7.17 — Reusable prototypical factories in Abstract Factory
Listing 7.18 — A reusable reflective factory in Factory Method
Listing 7.19 — Using reflective factories in Abstract Factory
Listing 7.20 — Reflective method invocation in Visitor
Listing 7.21 — Dynamic proxies in Prototype
Listing 7.22 — Annotations as compiler hints in Builder
Listing 7.23 — Annotation usage in Singleton
Listing 7.24 — Synchronisation expressing pattern functionality in Bridge
Listing 7.25 — Synchronisation in Facade
Listing 7.26 — Serialization in Memento
Listing 7.27 — Copyable and cloneable behaviour in Prototype
Listing 7.28 — Dynamic class loading in Singleton