source: trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/FilterResult.java @ 1200

Last change on this file since 1200 was 1200, checked in by adeicke, 11 years ago

Avoid double entries in complete filter result.

  • Property svn:mime-type set to text/plain
File size: 2.1 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.tasktree;
16
17import java.util.List;
18
19import com.google.common.base.Predicate;
20import com.google.common.collect.Lists;
21
22import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
23
24/**
25 * <p>
26 * TODO comment
27 * </p>
28 *
29 * @author Alexander Deicke
30 */
31public class FilterResult {
32
33    @SuppressWarnings("rawtypes")
34    private final Predicate filterPredicate;
35
36    private List<ITask> filteredTasks = Lists.newArrayList();
37
38    private List<ITask> tasksNotMatchedFilter = Lists.newArrayList();
39
40    @SuppressWarnings("rawtypes")
41    public FilterResult(Predicate filterPredicate) {
42        this.filterPredicate = filterPredicate;
43    }
44
45    @SuppressWarnings("unchecked")
46    public void addTask(ITask task) {
47        boolean notFilteredYet = !filteredTasks.contains(task) && !tasksNotMatchedFilter.contains(task);
48        if(notFilteredYet) {
49                if (filterPredicate.apply(task)) {
50                    filteredTasks.add(task);
51                }
52                else {
53                    tasksNotMatchedFilter.add(task);
54                }
55        }
56    }
57
58    public List<ITask> tasksMatchedFilter() {
59        return this.filteredTasks;
60    }
61
62    public int nrOfTasksMatchedFilter() {
63        return this.filteredTasks.size();
64    }
65
66    public List<ITask> tasksNotMatchedFilter() {
67        return this.tasksNotMatchedFilter;
68    }
69
70    public int nrOfTasksNotMatchedFilter() {
71        return this.tasksNotMatchedFilter.size();
72    }
73
74}
Note: See TracBrowser for help on using the repository browser.