source: trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/UsabilityEvaluationFacade.java @ 1040

Last change on this file since 1040 was 1040, checked in by adeicke, 11 years ago
  • Removed lombok related annotations and util class
  • Added comments and formating due to match project defaults
  • Property svn:mime-type set to text/plain
File size: 2.7 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.usability;
16
17import java.util.EnumSet;
18import java.util.List;
19
20import com.google.common.base.Optional;
21import com.google.common.base.Preconditions;
22import com.google.common.collect.Lists;
23
24import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
25import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect;
26import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
27import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRuleset;
28
29/**
30 * <p>
31 * TODO comment
32 * </p>
33 *
34 * @author Alexander Deicke
35 */
36public 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}
Note: See TracBrowser for help on using the repository browser.