001/* 002 * JGrapes Event Driven Framework 003 * Copyright (C) 2019 Michael N. Lipp 004 * 005 * This program is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Affero General Public License as published by 007 * the Free Software Foundation; either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, but 011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public 013 * License for more details. 014 * 015 * You should have received a copy of the GNU Affero General Public License 016 * along with this program; if not, see <http://www.gnu.org/licenses/>. 017 */ 018 019package org.jgrapes.core; 020 021import org.jgrapes.core.internal.EventBase; 022 023/** 024 * Some {@link HandlerScope} implementations use only a subset of the 025 * properties of the events passed to 026 * {@link HandlerScope#includes(Eligible, Eligible[])} for 027 * evaluating the result. This is done in order to avoid an excessive 028 * number of entries in the table that maps events (and channels) to 029 * handlers. 030 * 031 * When dispatching an event, the superfluous values from the mapping table 032 * must be filtered. {@link HandlerScope} implementations that do not 033 * take all properties of an event into account in their implementation 034 * of {@link HandlerScope#includes(Eligible, Eligible[])} must therefore 035 * also implement this interface. 036 */ 037@SuppressWarnings("PMD.ImplicitFunctionalInterface") 038public interface InvocationFilter { 039 040 /** 041 * Matches the given event against the criteria 042 * for events, taking properties into account that were left out 043 * by {@link HandlerScope#includes(Eligible, Eligible[])}. 044 * 045 * Note that this method is called only with events that have passed 046 * the invocation of {@link HandlerScope#includes(Eligible, Eligible[])}. 047 * It is therefore not required to re-test conditions already 048 * checked by {@link HandlerScope#includes(Eligible, Eligible[])}. 049 * 050 * @param event the event 051 * @return true, if successful 052 */ 053 boolean includes(EventBase<?> event); 054}