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 TypeMethodDescriptionbooleanReturnstrueif the specified object is accepted and returnsfalseif 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
Returnstrueif the specified object is accepted and returnsfalseif the specified object is rejected.- Parameters:
e- the object to be filtered- Returns:
trueif the specified object is accepted- Throws:
NullPointerException- ife==null
-