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

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

Added automatically created javadoc, still needs to be commented properly though

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