com.fasterxml.jackson.databind.ser.impl

## Class SimpleFilterProvider

- java.lang.Object
- - com.fasterxml.jackson.databind.ser.FilterProvider
  - - com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider

- All Implemented Interfaces:
    Serializable

      public class SimpleFilterProvider
      extends FilterProvider
      implements Serializable

  Simple `FilterProvider` implementation that just stores direct id-to-filter mapping.

  Note that version 2.3 was a partial rewrite, now that `PropertyFilter` is set to replace `BeanPropertyFilter`.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `_cfgFailOnUnknownId` Flag that indicates whether request for an unknown filter id should result an exception (default) or not.
    `protected PropertyFilter` | `_defaultFilter` This is the filter we return in case no mapping was found for given id; default is 'null' (in which case caller typically reports an error), but can be set to an explicit filter.
    `protected Map<String,PropertyFilter>` | `_filtersById` Mappings from ids to filters.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleFilterProvider()`
    `SimpleFilterProvider(Map<String,?> mapping)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `SimpleFilterProvider` | `addFilter(String id, BeanPropertyFilter filter)` Deprecated. since 2.3
    `SimpleFilterProvider` | `addFilter(String id, PropertyFilter filter)`
    `SimpleFilterProvider` | `addFilter(String id, SimpleBeanPropertyFilter filter)` Overloaded variant just to resolve "ties" when using `SimpleBeanPropertyFilter`.
    `BeanPropertyFilter` | `findFilter(Object filterId)` Deprecated.
    `PropertyFilter` | `findPropertyFilter(Object filterId, Object valueToFilter)` Lookup method used to find `PropertyFilter` that has specified id.
    `PropertyFilter` | `getDefaultFilter()`
    `PropertyFilter` | `removeFilter(String id)`
    `SimpleFilterProvider` | `setDefaultFilter(BeanPropertyFilter f)` Deprecated. Since 2.3 should use `PropertyFilter` instead of `BeanPropertyFilter`
    `SimpleFilterProvider` | `setDefaultFilter(PropertyFilter f)`
    `SimpleFilterProvider` | `setDefaultFilter(SimpleBeanPropertyFilter f)` Overloaded variant just to resolve "ties" when using `SimpleBeanPropertyFilter`.
    `SimpleFilterProvider` | `setFailOnUnknownId(boolean state)`
    `boolean` | `willFailOnUnknownId()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _filtersById

          protected final Map<String,PropertyFilter> _filtersById

      Mappings from ids to filters.

    - #### _defaultFilter

          protected PropertyFilter _defaultFilter

      This is the filter we return in case no mapping was found for given id; default is 'null' (in which case caller typically reports an error), but can be set to an explicit filter.

    - #### _cfgFailOnUnknownId

          protected boolean _cfgFailOnUnknownId

      Flag that indicates whether request for an unknown filter id should result an exception (default) or not. Note that this is only relevant if no default filter has been configured.

  - ### Constructor Detail

    - #### SimpleFilterProvider

          public SimpleFilterProvider()

    - #### SimpleFilterProvider

          public SimpleFilterProvider(Map<String,?> mapping)

      Parameters:
        `mapping` - Mapping from id to filter; used as is if if possible

  - ### Method Detail

    - #### setDefaultFilter

          @Deprecated
          public SimpleFilterProvider setDefaultFilter(BeanPropertyFilter f)

      Deprecated. Since 2.3 should use `PropertyFilter` instead of `BeanPropertyFilter`
      Method for defining filter to return for "unknown" filters; cases where there is no mapping from given id to an explicit filter.
      Parameters:
        `f` - Filter to return when no filter is found for given id

    - #### setDefaultFilter

          public SimpleFilterProvider setDefaultFilter(PropertyFilter f)

    - #### setDefaultFilter

          public SimpleFilterProvider setDefaultFilter(SimpleBeanPropertyFilter f)

      Overloaded variant just to resolve "ties" when using `SimpleBeanPropertyFilter`.

    - #### getDefaultFilter

          public PropertyFilter getDefaultFilter()

    - #### setFailOnUnknownId

          public SimpleFilterProvider setFailOnUnknownId(boolean state)

    - #### willFailOnUnknownId

          public boolean willFailOnUnknownId()

    - #### addFilter

          @Deprecated
          public SimpleFilterProvider addFilter(String id,
                                                            BeanPropertyFilter filter)

      Deprecated. since 2.3

    - #### addFilter

          public SimpleFilterProvider addFilter(String id,
                                                PropertyFilter filter)

    - #### addFilter

          public SimpleFilterProvider addFilter(String id,
                                                SimpleBeanPropertyFilter filter)

      Overloaded variant just to resolve "ties" when using `SimpleBeanPropertyFilter`.

    - #### removeFilter

          public PropertyFilter removeFilter(String id)

    - #### findFilter

          @Deprecated
          public BeanPropertyFilter findFilter(Object filterId)

      Deprecated.
      Description copied from class: `FilterProvider`
      Lookup method used to find `BeanPropertyFilter` that has specified id. Note that id is typically a `String`, but is not necessarily limited to that; that is, while standard components use String, custom implementation can choose other kinds of keys.
      Specified by:
        `findFilter` in class `FilterProvider`
      Returns:
        Filter registered with specified id, if one defined; null if none found.

    - #### findPropertyFilter

          public PropertyFilter findPropertyFilter(Object filterId,
                                                   Object valueToFilter)

      Description copied from class: `FilterProvider`
      Lookup method used to find `PropertyFilter` that has specified id. Note that id is typically a `String`, but is not necessarily limited to that; that is, while standard components use String, custom implementation can choose other kinds of keys.

      This method is the replacement for `FilterProvider.findFilter(java.lang.Object)` starting with 2.3.

      Note that the default implementation is designed to support short-term backwards compatibility, and will call the deprecated `findFilter` method, then wrap filter if one found as `PropertyFilter`. It should be overridden by up-to-date implementations

      Overrides:
        `findPropertyFilter` in class `FilterProvider`
      Parameters:
        `filterId` - Id of the filter to fetch
        `valueToFilter` - Object being filtered (usually POJO, but may be a `Map`, or in future a container), if available; not available when generating schemas.
      Returns:
        Filter to use, if any.

Copyright © 2008–2020 FasterXML. All rights reserved.