Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.ser.impl

public Class SimpleFilterProvider

extends FilterProvider
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.util.*, com.fasterxml.jackson.databind.ser.*

Simple FilterProvider 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 replace BeanPropertyFilter.

Field Summary

Modifier and TypeField 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 final Map<String, PropertyFilter>
_filtersById

Mappings from ids to filters.

private static final long

Constructor Summary

AccessConstructor and Description
public
public
SimpleFilterProvider(Map<String, ?>
Mapping from id to filter; used as is if if possible
mapping
)

Method Summary

Modifier and TypeMethod and Description
private static final Map<String, PropertyFilter>
_convert(Map<String, ?> filters)

private static final PropertyFilter
_convert(BeanPropertyFilter f)

Deprecated as a consequence of BeanPropertyFilter being deprecated.
public SimpleFilterProvider
addFilter(String id, BeanPropertyFilter filter)

Deprecated since 2.3
public SimpleFilterProvider

Returns:

This provider instance, for call-chaining
addFilter
(String
The id to associate the filter with.
id
,
PropertyFilter
The filter to add;
filter
)

Adds an instance of PropertyFilter associated with the given id parameter.

public SimpleFilterProvider

Returns:

This provider instance, for call-chaining
addFilter
(String
The id to associate the filter with.
id
,
SimpleBeanPropertyFilter
The filter to add;
filter
)

Deprecated as a consequence of SimpleBeanPropertyFilter being deprecated.
Overloaded variant just to resolve "ties" when using SimpleBeanPropertyFilter.
public BeanPropertyFilter
findFilter(Object filterId)

Implements abstract com.fasterxml.jackson.databind.ser.FilterProvider.findFilter.

Deprecated
Lookup method used to find BeanPropertyFilter that has specified id. Note that id is typically a java.lang.String, but is not necessarily limited to that; that is, while standard components use String, custom implementation can choose other kinds of keys.
public PropertyFilter
findPropertyFilter(Object
Id of the filter to fetch
filterId
,
Object
Object being filtered (usually POJO, but may be a java.util.Map, or in future a container), if available; not available when generating schemas.
valueToFilter
)

Overrides com.fasterxml.jackson.databind.ser.FilterProvider.findPropertyFilter.

Lookup method used to find PropertyFilter that has specified id. Note that id is typically a java.lang.String, but is not necessarily limited to that; that is, while standard components use String, custom implementation can choose other kinds of keys.
public PropertyFilter
public PropertyFilter
public SimpleFilterProvider
setDefaultFilter(BeanPropertyFilter
Filter to return when no filter is found for given id
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.
public SimpleFilterProvider

Returns:

This provider instance, for call-chaining
setDefaultFilter
(PropertyFilter
Default filter to set
f
)

Method for defining "default filter" to use, if any (null if none), to return in case no registered instance matches passed filter id.

public SimpleFilterProvider
setDefaultFilter(SimpleBeanPropertyFilter f)

Deprecated as a consequence of SimpleBeanPropertyFilter being deprecated.
Overloaded variant just to resolve "ties" when using SimpleBeanPropertyFilter.
public SimpleFilterProvider
setFailOnUnknownId(boolean state)

public boolean

Field Detail

_cfgFailOnUnknownIdback to summary
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.

_defaultFilterback to summary
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.

_filtersByIdback to summary
protected final Map<String, PropertyFilter> _filtersById

Mappings from ids to filters.

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

SimpleFilterProviderback to summary
public SimpleFilterProvider()
SimpleFilterProviderback to summary
public SimpleFilterProvider(Map<String, ?> mapping)
Parameters
mapping:Map<String, ?>

Mapping from id to filter; used as is if if possible

Annotations
@SuppressWarnings:unchecked

Method Detail

_convertback to summary
private static final Map<String, PropertyFilter> _convert(Map<String, ?> filters)
Annotations
@SuppressWarnings:deprecation
_convertback to summary
private static final PropertyFilter _convert(BeanPropertyFilter f)

Deprecated

as a consequence of BeanPropertyFilter being deprecated. See corresponding docs for further information.

Annotations
@SuppressWarnings:deprecation
addFilterback to summary
public SimpleFilterProvider addFilter(String id, BeanPropertyFilter filter)

Deprecated

since 2.3

Annotations
@Deprecated
addFilterback to summary
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 com.fasterxml.jackson.annotation.JsonFilter.

Parameters
id:String

The id to associate the filter with.

filter:PropertyFilter

The filter to add;

Returns:SimpleFilterProvider

This provider instance, for call-chaining

addFilterback to summary
public SimpleFilterProvider addFilter(String id, SimpleBeanPropertyFilter filter)

Deprecated

as a consequence of SimpleBeanPropertyFilter being deprecated. See corresponding docs for further information.

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 com.fasterxml.jackson.annotation.JsonFilter.

Parameters
id:String

The id to associate the filter with.

filter:SimpleBeanPropertyFilter

The filter to add;

Returns:SimpleFilterProvider

This provider instance, for call-chaining

findFilterback to summary
public BeanPropertyFilter findFilter(Object filterId)

Implements abstract com.fasterxml.jackson.databind.ser.FilterProvider.findFilter.

Doc from com.fasterxml.jackson.databind.ser.FilterProvider.findFilter.

Deprecated

Lookup method used to find BeanPropertyFilter that has specified id. Note that id is typically a java.lang.String, but is not necessarily limited to that; that is, while standard components use String, custom implementation can choose other kinds of keys.

Returns:BeanPropertyFilter

Filter registered with specified id, if one defined; null if none found.

Annotations
@Deprecated
@Override
findPropertyFilterback to summary
public PropertyFilter findPropertyFilter(Object filterId, Object valueToFilter)

Overrides com.fasterxml.jackson.databind.ser.FilterProvider.findPropertyFilter.

Doc from com.fasterxml.jackson.databind.ser.FilterProvider.findPropertyFilter.

Lookup method used to find PropertyFilter that has specified id. Note that id is typically a java.lang.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 findFilter 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

Parameters
filterId:Object

Id of the filter to fetch

valueToFilter:Object

Object being filtered (usually POJO, but may be a java.util.Map, or in future a container), if available; not available when generating schemas.

Returns:PropertyFilter

Filter to use, if any.

Annotations
@Override
getDefaultFilterback to summary
public PropertyFilter getDefaultFilter()
removeFilterback to summary
public PropertyFilter removeFilter(String id)
setDefaultFilterback to summary
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:BeanPropertyFilter

Filter to return when no filter is found for given id

Annotations
@Deprecated
setDefaultFilterback to summary
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:PropertyFilter

Default filter to set

Returns:SimpleFilterProvider

This provider instance, for call-chaining

setDefaultFilterback to summary
public SimpleFilterProvider setDefaultFilter(SimpleBeanPropertyFilter f)

Deprecated

as a consequence of SimpleBeanPropertyFilter being deprecated. See corresponding docs for further information.

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

setFailOnUnknownIdback to summary
public SimpleFilterProvider setFailOnUnknownId(boolean state)
willFailOnUnknownIdback to summary
public boolean willFailOnUnknownId()