source: trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/FilterStatistic.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
RevLine 
[1040]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
[1030]15package de.ugoe.cs.autoquest.usability.tasktree.filter;
16
17import java.util.List;
18
19import com.google.common.base.Predicate;
[1040]20import com.google.common.collect.LinkedListMultimap;
[1030]21import com.google.common.collect.Lists;
[1040]22import com.google.common.collect.Multimap;
[1030]23
[1040]24import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
25import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
[1030]26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
27
[1040]28/**
29 * <p>
30 * TODO comment
31 * </p>
32 *
33 * @author Alexander Deicke
34 */
[1030]35public class FilterStatistic {
[1040]36
[1030]37    @SuppressWarnings("rawtypes")
38    private final Predicate filterPredicate;
39
40    private List<ITaskTreeNode> filteredNodes = Lists.newArrayList();
[1040]41
[1030]42    private List<ITaskTreeNode> nodesNotMatchedFilter = Lists.newArrayList();
[1040]43
[1030]44    @SuppressWarnings("rawtypes")
45    public FilterStatistic(Predicate filterPredicate) {
46        this.filterPredicate = filterPredicate;
47    }
[1040]48
[1030]49    @SuppressWarnings("unchecked")
50    public void addNode(ITaskTreeNode node) {
51        if (filterPredicate.apply(node)) {
52            filteredNodes.add(node);
[1040]53        }
54        else {
[1030]55            nodesNotMatchedFilter.add(node);
56        }
57    }
[1040]58
[1030]59    public List<ITaskTreeNode> nodesMatchedFilter() {
60        return this.filteredNodes;
61    }
[1040]62
[1030]63    public int nrOfNodesMatchedFilter() {
64        return this.filteredNodes.size();
65    }
[1040]66
[1030]67    public List<ITaskTreeNode> nodesNotMatchedFilter() {
68        return this.nodesNotMatchedFilter;
69    }
[1040]70
[1030]71    public int nrOfNodesNotMatchedFilter() {
72        return this.nodesNotMatchedFilter.size();
73    }
[1040]74
75    /**
76     * <p>
77     * TODO: comment
78     * </p>
79     *
80     * @param eventTargetParent
81     * @return
82     */
83    public Multimap<IGUIElement, ITaskTreeNode> groupBy() {
84        Multimap<IGUIElement, ITaskTreeNode> groupedNodes = LinkedListMultimap.create();
85        for(ITaskTreeNode node : filteredNodes) {
86            IGUIElement eventTask = (IGUIElement) ((IEventTask) node).getEventTarget();
87            groupedNodes.put(eventTask.getParent(), node);
88        }
89        return groupedNodes;
90    }
91
[1030]92}
Note: See TracBrowser for help on using the repository browser.