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.temporalrelation; |
---|
16 | |
---|
17 | import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; |
---|
18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; |
---|
19 | import de.ugoe.cs.autoquest.usageprofiles.DefaultSymbolMap; |
---|
20 | import de.ugoe.cs.autoquest.usageprofiles.SymbolComparator; |
---|
21 | import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; |
---|
22 | import de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy; |
---|
23 | |
---|
24 | /** |
---|
25 | * <p> |
---|
26 | * TODO comment |
---|
27 | * </p> |
---|
28 | * |
---|
29 | * @author Patrick Harms |
---|
30 | */ |
---|
31 | class TaskHandlingStrategy implements SymbolStrategy<ITaskInstance> { |
---|
32 | |
---|
33 | /** */ |
---|
34 | private static final long serialVersionUID = 1L; |
---|
35 | |
---|
36 | /** |
---|
37 | * |
---|
38 | */ |
---|
39 | private TaskEquality consideredEquality; |
---|
40 | |
---|
41 | /** |
---|
42 | * |
---|
43 | */ |
---|
44 | private TaskInstanceComparator comparator; |
---|
45 | |
---|
46 | /** |
---|
47 | * <p> |
---|
48 | * TODO: comment |
---|
49 | * </p> |
---|
50 | * |
---|
51 | * @param consideredEquality |
---|
52 | */ |
---|
53 | TaskHandlingStrategy(TaskEquality consideredEquality) { |
---|
54 | this.consideredEquality = consideredEquality; |
---|
55 | |
---|
56 | if (this.consideredEquality == TaskEquality.IDENTICAL) { |
---|
57 | comparator = new TaskIdentityComparator(); |
---|
58 | } |
---|
59 | else { |
---|
60 | comparator = new TaskInstanceComparator(this.consideredEquality); |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | /* (non-Javadoc) |
---|
65 | * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#getSymbolComparator() |
---|
66 | */ |
---|
67 | @Override |
---|
68 | public SymbolComparator<ITaskInstance> getSymbolComparator() { |
---|
69 | return comparator; |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * <p> |
---|
74 | * TODO: comment |
---|
75 | * </p> |
---|
76 | * |
---|
77 | * @return |
---|
78 | */ |
---|
79 | public TaskInstanceComparator getTaskComparator() { |
---|
80 | return comparator; |
---|
81 | } |
---|
82 | |
---|
83 | /* (non-Javadoc) |
---|
84 | * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#createSymbolMap() |
---|
85 | */ |
---|
86 | @Override |
---|
87 | public <V> SymbolMap<ITaskInstance, V> createSymbolMap() { |
---|
88 | if (consideredEquality == TaskEquality.IDENTICAL) { |
---|
89 | return new TaskSymbolIdentityMap<V>(); |
---|
90 | } |
---|
91 | else { |
---|
92 | return new TaskSymbolBucketedMap<V>(comparator); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | /* (non-Javadoc) |
---|
97 | * @see de.ugoe.cs.autoquest.usageprofiles.SymbolStrategy#copySymbolMap(de.ugoe.cs.autoquest.usageprofiles.SymbolMap) |
---|
98 | */ |
---|
99 | @Override |
---|
100 | public <V> SymbolMap<ITaskInstance, V> copySymbolMap(SymbolMap<ITaskInstance, V> other) { |
---|
101 | if (consideredEquality == TaskEquality.IDENTICAL) { |
---|
102 | return new DefaultSymbolMap<ITaskInstance, V>(other); |
---|
103 | } |
---|
104 | else { |
---|
105 | return new TaskSymbolBucketedMap<V>(comparator); |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | } |
---|