# Interface BloomFilterExtractor

All Known Implementing Classes:
  `LayeredBloomFilter`, `LayerManager`

Functional Interface:
  This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface BloomFilterExtractor
Produces Bloom filters from a collection (for example, `LayeredBloomFilter`).

Since:
  4.5.0-M2

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default BloomFilter[]`
  `asBloomFilterArray()`
  Return an array of the Bloom filters in the collection.
  `default BloomFilter`
  `flatten()`
  Create a standard (non-layered) Bloom filter by merging all of the layers.
  `static <T extends BloomFilter<T>>
  BloomFilterExtractor`
  `fromBloomFilterArray(BloomFilter<?>... filters)`
  Creates a BloomFilterExtractor from an array of Bloom filters.
  `default boolean`
  `processBloomFilterPair(BloomFilterExtractor other, BiPredicate<BloomFilter,BloomFilter> func)`
  Applies the `func` to each Bloom filter pair in order.
  `boolean`
  `processBloomFilters(Predicate<BloomFilter> bloomFilterPredicate)`
  Executes a Bloom filter Predicate on each Bloom filter in the collection.

- ## Method Details

  - ### fromBloomFilterArray

    static <T extends BloomFilter<T>> BloomFilterExtractor fromBloomFilterArray(BloomFilter<?>... filters)
    Creates a BloomFilterExtractor from an array of Bloom filters.
    - The asBloomFilterArray() method returns a copy of the original array with references to the original filters.
    - The forEachBloomFilterPair() method uses references to the original filters.

    All modifications to the Bloom filters are reflected in the original filters

    Type Parameters:
      `T` - The BloomFilter type.
    Parameters:
      `filters` - The filters to be returned by the extractor.
    Returns:
      THe BloomFilterExtractor containing the filters.

  - ### asBloomFilterArray

    default BloomFilter[] asBloomFilterArray()
    Return an array of the Bloom filters in the collection.

    Implementations should specify if the array contains deep copies, immutable instances, or references to the filters in the collection.

    The default method returns a deep copy of the enclosed filters.

    Returns:
      An array of Bloom filters.

  - ### flatten

    default BloomFilter flatten()
    Create a standard (non-layered) Bloom filter by merging all of the layers. If the filter is empty this method will return an empty Bloom filter.
    Returns:
      the merged bloom filter, never null.
    Throws:
      `NullPointerException` - if this call did not process any filters.

  - ### processBloomFilterPair

    default boolean processBloomFilterPair(BloomFilterExtractor other, BiPredicate<BloomFilter,BloomFilter> func)
    Applies the `func` to each Bloom filter pair in order. Will apply all of the Bloom filters from the other BloomFilterExtractor to this extractor. If either `this` extractor or `other` extractor has fewer BloomFilters the method will provide `null` for all excess calls to the `func`.

    This implementation returns references to the Bloom filter. Other implementations should specify if the array contains deep copies, immutable instances, or references to the filters in the collection.

    Parameters:
      `other` - The other BloomFilterExtractor that provides the y values in the (x,y) pair.
      `func` - The function to apply.
    Returns:
      `true` if the `func` returned `true` for every pair, `false` otherwise.

  - ### processBloomFilters

    boolean processBloomFilters(Predicate<BloomFilter> bloomFilterPredicate)
    Executes a Bloom filter Predicate on each Bloom filter in the collection. The ordering of the Bloom filters is not specified by this interface.
    Parameters:
      `bloomFilterPredicate` - the predicate to evaluate each Bloom filter with.
    Returns:
      `false` when the first filter fails the predicate test. Returns `true` if all filters pass the test.