1 package com.fasterxml.jackson.databind.ser;
2 
3 import com.fasterxml.jackson.core.JsonGenerator;
4 import com.fasterxml.jackson.databind.JsonMappingException;
5 import com.fasterxml.jackson.databind.SerializerProvider;
6 import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor;
7 import com.fasterxml.jackson.databind.node.ObjectNode;
8 
9 /**
10  * Interface that defines API for filter objects use (as configured
11  * using {@link com.fasterxml.jackson.annotation.JsonFilter})
12  * for filtering bean properties to serialize.
13  *<p>
14  * Starting with version 2.3 this class is deprecated; use
15  * {@link PropertyFilter} instead.
16  *
17  * @deprecated Since 2.3: use {@link PropertyFilter} instead.
18  */
19 @Deprecated
20 public interface BeanPropertyFilter
21 {
22     /**
23      * Method called by {@link BeanSerializer} to let filter decide what to do with
24      * given bean property value: the usual choices are to either filter out (i.e.
25      * do nothing) or write using given {@link BeanPropertyWriter}, although filters
26      * can choose other to do something different altogether.
27      *<p>
28      * Typical implementation is something like:
29      *<pre>
30      * if (include(writer)) {
31      *      writer.serializeAsField(pojo, jgen, prov);
32      * }
33      *</pre>
34      *
35      * @param pojo Object that contains property value to serialize
36      * @param jgen Generator use for serializing value
37      * @param prov Provider that can be used for accessing dynamic aspects of serialization
38      *    processing
39      * @param writer Default bean property serializer to use
40      */
serializeAsField(Object pojo, JsonGenerator jgen, SerializerProvider prov, BeanPropertyWriter writer)41     public void serializeAsField(Object pojo, JsonGenerator jgen, SerializerProvider prov,
42             BeanPropertyWriter writer)
43         throws Exception;
44 
45     /**
46      * Method called by {@link BeanSerializer} to let the filter determine whether, and in what
47      * form the given property exist within the parent, or root, schema. Filters can omit
48      * adding the property to the node, or choose the form of the schema value for the property.
49      *<p>
50      * Typical implementation is something like:
51      *<pre>
52      * if (include(writer)) {
53      *      writer.depositSchemaProperty(propertiesNode, provider);
54      * }
55      *</pre>
56      *
57      * @param writer Bean property writer to use to create schema value
58      * @param propertiesNode Node which the given property would exist within
59      * @param provider Provider that can be used for accessing dynamic aspects of serialization
60      * 	processing
61      *
62      * @since 2.1
63      * @deprecated Since 2.3: new code should use the alternative <code>depositSchemaProperty</code>
64      *   method
65      */
66     @Deprecated
depositSchemaProperty(BeanPropertyWriter writer, ObjectNode propertiesNode, SerializerProvider provider)67     public void depositSchemaProperty(BeanPropertyWriter writer, ObjectNode propertiesNode,
68             SerializerProvider provider)
69         throws JsonMappingException;
70 
71     /**
72      * Method called by {@link BeanSerializer} to let the filter determine whether, and in what
73      * form the given property exist within the parent, or root, schema. Filters can omit
74      * adding the property to the node, or choose the form of the schema value for the property
75      *<p>
76      * Typical implementation is something like:
77      *<pre>
78      * if (include(writer)) {
79      *      writer.depositSchemaProperty(objectVisitor, provider);
80      * }
81      *</pre>
82      *
83      * @param writer Bean property serializer to use to create schema value
84      * @param objectVisitor JsonObjectFormatVisitor which should be aware of
85      * the property's existence
86      * @param provider Provider that can be used for accessing dynamic aspects of serialization
87      * 	processing
88      *
89      * @since 2.1
90      */
depositSchemaProperty(BeanPropertyWriter writer, JsonObjectFormatVisitor objectVisitor, SerializerProvider provider)91     public void depositSchemaProperty(BeanPropertyWriter writer, JsonObjectFormatVisitor objectVisitor,
92             SerializerProvider provider)
93         throws JsonMappingException;
94 }
95