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