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

      All Methods Static Methods Instance Methods Abstract Methods 
      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> 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 - if include == 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 - 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:
        java.lang.NullPointerException - if e==null