1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | package de.ugoe.cs.autoquest.tasktrees.treeifc; |
---|
16 | |
---|
17 | // TODO: Auto-generated Javadoc |
---|
18 | /** |
---|
19 | * <p> |
---|
20 | * Default implementation for a task instance visitor performing a traversal of |
---|
21 | * the instances |
---|
22 | * </p>. |
---|
23 | * |
---|
24 | * @author Patrick Harms |
---|
25 | */ |
---|
26 | public class DefaultTaskInstanceTraversingVisitor implements |
---|
27 | ITaskInstanceVisitor { |
---|
28 | |
---|
29 | /* |
---|
30 | * (non-Javadoc) |
---|
31 | * |
---|
32 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit( |
---|
33 | * IEventTaskInstance) |
---|
34 | */ |
---|
35 | @Override |
---|
36 | public void visit(IEventTaskInstance eventTaskInstance) { |
---|
37 | // do nothing |
---|
38 | } |
---|
39 | |
---|
40 | /* |
---|
41 | * (non-Javadoc) |
---|
42 | * |
---|
43 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit( |
---|
44 | * IIterationInstance) |
---|
45 | */ |
---|
46 | @Override |
---|
47 | public void visit(IIterationInstance iterationInstance) { |
---|
48 | visit((ITaskInstanceList) iterationInstance); |
---|
49 | } |
---|
50 | |
---|
51 | /* |
---|
52 | * (non-Javadoc) |
---|
53 | * |
---|
54 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit( |
---|
55 | * IOptionalInstance) |
---|
56 | */ |
---|
57 | @Override |
---|
58 | public void visit(IOptionalInstance optionalInstance) { |
---|
59 | if (optionalInstance.getChild() != null) { |
---|
60 | optionalInstance.getChild().accept(this); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | /* |
---|
65 | * (non-Javadoc) |
---|
66 | * |
---|
67 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit( |
---|
68 | * ISelectionInstance) |
---|
69 | */ |
---|
70 | @Override |
---|
71 | public void visit(ISelectionInstance selectionInstance) { |
---|
72 | selectionInstance.getChild().accept(this); |
---|
73 | } |
---|
74 | |
---|
75 | /* |
---|
76 | * (non-Javadoc) |
---|
77 | * |
---|
78 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit( |
---|
79 | * ISequenceInstance) |
---|
80 | */ |
---|
81 | @Override |
---|
82 | public void visit(ISequenceInstance sequenceInstance) { |
---|
83 | visit((ITaskInstanceList) sequenceInstance); |
---|
84 | } |
---|
85 | |
---|
86 | /* |
---|
87 | * (non-Javadoc) |
---|
88 | * |
---|
89 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit( |
---|
90 | * ITaskInstance) |
---|
91 | */ |
---|
92 | @Override |
---|
93 | public void visit(ITaskInstance taskInstance) { |
---|
94 | if (taskInstance instanceof IEventTaskInstance) { |
---|
95 | visit((IEventTaskInstance) taskInstance); |
---|
96 | } else if (taskInstance instanceof IIterationInstance) { |
---|
97 | visit((IIterationInstance) taskInstance); |
---|
98 | } else if (taskInstance instanceof IOptionalInstance) { |
---|
99 | visit((IOptionalInstance) taskInstance); |
---|
100 | } else if (taskInstance instanceof ISelectionInstance) { |
---|
101 | visit((ISelectionInstance) taskInstance); |
---|
102 | } else if (taskInstance instanceof ISequenceInstance) { |
---|
103 | visit((ISequenceInstance) taskInstance); |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * <p> |
---|
109 | * common implementation for traversing task instance lists. |
---|
110 | * </p> |
---|
111 | * |
---|
112 | * @param taskInstanceList |
---|
113 | * the task instance list to be traversed |
---|
114 | */ |
---|
115 | public void visit(ITaskInstanceList taskInstanceList) { |
---|
116 | for (final ITaskInstance child : taskInstanceList) { |
---|
117 | child.accept(this); |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|