[1326] | 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.plugin.usability2.rules.operator.wrapper; |
---|
| 16 | |
---|
| 17 | import java.util.List; |
---|
| 18 | |
---|
| 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; |
---|
| 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; |
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; |
---|
| 22 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; |
---|
| 23 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; |
---|
| 24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 25 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | public abstract class AbstractTaskEntryInstanceVisitor implements ITaskEntryVisitor { |
---|
| 29 | |
---|
| 30 | public abstract void visitInstanceEntry(IEventTaskInstance value); |
---|
| 31 | |
---|
| 32 | private void visitSequence(ISequenceInstance value) { |
---|
| 33 | List<ITaskInstance> children = value.getChildren(); |
---|
| 34 | for (ITaskInstance child : children) { |
---|
| 35 | visitInstance(child); |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | private void visitIteration(IIterationInstance value) { |
---|
| 40 | List<ITaskInstance> children = value.getChildren(); |
---|
| 41 | for (ITaskInstance child : children) { |
---|
| 42 | visitInstance(child); |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | private void visitSelection(ISelectionInstance value) { |
---|
| 47 | ITaskInstance child = value.getChild(); |
---|
| 48 | if(child != null) |
---|
| 49 | visitInstance(child); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | private void visitOptional(IOptionalInstance value) { |
---|
| 53 | ITaskInstance child = value.getChild(); |
---|
| 54 | if(child != null) |
---|
| 55 | visitInstance(child); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | protected void visitInstance(ITaskInstance value) { |
---|
| 59 | if (value instanceof IEventTaskInstance) { |
---|
| 60 | visitInstanceEntry((IEventTaskInstance) value); |
---|
| 61 | } else if (value instanceof ISequenceInstance) { |
---|
| 62 | visitSequence((ISequenceInstance) value); |
---|
| 63 | } else if (value instanceof IIterationInstance) { |
---|
| 64 | visitIteration((IIterationInstance) value); |
---|
| 65 | } else if (value instanceof ISelectionInstance) { |
---|
| 66 | visitSelection((ISelectionInstance) value); |
---|
| 67 | } else if (value instanceof IOptionalInstance) { |
---|
| 68 | visitOptional((IOptionalInstance) value); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | public void visit(ITask value) { |
---|
| 74 | for (ITaskInstance instance : value.getInstances()) { |
---|
| 75 | visitInstance(instance); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | @Override |
---|
| 80 | public void visit(ITaskEntry value) { |
---|
| 81 | visit(value.getReference()); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | } |
---|