4594 |
21 Oct 08 |
nicklas |
1 |
/** |
4594 |
21 Oct 08 |
nicklas |
$Id$ |
4594 |
21 Oct 08 |
nicklas |
3 |
|
4594 |
21 Oct 08 |
nicklas |
Copyright (C) 2008 Nicklas Nordborg |
4594 |
21 Oct 08 |
nicklas |
5 |
|
4594 |
21 Oct 08 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4594 |
21 Oct 08 |
nicklas |
Available at http://base.thep.lu.se/ |
4594 |
21 Oct 08 |
nicklas |
8 |
|
4594 |
21 Oct 08 |
nicklas |
BASE is free software; you can redistribute it and/or |
4594 |
21 Oct 08 |
nicklas |
modify it under the terms of the GNU General Public License |
4594 |
21 Oct 08 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4594 |
21 Oct 08 |
nicklas |
of the License, or (at your option) any later version. |
4594 |
21 Oct 08 |
nicklas |
13 |
|
4594 |
21 Oct 08 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4594 |
21 Oct 08 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4594 |
21 Oct 08 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4594 |
21 Oct 08 |
nicklas |
GNU General Public License for more details. |
4594 |
21 Oct 08 |
nicklas |
18 |
|
4594 |
21 Oct 08 |
nicklas |
You should have received a copy of the GNU General Public License |
4594 |
21 Oct 08 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4594 |
21 Oct 08 |
nicklas |
21 |
*/ |
4594 |
21 Oct 08 |
nicklas |
22 |
package net.sf.basedb.util.filter; |
4594 |
21 Oct 08 |
nicklas |
23 |
|
4594 |
21 Oct 08 |
nicklas |
24 |
import java.util.Collection; |
4594 |
21 Oct 08 |
nicklas |
25 |
|
4594 |
21 Oct 08 |
nicklas |
26 |
/** |
4594 |
21 Oct 08 |
nicklas |
A filter implementation that accpets an object only if |
4594 |
21 Oct 08 |
nicklas |
at none of the parent filters accepts it. |
4594 |
21 Oct 08 |
nicklas |
29 |
|
4594 |
21 Oct 08 |
nicklas |
@author Nicklas |
4594 |
21 Oct 08 |
nicklas |
@version 2.9 |
4594 |
21 Oct 08 |
nicklas |
@base.modified $Date$ |
4594 |
21 Oct 08 |
nicklas |
33 |
*/ |
4594 |
21 Oct 08 |
nicklas |
34 |
public class NoneOfFilter<T> |
4594 |
21 Oct 08 |
nicklas |
35 |
implements Filter<T> |
4594 |
21 Oct 08 |
nicklas |
36 |
{ |
4594 |
21 Oct 08 |
nicklas |
37 |
private final Collection<? extends Filter<? super T>> parents; |
4594 |
21 Oct 08 |
nicklas |
38 |
|
4594 |
21 Oct 08 |
nicklas |
39 |
/** |
4594 |
21 Oct 08 |
nicklas |
Create a new filter. |
4594 |
21 Oct 08 |
nicklas |
@param parents The parent filters |
4594 |
21 Oct 08 |
nicklas |
42 |
*/ |
4594 |
21 Oct 08 |
nicklas |
43 |
public NoneOfFilter( Collection<? extends Filter<? super T>> parents) |
4594 |
21 Oct 08 |
nicklas |
44 |
{ |
4594 |
21 Oct 08 |
nicklas |
45 |
this.parents = parents; |
4594 |
21 Oct 08 |
nicklas |
46 |
} |
4594 |
21 Oct 08 |
nicklas |
47 |
|
4594 |
21 Oct 08 |
nicklas |
48 |
/** |
4594 |
21 Oct 08 |
nicklas |
@return TRUE only if no parent filters returns TRUE, FALSE otherwise |
4594 |
21 Oct 08 |
nicklas |
50 |
*/ |
4594 |
21 Oct 08 |
nicklas |
51 |
@Override |
4594 |
21 Oct 08 |
nicklas |
52 |
public boolean evaluate(T object) |
4594 |
21 Oct 08 |
nicklas |
53 |
{ |
4594 |
21 Oct 08 |
nicklas |
54 |
for (Filter<? super T> pf : parents) |
4594 |
21 Oct 08 |
nicklas |
55 |
{ |
4594 |
21 Oct 08 |
nicklas |
56 |
if (pf.evaluate(object)) return false; |
4594 |
21 Oct 08 |
nicklas |
57 |
} |
4594 |
21 Oct 08 |
nicklas |
58 |
return true; |
4594 |
21 Oct 08 |
nicklas |
59 |
} |
4594 |
21 Oct 08 |
nicklas |
60 |
} |