[1326] | 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 | |
---|
| 15 | package de.ugoe.cs.autoquest.plugin.usability2.rules.operator; |
---|
| 16 | |
---|
| 17 | import de.ugoe.cs.autoquest.plugin.usability2.rules.results.IResult; |
---|
| 18 | import de.ugoe.cs.autoquest.plugin.usability2.rules.results.UnmatchableResult; |
---|
| 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 20 | |
---|
| 21 | /** |
---|
| 22 | * |
---|
| 23 | * <p> |
---|
| 24 | * A filter that acts as a logical NOT operation on matches. |
---|
| 25 | * If the marked filter does not match, this filter will return a match (with a UNNAMEMABLE_MATCH as result). |
---|
| 26 | * If the marked filter matches, this filter will return no match found. |
---|
| 27 | * </p> |
---|
| 28 | * |
---|
| 29 | * @author Konni Hartmann |
---|
| 30 | */ |
---|
| 31 | public class Negation extends MarkingFilter { |
---|
| 32 | |
---|
| 33 | public Negation(IFilter marked) { |
---|
| 34 | super(marked); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | public Negation(IFilter marked, IResultTransformer transformer) { |
---|
| 38 | super(marked, transformer); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | @Override |
---|
| 42 | public IResult match(ITask task, IFilter filter) { |
---|
| 43 | IResult result = filter.match(task); |
---|
| 44 | if (result.isPresent()) |
---|
| 45 | return UnmatchableResult.NO_MATCH_FOUND; |
---|
| 46 | else |
---|
| 47 | return UnmatchableResult.UNNAMEMABLE_MATCH_FOUND; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | } |
---|