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.taskequality; |
---|
16 | |
---|
17 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
19 | |
---|
20 | /** |
---|
21 | * <p> |
---|
22 | * This comparison rule returns <code>TaskEquality.IDENTICAL</code> if the comparison of the two |
---|
23 | * tasks using the <code>==</code> operator returns true. Else it returns null to denote, that |
---|
24 | * it can not compare the tasks. |
---|
25 | * </p> |
---|
26 | * |
---|
27 | * @version $Revision: $ $Date: 19.02.2012$ |
---|
28 | * @author 2012, last modified by $Author: patrick$ |
---|
29 | */ |
---|
30 | public class TaskIdentityRule implements TaskComparisonRule { |
---|
31 | |
---|
32 | /* (non-Javadoc) |
---|
33 | * @see TaskComparisonRule#isApplicable(ITask, ITask) |
---|
34 | */ |
---|
35 | @Override |
---|
36 | public boolean isApplicable(ITask task1, ITask task2) { |
---|
37 | return (task1 == task2); |
---|
38 | } |
---|
39 | |
---|
40 | /* (non-Javadoc) |
---|
41 | * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) |
---|
42 | */ |
---|
43 | @Override |
---|
44 | public boolean areLexicallyEqual(ITask task1, ITask task2) { |
---|
45 | return (task1 == task2); |
---|
46 | } |
---|
47 | |
---|
48 | /* (non-Javadoc) |
---|
49 | * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) |
---|
50 | */ |
---|
51 | @Override |
---|
52 | public boolean areSyntacticallyEqual(ITask task1, ITask task2) { |
---|
53 | return (task1 == task2); |
---|
54 | } |
---|
55 | |
---|
56 | /* (non-Javadoc) |
---|
57 | * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) |
---|
58 | */ |
---|
59 | @Override |
---|
60 | public boolean areSemanticallyEqual(ITask task1, ITask task2) { |
---|
61 | return (task1 == task2); |
---|
62 | } |
---|
63 | |
---|
64 | /* (non-Javadoc) |
---|
65 | * @see TaskComparisonRule#compare(ITask, ITask) |
---|
66 | */ |
---|
67 | @Override |
---|
68 | public TaskEquality compare(ITask task1, ITask task2) { |
---|
69 | if (isApplicable(task1, task2)) { |
---|
70 | return TaskEquality.IDENTICAL; |
---|
71 | } |
---|
72 | else { |
---|
73 | return null; |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | /* (non-Javadoc) |
---|
78 | * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) |
---|
79 | */ |
---|
80 | @Override |
---|
81 | public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { |
---|
82 | return (instance1.getTask() == instance2.getTask()); |
---|
83 | } |
---|
84 | |
---|
85 | /* (non-Javadoc) |
---|
86 | * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) |
---|
87 | */ |
---|
88 | @Override |
---|
89 | public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { |
---|
90 | return (instance1.getTask() == instance2.getTask()); |
---|
91 | } |
---|
92 | |
---|
93 | /* (non-Javadoc) |
---|
94 | * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) |
---|
95 | */ |
---|
96 | @Override |
---|
97 | public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { |
---|
98 | return (instance1.getTask() == instance2.getTask()); |
---|
99 | } |
---|
100 | |
---|
101 | /* (non-Javadoc) |
---|
102 | * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) |
---|
103 | */ |
---|
104 | @Override |
---|
105 | public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { |
---|
106 | return (instance1.getTask() == instance2.getTask()); |
---|
107 | } |
---|
108 | |
---|
109 | /* (non-Javadoc) |
---|
110 | * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) |
---|
111 | */ |
---|
112 | @Override |
---|
113 | public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { |
---|
114 | if (isApplicable(instance1, instance2)) { |
---|
115 | return TaskEquality.IDENTICAL; |
---|
116 | } |
---|
117 | else { |
---|
118 | return null; |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | } |
---|