source: branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/DefaultTaskInstanceTraversingVisitor.java @ 1733

Last change on this file since 1733 was 1733, checked in by rkrimmel, 10 years ago

Used Eclipse code cleanup

File size: 3.2 KB
Line 
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
15package de.ugoe.cs.autoquest.tasktrees.treeifc;
16
17/**
18 * <p>
19 * Default implementation for a task instance visitor performing a traversal of
20 * the instances
21 * </p>
22 *
23 * @author Patrick Harms
24 */
25public class DefaultTaskInstanceTraversingVisitor implements
26                ITaskInstanceVisitor {
27
28        /*
29         * (non-Javadoc)
30         *
31         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit(
32         * IEventTaskInstance)
33         */
34        @Override
35        public void visit(IEventTaskInstance eventTaskInstance) {
36                // do nothing
37        }
38
39        /*
40         * (non-Javadoc)
41         *
42         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit(
43         * IIterationInstance)
44         */
45        @Override
46        public void visit(IIterationInstance iterationInstance) {
47                visit((ITaskInstanceList) iterationInstance);
48        }
49
50        /*
51         * (non-Javadoc)
52         *
53         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit(
54         * IOptionalInstance)
55         */
56        @Override
57        public void visit(IOptionalInstance optionalInstance) {
58                if (optionalInstance.getChild() != null) {
59                        optionalInstance.getChild().accept(this);
60                }
61        }
62
63        /*
64         * (non-Javadoc)
65         *
66         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit(
67         * ISelectionInstance)
68         */
69        @Override
70        public void visit(ISelectionInstance selectionInstance) {
71                selectionInstance.getChild().accept(this);
72        }
73
74        /*
75         * (non-Javadoc)
76         *
77         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit(
78         * ISequenceInstance)
79         */
80        @Override
81        public void visit(ISequenceInstance sequenceInstance) {
82                visit((ITaskInstanceList) sequenceInstance);
83        }
84
85        /*
86         * (non-Javadoc)
87         *
88         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceVisitor#visit(
89         * ITaskInstance)
90         */
91        @Override
92        public void visit(ITaskInstance taskInstance) {
93                if (taskInstance instanceof IEventTaskInstance) {
94                        visit((IEventTaskInstance) taskInstance);
95                } else if (taskInstance instanceof IIterationInstance) {
96                        visit((IIterationInstance) taskInstance);
97                } else if (taskInstance instanceof IOptionalInstance) {
98                        visit((IOptionalInstance) taskInstance);
99                } else if (taskInstance instanceof ISelectionInstance) {
100                        visit((ISelectionInstance) taskInstance);
101                } else if (taskInstance instanceof ISequenceInstance) {
102                        visit((ISequenceInstance) taskInstance);
103                }
104        }
105
106        /**
107         * <p>
108         * common implementation for traversing task instance lists.
109         * </p>
110         *
111         * @param taskInstanceList
112         *            the task instance list to be traversed
113         */
114        public void visit(ITaskInstanceList taskInstanceList) {
115                for (final ITaskInstance child : taskInstanceList) {
116                        child.accept(this);
117                }
118        }
119}
Note: See TracBrowser for help on using the repository browser.