1 package com.fasterxml.jackson.databind.ser; 2 3 import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; 4 5 /** 6 * Interface for objects that providers instances of {@link PropertyFilter} 7 * that match given ids. A provider is configured to be used during serialization, 8 * to find filter to used based on id specified by {@link com.fasterxml.jackson.annotation.JsonFilter} 9 * annotation on bean class. 10 */ 11 public abstract class FilterProvider 12 { 13 /** 14 * Lookup method used to find {@link BeanPropertyFilter} that has specified id. 15 * Note that id is typically a {@link java.lang.String}, but is not necessarily 16 * limited to that; that is, while standard components use String, custom 17 * implementation can choose other kinds of keys. 18 * 19 * @return Filter registered with specified id, if one defined; null if 20 * none found. 21 * 22 * @deprecated Since 2.3 deprecated because {@link BeanPropertyFilter} is deprecated; 23 */ 24 @Deprecated findFilter(Object filterId)25 public abstract BeanPropertyFilter findFilter(Object filterId); 26 27 /** 28 * Lookup method used to find {@link PropertyFilter} that has specified id. 29 * Note that id is typically a {@link java.lang.String}, but is not necessarily 30 * limited to that; that is, while standard components use String, custom 31 * implementation can choose other kinds of keys. 32 *<p> 33 * This method is the replacement for {@link #findFilter} starting with 2.3. 34 *<p> 35 * Note that the default implementation is designed to support short-term 36 * backwards compatibility, and will call the deprecated <code>findFilter</code> 37 * method, then wrap filter if one found as {@link PropertyFilter}. 38 * It should be overridden by up-to-date implementations 39 * 40 * @param filterId Id of the filter to fetch 41 * @param valueToFilter Object being filtered (usually POJO, but may be a {@link java.util.Map}, 42 * or in future a container), <b>if available</b>; not available when generating 43 * schemas. 44 * 45 * @return Filter to use, if any. 46 * 47 * @since 2.3 48 */ findPropertyFilter(Object filterId, Object valueToFilter)49 public PropertyFilter findPropertyFilter(Object filterId, Object valueToFilter) 50 { 51 @SuppressWarnings("deprecation") 52 BeanPropertyFilter old = findFilter(filterId); 53 if (old == null) { 54 return null; 55 } 56 return SimpleBeanPropertyFilter.from(old); 57 } 58 } 59