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
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the specified object is accepted and returnsfalse
if the specified object is rejected.static <E> Filter
<E> Returns a filter that accepts all non-null objects.static <E> Filter
<E> excludeFilter
(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
(Collection<E> include) Returns a filter that accepts all non-null objects that are contained in the specified collection.
-
Method Details
-
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
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:
NullPointerException
- ifinclude == null
-
excludeFilter
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:
NullPointerException
- ifexclude == null
-
accept
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:
NullPointerException
- ife==null
-