Last change
on this file since 818 was
807,
checked in by pharms, 12 years ago
|
- improved node equality comparison to match the principle of lexical, syntactical and semantical node equality. As a result, more condensed task trees are created.
|
File size:
1.2 KB
|
Line | |
---|
1 | package de.ugoe.cs.quest.tasktrees.nodeequality; |
---|
2 | |
---|
3 | import de.ugoe.cs.quest.tasktrees.treeifc.IEventTask; |
---|
4 | import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNode; |
---|
5 | |
---|
6 | /** |
---|
7 | * <p> |
---|
8 | * This rule identifies two task tree nodes as lexically equal, if they are both event tasks and |
---|
9 | * if their respective event types and targets equal. |
---|
10 | * </p> |
---|
11 | * |
---|
12 | * @author Patrick Harms |
---|
13 | */ |
---|
14 | public class EventTaskComparisonRule implements NodeComparisonRule { |
---|
15 | |
---|
16 | /* |
---|
17 | * (non-Javadoc) |
---|
18 | * |
---|
19 | * @see de.ugoe.cs.tasktree.nodeequality.NodeEqualityRule#apply(TaskTreeNode, TaskTreeNode) |
---|
20 | */ |
---|
21 | @Override |
---|
22 | public NodeEquality compare(ITaskTreeNode node1, ITaskTreeNode node2) { |
---|
23 | if ((!(node1 instanceof IEventTask)) || (!(node2 instanceof IEventTask))) { |
---|
24 | return null; |
---|
25 | } |
---|
26 | |
---|
27 | if (node1 == node2) { |
---|
28 | return NodeEquality.IDENTICAL; |
---|
29 | } |
---|
30 | |
---|
31 | IEventTask task1 = (IEventTask) node1; |
---|
32 | IEventTask task2 = (IEventTask) node2; |
---|
33 | |
---|
34 | if (task1.getEventType().equals(task2.getEventType()) && |
---|
35 | task1.getEventTarget().equals(task2.getEventTarget())) |
---|
36 | { |
---|
37 | return NodeEquality.LEXICALLY_EQUAL; |
---|
38 | } |
---|
39 | else { |
---|
40 | return NodeEquality.UNEQUAL; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.