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 License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Affero General Public License along 
016 * 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 */
037public interface InvocationFilter {
038
039    /**
040     * Matches the given event against the criteria
041     * for events, taking properties into account that were left out
042     * by {@link HandlerScope#includes(Eligible, Eligible[])}.
043     * 
044     * Note that this method is called only with events that have passed 
045     * the invocation of {@link HandlerScope#includes(Eligible, Eligible[])}.
046     * It is therefore not required to re-test conditions already
047     * checked by {@link HandlerScope#includes(Eligible, Eligible[])}.
048     *
049     * @param event the event
050     * @return true, if successful
051     */
052    boolean includes(EventBase<?> event);
053}