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;
|
---|
16 |
|
---|
17 | import java.util.EnumSet;
|
---|
18 | import java.util.List;
|
---|
19 |
|
---|
20 | import com.google.common.base.Optional;
|
---|
21 | import com.google.common.base.Preconditions;
|
---|
22 | import com.google.common.collect.Lists;
|
---|
23 |
|
---|
24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
|
---|
25 | import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect;
|
---|
26 | import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
|
---|
27 | import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRuleset;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * <p>
|
---|
31 | * TODO comment
|
---|
32 | * </p>
|
---|
33 | *
|
---|
34 | * @author Alexander Deicke
|
---|
35 | */
|
---|
36 | public class UsabilityEvaluationFacade {
|
---|
37 |
|
---|
38 | private UsabilityEvaluationFacade() {
|
---|
39 | // no instantiation allowed
|
---|
40 | }
|
---|
41 |
|
---|
42 | public static ExecuteUsabilityEvaluationStep applyUsabilityRuleset(UsabilityRuleset usabilityRuleset)
|
---|
43 | {
|
---|
44 | Preconditions.checkNotNull(usabilityRuleset);
|
---|
45 | return new ExecuteUsabilityEvaluationStep(usabilityRuleset);
|
---|
46 | }
|
---|
47 |
|
---|
48 | protected static class ExecuteUsabilityEvaluationStep {
|
---|
49 |
|
---|
50 | protected ExecuteUsabilityEvaluationStep(UsabilityRuleset usabilityRuleset) {
|
---|
51 | super();
|
---|
52 | this.usabilityRuleset = usabilityRuleset;
|
---|
53 | }
|
---|
54 |
|
---|
55 | private final UsabilityRuleset usabilityRuleset;
|
---|
56 |
|
---|
57 | public UsabilityEvaluationReport evaluateUsabilityOf(ITaskTree taskTree) {
|
---|
58 | Preconditions.checkNotNull(taskTree);
|
---|
59 | EnumSet<? extends UsabilityRule> evaluationRules = usabilityRuleset.evaluationRules();
|
---|
60 | List<UsabilityDefect> evaluationResults =
|
---|
61 | Lists.newArrayListWithCapacity(evaluationRules.size());
|
---|
62 | for (UsabilityRule usabilityRule : evaluationRules) {
|
---|
63 | Optional<UsabilityDefect> ruleEvaluationResult = usabilityRule.evaluate(taskTree);
|
---|
64 | if (ruleEvaluationResult.isPresent()) {
|
---|
65 | evaluationResults.add(ruleEvaluationResult.get());
|
---|
66 | }
|
---|
67 | }
|
---|
68 | return UsabilityEvaluationReport.from(evaluationResults);
|
---|
69 | }
|
---|
70 |
|
---|
71 | }
|
---|
72 |
|
---|
73 | }
|
---|