[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> |
---|
[1733] | 19 | * Default implementation for a task instance visitor performing a traversal of |
---|
| 20 | * the instances |
---|
[1406] | 21 | * </p> |
---|
| 22 | * |
---|
| 23 | * @author Patrick Harms |
---|
| 24 | */ |
---|
[1733] | 25 | public class DefaultTaskInstanceTraversingVisitor implements |
---|
| 26 | ITaskInstanceVisitor { |
---|
[1406] | 27 | |
---|
[1733] | 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 | } |
---|
[1406] | 38 | |
---|
[1733] | 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 | } |
---|
[1406] | 49 | |
---|
[1733] | 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 | } |
---|
[1406] | 62 | |
---|
[1733] | 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 | } |
---|
[1406] | 73 | |
---|
[1733] | 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 | } |
---|
[1406] | 84 | |
---|
[1733] | 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 | } |
---|
[1406] | 105 | |
---|
[1733] | 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 | } |
---|
[1406] | 119 | } |
---|