1 //----------------------------------------------------------------------
2 //
3 // PerfectJPattern: "Design patterns are good but components are better!"
4 // IElement.java Copyright (c) 2009 Giovanni Azua Garcia
5 // bravegag@hotmail.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 3
10 // of the License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, see <http://www.gnu.org/licenses/>.
19 //
20 //----------------------------------------------------------------------
21 package org.perfectjpattern.core.api.behavioral.visitor;
22
23 /**
24 * <b>Visitor Design Pattern</b>: Represent an operation to be performed on the
25 * elements of an object structure. Visitor lets you define a new operation
26 * without changing the classes of the elements on which it operates.<br/>
27 * <br/>
28 *
29 * <b>Responsibility</b> Abstract definition of "Element"
30 * <ul>
31 * <li>Marker interface for any Element type.</li>
32 * </ul>
33 *
34 * <br/>
35 * Example usage:
36 * <pre><code>
37 * //
38 * // Abstract Base Node for a simple Element hierarchy.
39 * //
40 * abstract
41 * class AbstractNode
42 * implements IElement
43 * {
44 * //--------------------------------------------------------------------
45 * public
46 * BaseNode(String aName)
47 * {
48 * theName = aName;
49 * }
50 *
51 * //--------------------------------------------------------------------
52 * public final String
53 * getName()
54 * {
55 * return theName;
56 * }
57 *
58 * //--------------------------------------------------------------------
59 * // members
60 * //--------------------------------------------------------------------
61 * private final String theName;
62 * }
63 *
64 * //
65 * // RedNode
66 * //
67 * class RedNode
68 * extends AbstractNode
69 * {
70 * //--------------------------------------------------------------------
71 * public
72 * RedNode()
73 * {
74 * super("Red");
75 * }
76 * }
77 *
78 * //
79 * // BlackNode
80 * //
81 * class BlackNode
82 * extends AbstractNode
83 * {
84 * //--------------------------------------------------------------------
85 * public
86 * BlackNode()
87 * {
88 * super("Black");
89 * }
90 * }
91 *
92 * //
93 * // Simple Visitor
94 * //
95 * class NodeVisitor
96 * extends AbstractVisitor<AbstractNode>
97 * {
98 * //--------------------------------------------------------------------
99 * public void
100 * visitRedNode(RedNode aNode)
101 * {
102 * // do RedNode visiting
103 * System.out.println(aNode.getName());
104 * }
105 *
106 * //--------------------------------------------------------------------
107 * public void
108 * visitBlackNode(BlackNode aNode)
109 * {
110 * // do BlackNode visiting
111 * System.out.println(aNode.getName());
112 * }
113 * }
114 *
115 * //
116 * // Usage example
117 * //
118 * IVisitor<AbstractNode> myVisitor = new NodeVisitor();
119 * myVisitor.visit(new RedNode());
120 * myVisitor.visit(new BlackNode());
121 * </code></pre>
122 *
123 * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a>
124 * @version $Revision: 1.0 $ $Date: Jul 1, 2007 6:59:35 AM $
125 */
126 public interface
127 IElement
128 {
129 // marker interface
130 }