[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] | 15 | package de.ugoe.cs.autoquest.tasktrees.taskequality; |
---|
[439] | 16 | |
---|
[1146] | 17 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
[1294] | 18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
[439] | 19 | |
---|
| 20 | /** |
---|
[557] | 21 | * <p> |
---|
[1146] | 22 | * This comparison rule returns <code>TaskEquality.IDENTICAL</code> if the comparison of the two |
---|
[1294] | 23 | * tasks using the <code>==</code> operator returns true. Else it returns null to denote, that |
---|
| 24 | * it can not compare the tasks. |
---|
[557] | 25 | * </p> |
---|
[439] | 26 | * |
---|
| 27 | * @version $Revision: $ $Date: 19.02.2012$ |
---|
| 28 | * @author 2012, last modified by $Author: patrick$ |
---|
| 29 | */ |
---|
[1146] | 30 | public class TaskIdentityRule implements TaskComparisonRule { |
---|
[439] | 31 | |
---|
[1125] | 32 | /* (non-Javadoc) |
---|
[1294] | 33 | * @see TaskComparisonRule#isApplicable(ITask, ITask) |
---|
[557] | 34 | */ |
---|
| 35 | @Override |
---|
[1146] | 36 | public boolean isApplicable(ITask task1, ITask task2) { |
---|
| 37 | return (task1 == task2); |
---|
[1125] | 38 | } |
---|
| 39 | |
---|
| 40 | /* (non-Javadoc) |
---|
[1294] | 41 | * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) |
---|
[1125] | 42 | */ |
---|
| 43 | @Override |
---|
[1146] | 44 | public boolean areLexicallyEqual(ITask task1, ITask task2) { |
---|
| 45 | return (task1 == task2); |
---|
[1125] | 46 | } |
---|
| 47 | |
---|
| 48 | /* (non-Javadoc) |
---|
[1294] | 49 | * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) |
---|
[1125] | 50 | */ |
---|
| 51 | @Override |
---|
[1146] | 52 | public boolean areSyntacticallyEqual(ITask task1, ITask task2) { |
---|
| 53 | return (task1 == task2); |
---|
[1125] | 54 | } |
---|
| 55 | |
---|
| 56 | /* (non-Javadoc) |
---|
[1294] | 57 | * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) |
---|
[1125] | 58 | */ |
---|
| 59 | @Override |
---|
[1146] | 60 | public boolean areSemanticallyEqual(ITask task1, ITask task2) { |
---|
| 61 | return (task1 == task2); |
---|
[1125] | 62 | } |
---|
| 63 | |
---|
| 64 | /* (non-Javadoc) |
---|
[1294] | 65 | * @see TaskComparisonRule#compare(ITask, ITask) |
---|
[1125] | 66 | */ |
---|
| 67 | @Override |
---|
[1146] | 68 | public TaskEquality compare(ITask task1, ITask task2) { |
---|
| 69 | if (isApplicable(task1, task2)) { |
---|
| 70 | return TaskEquality.IDENTICAL; |
---|
[557] | 71 | } |
---|
| 72 | else { |
---|
| 73 | return null; |
---|
| 74 | } |
---|
[439] | 75 | } |
---|
| 76 | |
---|
[1294] | 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 | |
---|
[439] | 122 | } |
---|