source: branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEquality.java @ 1733

Last change on this file since 1733 was 1733, checked in by rkrimmel, 10 years ago

Used Eclipse code cleanup

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