Package blbutil
Interface Filter<E>
-
- Type Parameters:
E
- the type of object that is filtered.
public interface Filter<E>
A filter for accepting or rejecting objects.
Instances of classFilter
are required to be immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
accept(E e)
Returnstrue
if the specified object is accepted and returnsfalse
if the specified object is rejected.static <E> Filter<E>
acceptAllFilter()
Returns a filter that accepts all non-null objects.static <E> Filter<E>
excludeFilter(java.util.Collection<E> exclude)
Returns a filter that accepts all non-null objects that are not contained in the specified collection.static <E> Filter<E>
includeFilter(java.util.Collection<E> include)
Returns a filter that accepts all non-null objects that are contained in the specified collection.
-
-
-
Method Detail
-
acceptAllFilter
static <E> Filter<E> acceptAllFilter()
Returns a filter that accepts all non-null objects.- Type Parameters:
E
- the type of object that is filtered- Returns:
- a filter that accepts all non-null objects
-
includeFilter
static <E> Filter<E> includeFilter(java.util.Collection<E> include)
Returns a filter that accepts all non-null objects that are contained in the specified collection.- Type Parameters:
E
- the type of object that is filtered- Parameters:
include
- the collection of objects that will be accepted by the filter- Returns:
- a filter that accepts all non-null objects that are contained in the specified collection
- Throws:
java.lang.NullPointerException
- ifinclude == null
-
excludeFilter
static <E> Filter<E> excludeFilter(java.util.Collection<E> exclude)
Returns a filter that accepts all non-null objects that are not contained in the specified collection.- Type Parameters:
E
- the type of object that is filtered- Parameters:
exclude
- the collection of objects that will be rejected by the filter- Returns:
- a filter that accepts all non-null objects that are not contained in the specified collection
- Throws:
java.lang.NullPointerException
- ifexclude == null
-
accept
boolean accept(E e)
Returnstrue
if the specified object is accepted and returnsfalse
if the specified object is rejected.- Parameters:
e
- the object to be filtered- Returns:
true
if the specified object is accepted- Throws:
java.lang.NullPointerException
- ife==null
-
-