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.usability.rules.patterns;
|
---|
16 |
|
---|
17 | import java.util.List;
|
---|
18 |
|
---|
19 | import com.google.common.collect.Lists;
|
---|
20 |
|
---|
21 | import de.ugoe.cs.autoquest.usability.rules.patterns.visitors.ContainsEventVisitor;
|
---|
22 | import de.ugoe.cs.autoquest.usability.rules.patterns.visitors.ContainsInteractionPatternVisitor;
|
---|
23 | import de.ugoe.cs.autoquest.usability.rules.patterns.visitors.EndsWithEventVisitor;
|
---|
24 | import de.ugoe.cs.autoquest.usability.rules.patterns.visitors.EndsWithInteractionPatternVisitor;
|
---|
25 | import de.ugoe.cs.autoquest.usability.rules.patterns.visitors.StartsWithEventVisitor;
|
---|
26 | import de.ugoe.cs.autoquest.usability.rules.patterns.visitors.StartsWithInteractionPatternVisitor;
|
---|
27 | import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter;
|
---|
28 | import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter;
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * <p>
|
---|
32 | * Helper class, which allows to create {@link InteractionPattern}s.
|
---|
33 | * </p>
|
---|
34 | *
|
---|
35 | * @author Alexander Deicke
|
---|
36 | */
|
---|
37 | public class InteractionPatternBuilder {
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * <p>
|
---|
41 | * Type of root task. Determines the order in which sub task appear.
|
---|
42 | * </p>
|
---|
43 | */
|
---|
44 | protected TaskTypeFilter rootTask;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * <p>
|
---|
48 | * Interaction pattern starts with event.
|
---|
49 | * </p>
|
---|
50 | */
|
---|
51 | protected EventTypeFilter startsWithEvent;
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * <p>
|
---|
55 | * Interaction pattern starts with interaction pattern.
|
---|
56 | * </p>
|
---|
57 | */
|
---|
58 | protected InteractionPattern startsWithPattern;
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * <p>
|
---|
62 | * Interaction pattern ends with event.
|
---|
63 | * </p>
|
---|
64 | */
|
---|
65 | protected EventTypeFilter endsWithEvent;
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * <p>
|
---|
69 | * Interaction pattern ends with interaction pattern.
|
---|
70 | * </p>
|
---|
71 | */
|
---|
72 | protected InteractionPattern endsWithPattern;
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * <p>
|
---|
76 | * Interaction pattern contains certain event.
|
---|
77 | * </p>
|
---|
78 | */
|
---|
79 | protected EventTypeFilter containsEvent;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * <p>
|
---|
83 | * Interaction pattern contains certain interaction pattern.
|
---|
84 | * </p>
|
---|
85 | */
|
---|
86 | protected InteractionPattern containsPattern;
|
---|
87 |
|
---|
88 | /**
|
---|
89 | *
|
---|
90 | * <p>
|
---|
91 | * Starts creation of new interaction pattern.
|
---|
92 | * </p>
|
---|
93 | *
|
---|
94 | * @return steps to create interaction pattern
|
---|
95 | */
|
---|
96 | public static SetConcernedTaskModelComponentStep newPattern() {
|
---|
97 | return new Steps();
|
---|
98 | }
|
---|
99 |
|
---|
100 | public static interface SetConcernedTaskModelComponentStep {
|
---|
101 |
|
---|
102 | public BuildPatternStep rootTask(TaskTypeFilter concernedNode);
|
---|
103 |
|
---|
104 | }
|
---|
105 |
|
---|
106 | public static interface BuildPatternStep {
|
---|
107 |
|
---|
108 | public StartsWithStep startsWithEvent(EventTypeFilter startsWithEventType);
|
---|
109 |
|
---|
110 | public StartsWithStep startsWithPattern(InteractionPattern endsWithPattern);
|
---|
111 |
|
---|
112 | public ContainsStep containsEvent(EventTypeFilter containsEventType);
|
---|
113 |
|
---|
114 | public ContainsStep containsPattern(InteractionPattern containsPattern);
|
---|
115 |
|
---|
116 | public EndsWithStep endsWithEvent(EventTypeFilter endsWithEventType);
|
---|
117 |
|
---|
118 | public EndsWithStep endsWithPattern(InteractionPattern endsPattern);
|
---|
119 |
|
---|
120 | public BuildStep patternFinished();
|
---|
121 |
|
---|
122 | }
|
---|
123 |
|
---|
124 | public static interface StartsWithStep {
|
---|
125 |
|
---|
126 | public ContainsStep containsEvent(EventTypeFilter containsEventType);
|
---|
127 |
|
---|
128 | public ContainsStep containsPattern(InteractionPattern containsPattern);
|
---|
129 |
|
---|
130 | public EndsWithStep endsWithEvent(EventTypeFilter endsWithEventType);
|
---|
131 |
|
---|
132 | public EndsWithStep endsWithPattern(InteractionPattern endsPattern);
|
---|
133 |
|
---|
134 | public BuildStep patternFinished();
|
---|
135 |
|
---|
136 | }
|
---|
137 |
|
---|
138 | public static interface ContainsStep {
|
---|
139 |
|
---|
140 | public ContainsStep containsEvent(EventTypeFilter containsEventType);
|
---|
141 |
|
---|
142 | public ContainsStep containsPattern(InteractionPattern containsPattern);
|
---|
143 |
|
---|
144 | public EndsWithStep endsWithEvent(EventTypeFilter endsWithEventType);
|
---|
145 |
|
---|
146 | public EndsWithStep endsWithPattern(InteractionPattern endsPattern);
|
---|
147 |
|
---|
148 | public BuildStep patternFinished();
|
---|
149 | }
|
---|
150 |
|
---|
151 | public static interface EndsWithStep {
|
---|
152 |
|
---|
153 | public BuildStep patternFinished();
|
---|
154 |
|
---|
155 | }
|
---|
156 |
|
---|
157 | public static interface BuildStep {
|
---|
158 |
|
---|
159 | public InteractionPattern build();
|
---|
160 |
|
---|
161 | }
|
---|
162 |
|
---|
163 | private static class Steps implements SetConcernedTaskModelComponentStep, BuildPatternStep,
|
---|
164 | StartsWithStep, ContainsStep, EndsWithStep, BuildStep
|
---|
165 | {
|
---|
166 |
|
---|
167 | private List<InteractionPatternVisitor> visitors = Lists.newArrayList();
|
---|
168 |
|
---|
169 | private TaskTypeFilter concernedNode;
|
---|
170 |
|
---|
171 | @Override
|
---|
172 | public BuildPatternStep rootTask(TaskTypeFilter concernedNode) {
|
---|
173 | this.concernedNode = concernedNode;
|
---|
174 | return this;
|
---|
175 | }
|
---|
176 |
|
---|
177 | @Override
|
---|
178 | public StartsWithStep startsWithEvent(EventTypeFilter startsWithEventType) {
|
---|
179 | this.visitors.add(new StartsWithEventVisitor(startsWithEventType, concernedNode));
|
---|
180 | return this;
|
---|
181 | }
|
---|
182 |
|
---|
183 | @Override
|
---|
184 | public StartsWithStep startsWithPattern(InteractionPattern startsWithPattern) {
|
---|
185 | this.visitors.add(new StartsWithInteractionPatternVisitor(startsWithPattern,
|
---|
186 | concernedNode));
|
---|
187 | return this;
|
---|
188 | }
|
---|
189 |
|
---|
190 | @Override
|
---|
191 | public ContainsStep containsEvent(EventTypeFilter containsEventType) {
|
---|
192 | this.visitors.add(new ContainsEventVisitor(containsEventType, concernedNode));
|
---|
193 | return this;
|
---|
194 | }
|
---|
195 |
|
---|
196 | @Override
|
---|
197 | public ContainsStep containsPattern(InteractionPattern containsPattern) {
|
---|
198 | this.visitors
|
---|
199 | .add(new ContainsInteractionPatternVisitor(containsPattern, concernedNode));
|
---|
200 | return this;
|
---|
201 | }
|
---|
202 |
|
---|
203 | @Override
|
---|
204 | public EndsWithStep endsWithEvent(EventTypeFilter endsWithEventType) {
|
---|
205 | this.visitors.add(new EndsWithEventVisitor(endsWithEventType, concernedNode));
|
---|
206 | return this;
|
---|
207 | }
|
---|
208 |
|
---|
209 | @Override
|
---|
210 | public EndsWithStep endsWithPattern(InteractionPattern endsWithPattern) {
|
---|
211 | this.visitors
|
---|
212 | .add(new EndsWithInteractionPatternVisitor(endsWithPattern, concernedNode));
|
---|
213 | return this;
|
---|
214 |
|
---|
215 | }
|
---|
216 |
|
---|
217 | @Override
|
---|
218 | public BuildStep patternFinished() {
|
---|
219 | return this;
|
---|
220 | }
|
---|
221 |
|
---|
222 | @Override
|
---|
223 | public InteractionPattern build() {
|
---|
224 | return new InteractionPattern(concernedNode, this.visitors);
|
---|
225 | }
|
---|
226 |
|
---|
227 | }
|
---|
228 |
|
---|
229 | }
|
---|