source: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/EventTaskComparisonRule.java @ 1154

Last change on this file since 1154 was 1146, checked in by pharms, 11 years ago
  • complete refactoring of task tree model with a separation of task models and task instances
  • appropriate adaptation of task tree generation process
  • appropriate adaptation of commands and task tree visualization
File size: 2.4 KB
RevLine 
[1113]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
[1146]15package de.ugoe.cs.autoquest.tasktrees.taskequality;
[807]16
[922]17import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
[1146]18import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
[807]19
20/**
21 * <p>
[1146]22 * This rule identifies two tasks as lexically equal, if they are both event tasks and
[807]23 * if their respective event types and targets equal.
24 * </p>
25 *
26 * @author Patrick Harms
27 */
[1146]28public class EventTaskComparisonRule implements TaskComparisonRule {
[807]29   
[1125]30    /* (non-Javadoc)
[1146]31     * @see NodeComparisonRule#isApplicable(ITask, ITask)
[807]32     */
33    @Override
[1146]34    public boolean isApplicable(ITask task1, ITask task2) {
35        return (task1 instanceof IEventTask) && (task2 instanceof IEventTask);
[1125]36    }
[807]37
[1125]38    /* (non-Javadoc)
[1146]39     * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)
[1125]40     */
41    @Override
[1146]42    public boolean areLexicallyEqual(ITask task1, ITask task2) {
43        IEventTask eventTask1 = (IEventTask) task1;
44        IEventTask eventTask2 = (IEventTask) task2;
[807]45       
[1146]46        return (eventTask1.getEventType().equals(eventTask2.getEventType()) &&
47                eventTask1.getEventTarget().equals(eventTask2.getEventTarget()));
[1125]48    }
49
50    /* (non-Javadoc)
[1146]51     * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)
[1125]52     */
53    @Override
[1146]54    public boolean areSyntacticallyEqual(ITask task1, ITask task2) {
55        return areLexicallyEqual(task1, task2);
[1125]56    }
57
58    /* (non-Javadoc)
[1146]59     * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)
[1125]60     */
61    @Override
[1146]62    public boolean areSemanticallyEqual(ITask task1, ITask task2) {
63        return areLexicallyEqual(task1, task2);
[1125]64    }
65
66    @Override
[1146]67    public TaskEquality compare(ITask task1, ITask task2) {
68        if (areLexicallyEqual(task1, task2)) {
69            return TaskEquality.LEXICALLY_EQUAL;
[807]70        }
71        else {
[1146]72            return TaskEquality.UNEQUAL;
[807]73        }
74    }
75
76}
Note: See TracBrowser for help on using the repository browser.