001/*
002 * JGrapes Event Driven Framework
003 * Copyright (C) 2016-2018 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
021/**
022 * This interface provides a mechanism for matching objects, using
023 * a filter on the object's "kind" as criterion. How the kind is 
024 * represented depends completely on the class that implements this 
025 * interface.
026 * 
027 * Every instance of a class that implement this interface must provide 
028 * a default criterion (filter) that accepts the instance (though, of course,
029 * not *only* this particular instance). Formally: for every instance "`obj`"
030 * of `Eligible`, the expression 
031 * `obj.isEligibleFor(obj.getDefaultCrtiterion())` must return `true`.
032 * 
033 * The default criterion can therefore be interpreted as the 
034 * representation of the kind of the object.
035 */
036public interface Eligible {
037
038    /**
039     * Returns <code>true</code> if this {@link Eligible}
040     * is met by the provided criterion.
041     * 
042     * @param criterion the criterion
043     * @return {@code true} if this meets the criterion
044     */
045    boolean isEligibleFor(Object criterion);
046
047    /**
048     * Returns a sample criterion that this {@link Eligible} meets.
049     * 
050     * @return the criterion
051     */
052    Object defaultCriterion();
053}