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