Class SimpleFilterProvider
- java.lang.Object
-
- com.fasterxml.jackson.databind.ser.FilterProvider
-
- com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider
-
- All Implemented Interfaces:
java.io.Serializable
public class SimpleFilterProvider extends FilterProvider implements java.io.Serializable
SimpleFilterProvider
implementation that just stores direct id-to-filter mapping. It also allows specifying a "default" filter to return if no registered instance matches given filter id.Note that version 2.3 was a partial rewrite, now that
PropertyFilter
is set to replaceBeanPropertyFilter
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleFilterProvider()
SimpleFilterProvider(java.util.Map<java.lang.String,?> mapping)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SimpleFilterProvider
addFilter(java.lang.String id, BeanPropertyFilter filter)
Deprecated.since 2.3SimpleFilterProvider
addFilter(java.lang.String id, SimpleBeanPropertyFilter filter)
Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter
.SimpleFilterProvider
addFilter(java.lang.String id, PropertyFilter filter)
Adds an instance ofPropertyFilter
associated with the givenid
parameter.BeanPropertyFilter
findFilter(java.lang.Object filterId)
Deprecated.PropertyFilter
findPropertyFilter(java.lang.Object filterId, java.lang.Object valueToFilter)
Lookup method used to findPropertyFilter
that has specified id.PropertyFilter
getDefaultFilter()
PropertyFilter
removeFilter(java.lang.String id)
SimpleFilterProvider
setDefaultFilter(BeanPropertyFilter f)
Deprecated.Since 2.3 should usePropertyFilter
instead ofBeanPropertyFilter
SimpleFilterProvider
setDefaultFilter(SimpleBeanPropertyFilter f)
Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter
.SimpleFilterProvider
setDefaultFilter(PropertyFilter f)
Method for defining "default filter" to use, if any (null
if none), to return in case no registered instance matches passed filter id.SimpleFilterProvider
setFailOnUnknownId(boolean state)
boolean
willFailOnUnknownId()
-
-
-
Method Detail
-
setDefaultFilter
@Deprecated public SimpleFilterProvider setDefaultFilter(BeanPropertyFilter f)
Deprecated.Since 2.3 should usePropertyFilter
instead ofBeanPropertyFilter
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)
Method for defining "default filter" to use, if any (null
if none), to return in case no registered instance matches passed filter id.- Parameters:
f
- Default filter to set- Returns:
- This provider instance, for call-chaining
-
setDefaultFilter
public SimpleFilterProvider setDefaultFilter(SimpleBeanPropertyFilter f)
Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter
.
-
getDefaultFilter
public PropertyFilter getDefaultFilter()
-
setFailOnUnknownId
public SimpleFilterProvider setFailOnUnknownId(boolean state)
-
willFailOnUnknownId
public boolean willFailOnUnknownId()
-
addFilter
@Deprecated public SimpleFilterProvider addFilter(java.lang.String id, BeanPropertyFilter filter)
Deprecated.since 2.3
-
addFilter
public SimpleFilterProvider addFilter(java.lang.String id, PropertyFilter filter)
Adds an instance ofPropertyFilter
associated with the givenid
parameter. Note that there can always only be one filter associated with a singleid
parameter, meaning a new filter with the sameid
will always override the previously added filter.WARNING: Binding
id
orfilter
withnull
value will not be validated within this method, but during serialization of target class annotated withJsonFilter
.- 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(java.lang.String id, SimpleBeanPropertyFilter filter)
Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter
.Adds an instance of
SimpleBeanPropertyFilter
associated with the givenid
parameter. Note that there can always only be one filter associated with a singleid
parameter, meaning a new filter with the sameid
will always override the previously added filter.WARNING: Binding
id
orfilter
withnull
value will not be validated within this method, but during serialization of target class annotated withJsonFilter
.- 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(java.lang.String id)
-
findFilter
@Deprecated public BeanPropertyFilter findFilter(java.lang.Object filterId)
Deprecated.Description copied from class:FilterProvider
Lookup method used to findBeanPropertyFilter
that has specified id. Note that id is typically aString
, 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 classFilterProvider
- Returns:
- Filter registered with specified id, if one defined; null if none found.
-
findPropertyFilter
public PropertyFilter findPropertyFilter(java.lang.Object filterId, java.lang.Object valueToFilter)
Description copied from class:FilterProvider
Lookup method used to findPropertyFilter
that has specified id. Note that id is typically aString
, 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 asPropertyFilter
. It should be overridden by up-to-date implementations- Overrides:
findPropertyFilter
in classFilterProvider
- Parameters:
filterId
- Id of the filter to fetchvalueToFilter
- Object being filtered (usually POJO, but may be aMap
, or in future a container), if available; not available when generating schemas.- Returns:
- Filter to use, if any.
-
-