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 class Filter are required to be immutable.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    accept(E e)
    Returns true if the specified object is accepted and returns false if the specified object is rejected.
    static <E> Filter<E>
    Returns a filter that accepts all non-null objects.
    static <E> Filter<E>
    Returns a filter that accepts all non-null objects that are not contained in the specified collection.
    static <E> Filter<E>
    Returns a filter that accepts all non-null objects that are contained in the specified collection.
  • Method Details

    • 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(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:
      NullPointerException - if include == null
    • excludeFilter

      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.
      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 - if exclude == null
    • accept

      boolean accept(E e)
      Returns true if the specified object is accepted and returns false if the specified object is rejected.
      Parameters:
      e - the object to be filtered
      Returns:
      true if the specified object is accepted
      Throws:
      NullPointerException - if e==null