java.lang.Object
tools.jackson.databind.ser.FilterProvider
tools.jackson.databind.ser.std.SimpleFilterProvider
- All Implemented Interfaces:
Serializable,Snapshottable<FilterProvider>
Simple
FilterProvider implementation that just stores
direct id-to-filter mapping.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag that indicates whether request for an unknown filter id should result an exception (default) or not.protected PropertyFilterThis 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> Mappings from ids to filters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFilter(String id, PropertyFilter filter) Adds an instance ofPropertyFilterassociated with the givenidparameter.addFilter(String id, SimpleBeanPropertyFilter filter) Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter.findPropertyFilter(SerializationContext ctxt, Object filterId, Object valueToFilter) Lookup method used to findPropertyFilterthat has specified id.removeFilter(String id) Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter.setFailOnUnknownId(boolean state) snapshot()boolean
-
Field Details
-
_filtersById
Mappings from ids to filters. -
_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 _cfgFailOnUnknownIdFlag 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
- Parameters:
mapping- Mapping from id to filter; used as is if if possible
-
SimpleFilterProvider
-
-
Method Details
-
snapshot
- Specified by:
snapshotin interfaceSnapshottable<FilterProvider>
-
setDefaultFilter
-
setDefaultFilter
Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter. -
getDefaultFilter
-
setFailOnUnknownId
-
willFailOnUnknownId
public boolean willFailOnUnknownId() -
addFilter
Adds an instance ofPropertyFilterassociated with the givenidparameter. Note that there can always only be one filter associated with a singleidparameter, meaning a new filter with the sameidwill always override the previously added filter.WARNING: Binding
idorfilterwithnullvalue 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
Overloaded variant just to resolve "ties" when usingSimpleBeanPropertyFilter.Adds an instance of
SimpleBeanPropertyFilterassociated with the givenidparameter. Note that there can always only be one filter associated with a singleidparameter, meaning a new filter with the sameidwill always override the previously added filter.WARNING: Binding
idorfilterwithnullvalue 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
-
findPropertyFilter
public PropertyFilter findPropertyFilter(SerializationContext ctxt, Object filterId, Object valueToFilter) Description copied from class:FilterProviderLookup method used to findPropertyFilterthat 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:
findPropertyFilterin classFilterProviderfilterId- 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.
-