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

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

Avoid adding of same task to filter result.

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