[1150] | 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.usability.rules.patterns.visitors;
|
---|
| 16 |
|
---|
[1152] | 17 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
|
---|
[1150] | 18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
|
---|
| 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
|
---|
[1152] | 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
|
---|
| 21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1150] | 22 | import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern;
|
---|
| 23 | import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternVisitor;
|
---|
| 24 | import de.ugoe.cs.autoquest.usability.util.PatternsVisitorUtil;
|
---|
| 25 |
|
---|
| 26 | /**
|
---|
| 27 | * <p>
|
---|
| 28 | * TODO comment
|
---|
| 29 | * </p>
|
---|
| 30 | *
|
---|
| 31 | * @author Alexander Deicke
|
---|
| 32 | */
|
---|
| 33 | public class EndsWithPatternVisitor extends UsagePatternVisitor {
|
---|
| 34 |
|
---|
| 35 | /**
|
---|
| 36 | * <p>
|
---|
| 37 | * TODO: comment
|
---|
| 38 | * </p>
|
---|
| 39 | *
|
---|
| 40 | * @param endsWithPattern
|
---|
| 41 | */
|
---|
| 42 | public EndsWithPatternVisitor(UsagePattern endsWithPattern) {
|
---|
| 43 | this.containedPattern = endsWithPattern;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | /* (non-Javadoc)
|
---|
| 47 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration)
|
---|
| 48 | */
|
---|
| 49 | public void visit(IIteration iteration) {
|
---|
[1152] | 50 | ITaskModel taskModel = PatternsVisitorUtil.createTaskModelFromNode(iteration);
|
---|
| 51 | this.present = containedPattern.containedIn(taskModel);
|
---|
[1150] | 52 |
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /* (non-Javadoc)
|
---|
| 56 | * @see de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence)
|
---|
| 57 | */
|
---|
| 58 | public void visit(ISequence sequence) {
|
---|
[1152] | 59 | ITask lastTask = PatternsVisitorUtil.lastNodeOf(sequence.getChildren());
|
---|
| 60 | ITaskModel taskModel;
|
---|
| 61 | if(isEvent(lastTask)) {
|
---|
| 62 | taskModel = PatternsVisitorUtil.createTaskModelFromNode(sequence);
|
---|
[1150] | 63 | } else {
|
---|
[1152] | 64 | taskModel = PatternsVisitorUtil.createTaskModelFromNode(lastTask);
|
---|
[1150] | 65 | }
|
---|
[1152] | 66 | this.present = containedPattern.containedIn(taskModel);
|
---|
[1150] | 67 | }
|
---|
| 68 |
|
---|
[1152] | 69 | private boolean isEvent(ITask lastTask) {
|
---|
| 70 | return lastTask instanceof IEventTask;
|
---|
[1150] | 71 | }
|
---|
| 72 |
|
---|
| 73 | }
|
---|