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

Last change on this file since 2255 was 2218, checked in by pharms, 7 years ago
  • java doc issues removal
  • Property svn:executable set to *
File size: 5.1 KB
Line 
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
15package de.ugoe.cs.autoquest.tasktrees.taskequality;
16
17/**
18 * <p>
19 * A task equality denotes, how equal two tasks are. There are different equality levels
20 * which are similar to the usual design levels of GUI design. These levels are
21 * </p>
22 * <ul>
23 *   <li>conceptual design: defines the concepts to be edited using a GUI</li>
24 *   <li>semantical design: defines the possible functions for editing the concepts</li>
25 *   <li>syntactical design: defines, which steps are needed to execute the functions</li>
26 *   <li>lexical design: defines on the key stroke level, how the steps for executing a function
27 *       can be performed</li>
28 * </ul>
29 * <p>
30 * It is not possible to compare two tasks conceptually. But the other design levels can be
31 * identified and compared.
32 * </p>
33 * <p>
34 * Tasks can be identical. This is the case if in the java virtual machine, their comparison
35 * using the <code>==</code> operator or the equals method return true.
36 * </p>
37 * <p>
38 * Tasks are lexically equal, if they represent the same events on a key stroke level to be
39 * carried out to execute the task. Identical tasks are also lexically equal.
40 * </p>
41 * <p>
42 * Tasks are syntactically equal, if they differ in their events on key stroke level, but the
43 * syntactical result is the same. For example, entering the text "hello" into a text field can
44 * be done by entering the letters in their correct order, but also by copying the text into the
45 * text field. The syntactical result is the same: The text "hello" was entered. But the tasks
46 * lexically differ because the events on key stroke level are different. On the other hand,
47 * lexically equal tasks are also syntactically equal. 
48 * </p>
49 * <p>
50 * Tasks are semantically equal, if they execute the same function for editing the concepts. An
51 * example are a click on a button and a short cut, both executing the same function. These tasks
52 * are syntactically and, therefore, also lexically different, but semantically equal.
53 * Syntactically equal tasks are always also semantically equal.
54 * </p>
55 *
56 * @version $Revision: $ $Date: 19.02.2012$
57 * @author 2012, last modified by $Author: patrick$
58 */
59public enum TaskEquality {
60    IDENTICAL,
61    LEXICALLY_EQUAL,
62    SYNTACTICALLY_EQUAL,
63    SEMANTICALLY_EQUAL,
64    UNEQUAL;
65
66    /**
67     * <p>
68     * Checks for the current task equality, if it is at least identical to the
69     * provided one or even more concrete. As an example, the task equality identical also
70     * indicates, that the tasks are e.g. lexically, syntactically and semantically equal.
71     * Therefore, the method called on <code>IDENTICAL</code> with <code>SEMANTICALLY_EQUAL</code>
72     * as parameter will return true. If this method is called on <code>SYNTACTICALLY_EQUAL</code>
73     * with the parameter <code>IDENTICAL</code> instead, it returns false;
74     * </p>
75     *
76     * @param taskEquality the task equality to compare with.
77     *
78     * @return as described
79     */
80    public boolean isAtLeast(TaskEquality taskEquality)
81    {
82        switch (taskEquality) {
83            case IDENTICAL:
84                return
85                    (this == IDENTICAL);
86            case LEXICALLY_EQUAL:
87                return
88                    (this == IDENTICAL) ||
89                    (this == LEXICALLY_EQUAL);
90            case SYNTACTICALLY_EQUAL:
91                return
92                    (this == IDENTICAL) ||
93                    (this == LEXICALLY_EQUAL) ||
94                    (this == SYNTACTICALLY_EQUAL);
95            case SEMANTICALLY_EQUAL:
96                return
97                    (this == IDENTICAL) ||
98                    (this == LEXICALLY_EQUAL) ||
99                    (this == SYNTACTICALLY_EQUAL) ||
100                    (this == SEMANTICALLY_EQUAL);
101            case UNEQUAL:
102                return
103                    (this == UNEQUAL);
104            default :
105                return false;
106        }
107    }
108
109    /**
110     * <p>
111     * returns the common denominator of this task equality and the provided one. I.e. if one
112     * equality is e.g. syntactical and the other one only semantical, then semantical is returned.
113     * </p>
114     *
115     * @param otherEquality the equality, to compare this with
116     *
117     * @return as described
118     */
119    public TaskEquality getCommonDenominator(TaskEquality otherEquality) {
120        if (this.isAtLeast(otherEquality)) {
121            return otherEquality;
122        }
123        else if (otherEquality.isAtLeast(this)) {
124            return this;
125        }
126        else {
127            return TaskEquality.UNEQUAL;
128        }
129    }
130}
Note: See TracBrowser for help on using the repository browser.