1 /*
2  *  Avis event router.
3  *
4  *  Copyright (C) 2008 Matthew Phillips <avis@mattp.name>
5  *
6  *  This program is free software: you can redistribute it and/or
7  *  modify it under the terms of the GNU General Public License
8  *  version 3 as published by the Free Software Foundation.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  *  General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.avis.util;
19 
20 /**
21  * A filter that selects values of the generic type T.
22  *
23  * @author Matthew Phillips
24  */
25 public interface Filter<T>
26 {
27   /**
28    * Matches anything.
29    */
30   public static final Filter<?> MATCH_NONE = new Filter<Object> ()
31   {
32     public boolean matches (Object value)
33     {
34       return false;
35     }
36   };
37 
38   /**
39    * Matches nothing.
40    */
41   public static final Filter<?> MATCH_ALL = new Filter<Object> ()
42   {
43     public boolean matches (Object value)
44     {
45       return true;
46     }
47   };
48 
49   /**
50    * Test if the filter matches.
51    *
52    * @param value The value to test.
53    *
54    * @return True if the fiLter matches.
55    */
matches(T value)56   public boolean matches (T value);
57 }
58