[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] | 15 | package de.ugoe.cs.autoquest.usability.tasktree;
|
---|
[1030] | 16 |
|
---|
| 17 | import java.util.List;
|
---|
| 18 |
|
---|
| 19 | import com.google.common.base.Predicate;
|
---|
| 20 | import com.google.common.collect.Lists;
|
---|
| 21 |
|
---|
[1152] | 22 | import 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] | 31 | public 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 | }
|
---|