Extending with Visitor

Suppose that you accept an assignment to help bring up a new Oozinoz factory in Dublin, Ireland. The developers in Dublin have created an object model of the new factory's machine composition and have made this model accessible as the static dublin() method of the OozinozFactory class. To display this composite, the developers created a MachineTreeModel class to adapt the model's information to a JTree object's needs. (The code for the MachineTreeModel class is in the com.oozinoz.dublin package.) Displaying the new factory's machines requires building an instance of MachineTreeModel from the factory composite and wrapping this model in Swing components:

 package com.oozinoz.applications; import javax.swing.*; import javax.swing.tree.*; ...

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.