Class SimpleFilterProvider

java.lang.Object
tools.jackson.databind.ser.FilterProvider
tools.jackson.databind.ser.std.SimpleFilterProvider
All Implemented Interfaces:
Serializable, Snapshottable<FilterProvider>

public class SimpleFilterProvider extends FilterProvider implements Serializable
Simple FilterProvider implementation that just stores direct id-to-filter mapping.
See Also:
  • Field Details

    • _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 Details

    • SimpleFilterProvider

      public SimpleFilterProvider()
    • SimpleFilterProvider

      public SimpleFilterProvider(Map<String,PropertyFilter> mapping)
      Parameters:
      mapping - Mapping from id to filter; used as is if if possible
    • SimpleFilterProvider

      protected SimpleFilterProvider(SimpleFilterProvider src)
  • Method Details

    • snapshot

      public SimpleFilterProvider snapshot()
      Specified by:
      snapshot in interface Snapshottable<FilterProvider>
    • 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

      public SimpleFilterProvider addFilter(String id, PropertyFilter filter)
      Adds an instance of PropertyFilter associated with the given id parameter. Note that there can always only be one filter associated with a single id parameter, meaning a new filter with the same id will always override the previously added filter.

      WARNING: Binding id or filter with null value will not be validated within this method, but during serialization of target class annotated with JsonFilter.

      Parameters:
      id - The id to associate the filter with.
      filter - The filter to add;
      Returns:
      This provider instance, for call-chaining
    • addFilter

      public SimpleFilterProvider addFilter(String id, SimpleBeanPropertyFilter filter)
      Overloaded variant just to resolve "ties" when using SimpleBeanPropertyFilter.

      Adds an instance of SimpleBeanPropertyFilter associated with the given id parameter. Note that there can always only be one filter associated with a single id parameter, meaning a new filter with the same id will always override the previously added filter.

      WARNING: Binding id or filter with null value will not be validated within this method, but during serialization of target class annotated with JsonFilter.

      Parameters:
      id - The id to associate the filter with.
      filter - The filter to add;
      Returns:
      This provider instance, for call-chaining
    • removeFilter

      public PropertyFilter removeFilter(String id)
    • findPropertyFilter

      public PropertyFilter findPropertyFilter(SerializationContext ctxt, 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.
      Specified by:
      findPropertyFilter in class FilterProvider
      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.