[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.filter; |
---|
| 16 | |
---|
| 17 | import java.util.ArrayList; |
---|
| 18 | import java.util.Arrays; |
---|
| 19 | import java.util.Collection; |
---|
| 20 | |
---|
| 21 | import de.ugoe.cs.autoquest.eventcore.IEventType; |
---|
| 22 | |
---|
| 23 | /** |
---|
| 24 | * <p> |
---|
| 25 | * TODO comment |
---|
| 26 | * </p> |
---|
| 27 | * |
---|
| 28 | * @author Konni Hartmann |
---|
| 29 | */ |
---|
| 30 | public class MultiEventTypeFilter extends EventTypeFilter { |
---|
| 31 | |
---|
| 32 | Collection<Class<? extends IEventType>> eventTypes; |
---|
| 33 | /** |
---|
| 34 | * <p> |
---|
| 35 | * TODO: comment |
---|
| 36 | * </p> |
---|
| 37 | * |
---|
| 38 | * @param eventTypeClazz |
---|
| 39 | */ |
---|
| 40 | public MultiEventTypeFilter(Collection<Class<? extends IEventType>> eventTypes) { |
---|
| 41 | super(null); |
---|
| 42 | this.eventTypes = new ArrayList<Class<? extends IEventType>>(eventTypes); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | public MultiEventTypeFilter(Class<? extends IEventType>... eventTypes) { |
---|
| 46 | super(null); |
---|
| 47 | this.eventTypes = Arrays.asList(eventTypes); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | /* (non-Javadoc) |
---|
| 51 | * @see de.ugoe.cs.autoquest.plugin.usability2.rules.operator.filter.EventTypeFilter#matchesType(de.ugoe.cs.autoquest.eventcore.IEventType, java.lang.Class) |
---|
| 52 | */ |
---|
| 53 | @Override |
---|
| 54 | protected boolean matchesType(IEventType type, Class<? extends IEventType> eventTypeClazz) { |
---|
| 55 | for (Class<? extends IEventType> targetType : eventTypes ) { |
---|
| 56 | if (super.matchesType(type, targetType)) |
---|
| 57 | return true; |
---|
| 58 | } |
---|
| 59 | return false; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | public boolean matchesType(IEventType type) { |
---|
| 63 | return this.matchesType(type, null); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | } |
---|