source: trunk/autoquest-plugin-usability2/src/main/java/de/ugoe/cs/autoquest/plugin/usability2/rules/operator/Disjunction.java @ 1326

Last change on this file since 1326 was 1326, checked in by khartmann, 10 years ago

Moved alexanders code into a new plugin project.
First commit of my experimental code (needs a lot of cleanup).

File size: 1.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.plugin.usability2.rules.operator;
16
17import java.util.LinkedList;
18import java.util.List;
19
20import de.ugoe.cs.autoquest.plugin.usability2.rules.results.IResult;
21import de.ugoe.cs.autoquest.plugin.usability2.rules.results.JoinedResult;
22import de.ugoe.cs.autoquest.plugin.usability2.rules.results.UnmatchableResult;
23import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
24
25/**
26 * <p>
27 * TODO comment
28 * </p>
29 *
30 * @author Konni Hartmann
31 */
32public class Disjunction extends AbstractFilterOperator {
33
34    public Disjunction(List<IFilter> filters) {
35        super(filters);
36    }
37
38    public Disjunction(IFilter... filters) {
39        super(filters);
40    }   
41   
42    @Override
43    public IResult match(ITask task, List<IFilter> filters) {
44        List<IResult> l = new LinkedList<IResult>();
45       
46        for (IFilter filter : filters) {
47            IResult result = filter.match(task);
48            if (result.isPresent())
49                l.add(result);
50        }
51
52        if(l.isEmpty())
53            return UnmatchableResult.NO_MATCH_FOUND;
54
55        return new JoinedResult(true, l);
56    }
57
58
59}
Note: See TracBrowser for help on using the repository browser.