Class SimpleBeanPropertyFilter
java.lang.Object
com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
- All Implemented Interfaces:
BeanPropertyFilter,PropertyFilter
- Direct Known Subclasses:
SimpleBeanPropertyFilter.FilterExceptFilter,SimpleBeanPropertyFilter.SerializeExceptFilter
Simple
PropertyFilter implementation that only uses property name
to determine whether to serialize property as is, or to filter it out.
Use of this class as the base implementation for any custom
PropertyFilter implementations is strongly encouraged,
because it can provide default implementation for any methods that may
be added in PropertyFilter (as unfortunate as additions may be).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFilter implementation which defaults to filtering out unknown properties and only serializes ones explicitly listed.static classFilter implementation which defaults to serializing all properties, except for ones explicitly listed to be filtered out. -
Method Summary
Modifier and TypeMethodDescriptionvoiddepositSchemaProperty(BeanPropertyWriter writer, JsonObjectFormatVisitor objectVisitor, SerializerProvider provider) Deprecated.voiddepositSchemaProperty(BeanPropertyWriter writer, ObjectNode propertiesNode, SerializerProvider provider) Deprecated.voiddepositSchemaProperty(PropertyWriter writer, JsonObjectFormatVisitor objectVisitor, SerializerProvider provider) Method called byBeanSerializerto let the filter determine whether, and in what form the given property exist within the parent, or root, schema.voiddepositSchemaProperty(PropertyWriter writer, ObjectNode propertiesNode, SerializerProvider provider) Deprecated.static SimpleBeanPropertyFilterConvenience factory method that will return a filter that will simply filter out everything.static SimpleBeanPropertyFilterfilterOutAllExcept(String... propertyArray) static SimpleBeanPropertyFilterfilterOutAllExcept(Set<String> properties) Factory method to construct filter that filters out all properties except ones includes in setstatic PropertyFilterfrom(BeanPropertyFilter src) Helper method to ease transition fromBeanPropertyWriterintoPropertyWriterstatic SimpleBeanPropertyFilterConvenience factory method that will return a "no-op" filter that will simply just serialize all properties that are given, and filter out nothing.static SimpleBeanPropertyFilterserializeAll(Set<String> properties) Deprecated.Since 2.6; to be removed from 2.7static SimpleBeanPropertyFilterserializeAllExcept(String... propertyArray) static SimpleBeanPropertyFilterserializeAllExcept(Set<String> properties) voidserializeAsElement(Object elementValue, JsonGenerator jgen, SerializerProvider provider, PropertyWriter writer) Method called by container to let the filter decide what to do with given element value: the usual choices are to either filter out (i.e.voidserializeAsField(Object bean, JsonGenerator jgen, SerializerProvider provider, BeanPropertyWriter writer) Deprecated.voidserializeAsField(Object pojo, JsonGenerator jgen, SerializerProvider provider, PropertyWriter writer) Method called byBeanSerializerto let the filter decide what to do with given bean property value: the usual choices are to either filter out (i.e.
-
Method Details
-
serializeAll
Convenience factory method that will return a "no-op" filter that will simply just serialize all properties that are given, and filter out nothing.- Since:
- 2.6
-
filterOutAll
Convenience factory method that will return a filter that will simply filter out everything.- Since:
- 2.15
-
serializeAll
Deprecated.Since 2.6; to be removed from 2.7Factory method that was accidentally added in 2.5 with arguments; basically works just as an alias offilterOutAllExcept(Set)which is not very useful. Instead, seeserializeAll()for intended signature. -
filterOutAllExcept
Factory method to construct filter that filters out all properties except ones includes in set -
filterOutAllExcept
-
serializeAllExcept
-
serializeAllExcept
-
from
Helper method to ease transition fromBeanPropertyWriterintoPropertyWriter- Since:
- 2.3
-
serializeAsField
@Deprecated public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider provider, BeanPropertyWriter writer) throws Exception Deprecated.Description copied from interface:BeanPropertyFilterMethod called byBeanSerializerto let filter decide what to do with given bean property value: the usual choices are to either filter out (i.e. do nothing) or write using givenBeanPropertyWriter, although filters can choose other to do something different altogether.Typical implementation is something like:
if (include(writer)) { writer.serializeAsField(pojo, jgen, prov); }- Specified by:
serializeAsFieldin interfaceBeanPropertyFilter- Parameters:
bean- Object that contains property value to serializejgen- Generator use for serializing valueprovider- Provider that can be used for accessing dynamic aspects of serialization processingwriter- Default bean property serializer to use- Throws:
Exception
-
depositSchemaProperty
@Deprecated public void depositSchemaProperty(BeanPropertyWriter writer, ObjectNode propertiesNode, SerializerProvider provider) throws JsonMappingException Deprecated.Description copied from interface:BeanPropertyFilterMethod called byBeanSerializerto let the filter determine whether, and in what form the given property exist within the parent, or root, schema. Filters can omit adding the property to the node, or choose the form of the schema value for the property.Typical implementation is something like:
if (include(writer)) { writer.depositSchemaProperty(propertiesNode, provider); }- Specified by:
depositSchemaPropertyin interfaceBeanPropertyFilter- Parameters:
writer- Bean property writer to use to create schema valuepropertiesNode- Node which the given property would exist withinprovider- Provider that can be used for accessing dynamic aspects of serialization processing- Throws:
JsonMappingException
-
depositSchemaProperty
@Deprecated public void depositSchemaProperty(BeanPropertyWriter writer, JsonObjectFormatVisitor objectVisitor, SerializerProvider provider) throws JsonMappingException Deprecated.Description copied from interface:BeanPropertyFilterMethod called byBeanSerializerto let the filter determine whether, and in what form the given property exist within the parent, or root, schema. Filters can omit adding the property to the node, or choose the form of the schema value for the propertyTypical implementation is something like:
if (include(writer)) { writer.depositSchemaProperty(objectVisitor, provider); }- Specified by:
depositSchemaPropertyin interfaceBeanPropertyFilter- Parameters:
writer- Bean property serializer to use to create schema valueobjectVisitor- JsonObjectFormatVisitor which should be aware of the property's existenceprovider- Provider that can be used for accessing dynamic aspects of serialization processing- Throws:
JsonMappingException
-
serializeAsField
public void serializeAsField(Object pojo, JsonGenerator jgen, SerializerProvider provider, PropertyWriter writer) throws Exception Description copied from interface:PropertyFilterMethod called byBeanSerializerto let the filter decide what to do with given bean property value: the usual choices are to either filter out (i.e. do nothing) or write using givenPropertyWriter, although filters can choose other to do something different altogether.Typical implementation is something like:
if (include(writer)) { writer.serializeAsField(pojo, gen, prov); }- Specified by:
serializeAsFieldin interfacePropertyFilter- Parameters:
pojo- Object that contains property value to serializejgen- Generator use for serializing valueprovider- Provider that can be used for accessing dynamic aspects of serialization processingwriter- Object called to do actual serialization of the field, if not filtered out- Throws:
Exception
-
serializeAsElement
public void serializeAsElement(Object elementValue, JsonGenerator jgen, SerializerProvider provider, PropertyWriter writer) throws Exception Description copied from interface:PropertyFilterMethod called by container to let the filter decide what to do with given element value: the usual choices are to either filter out (i.e. do nothing) or write using givenPropertyWriter, although filters can choose other to do something different altogether.Typical implementation is something like:
if (include(writer)) { writer.serializeAsElement(pojo, gen, prov); }- Specified by:
serializeAsElementin interfacePropertyFilter- Parameters:
elementValue- Element value being serializerdjgen- Generator use for serializing valueprovider- Provider that can be used for accessing dynamic aspects of serialization processingwriter- Object called to do actual serialization of the field, if not filtered out- Throws:
Exception
-
depositSchemaProperty
@Deprecated public void depositSchemaProperty(PropertyWriter writer, ObjectNode propertiesNode, SerializerProvider provider) throws JsonMappingException Deprecated.Description copied from interface:PropertyFilterMethod called byBeanSerializerto let the filter determine whether, and in what form the given property exist within the parent, or root, schema. Filters can omit adding the property to the node, or choose the form of the schema value for the property.Typical implementation is something like:
if (include(writer)) { writer.depositSchemaProperty(propertiesNode, provider); }- Specified by:
depositSchemaPropertyin interfacePropertyFilter- Parameters:
writer- Bean property writer to use to create schema valuepropertiesNode- Node which the given property would exist withinprovider- Provider that can be used for accessing dynamic aspects of serialization processing- Throws:
JsonMappingException
-
depositSchemaProperty
public void depositSchemaProperty(PropertyWriter writer, JsonObjectFormatVisitor objectVisitor, SerializerProvider provider) throws JsonMappingException Description copied from interface:PropertyFilterMethod called byBeanSerializerto let the filter determine whether, and in what form the given property exist within the parent, or root, schema. Filters can omit adding the property to the node, or choose the form of the schema value for the propertyTypical implementation is something like:
if (include(writer)) { writer.depositSchemaProperty(objectVisitor, provider); }- Specified by:
depositSchemaPropertyin interfacePropertyFilter- Parameters:
writer- Bean property serializer to use to create schema valueobjectVisitor- JsonObjectFormatVisitor which should be aware of the property's existenceprovider- Provider that can be used for accessing dynamic aspects of serialization processing- Throws:
JsonMappingException
-