Class BasicSerializerFactory
- java.lang.Object
-
- com.fasterxml.jackson.databind.ser.SerializerFactory
-
- com.fasterxml.jackson.databind.ser.BasicSerializerFactory
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
BeanSerializerFactory
public abstract class BasicSerializerFactory extends SerializerFactory implements java.io.Serializable
Factory class that can provide serializers for standard JDK classes, as well as custom classes that extend standard classes or implement one of "well-known" interfaces (such asCollection
).Since all the serializers are eagerly instantiated, and there is no additional introspection or customizability of these types, this factory is essentially stateless.
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ContainerSerializer<?>
buildCollectionSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, JsonSerializer<java.lang.Object> valueSerializer)
JsonSerializer<?>
buildEnumSetSerializer(JavaType enumType)
ContainerSerializer<?>
buildIndexedListSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, JsonSerializer<java.lang.Object> valueSerializer)
JsonSerializer<java.lang.Object>
createKeySerializer(SerializationConfig config, JavaType keyType, JsonSerializer<java.lang.Object> defaultImpl)
Deprecated.JsonSerializer<java.lang.Object>
createKeySerializer(SerializerProvider ctxt, JavaType keyType, JsonSerializer<java.lang.Object> defaultImpl)
Method called to create serializer to use for serializing JSON property names (which must be output asJsonToken.FIELD_NAME
) for Map that has specified declared key type, and is for specified property (or, if property is null, as root value)abstract JsonSerializer<java.lang.Object>
createSerializer(SerializerProvider prov, JavaType type)
Method called to create (or, for immutable serializers, reuse) a serializer for given type.TypeSerializer
createTypeSerializer(SerializationConfig config, JavaType baseType)
Method called to construct a type serializer for values with given declared base type.JsonSerializer<?>
findReferenceSerializer(SerializerProvider prov, ReferenceType refType, BeanDescription beanDesc, boolean staticTyping)
SerializerFactoryConfig
getFactoryConfig()
Method for getting currentSerializerFactoryConfig
.SerializerFactory
withAdditionalKeySerializers(Serializers additional)
Convenience method for creating a new factory instance with an additional key serializer provider.SerializerFactory
withAdditionalSerializers(Serializers additional)
Convenience method for creating a new factory instance with an additional serializer provider.abstract SerializerFactory
withConfig(SerializerFactoryConfig config)
Method used for creating a new instance of this factory, but with different configuration.SerializerFactory
withSerializerModifier(BeanSerializerModifier modifier)
Convenience method for creating a new factory instance with additional bean serializer modifier.
-
-
-
Method Detail
-
getFactoryConfig
public SerializerFactoryConfig getFactoryConfig()
Method for getting currentSerializerFactoryConfig
.Note that since instances are immutable, you can NOT change settings by accessing an instance and calling methods: this will simply create new instance of config object.
-
withConfig
public abstract SerializerFactory withConfig(SerializerFactoryConfig config)
Method used for creating a new instance of this factory, but with different configuration. Reason for specifying factory method (instead of plain constructor) is to allow proper sub-classing of factories.Note that custom sub-classes generally must override implementation of this method, as it usually requires instantiating a new instance of factory type. Check out javadocs for
BeanSerializerFactory
for more details.
-
withAdditionalSerializers
public final SerializerFactory withAdditionalSerializers(Serializers additional)
Convenience method for creating a new factory instance with an additional serializer provider.- Specified by:
withAdditionalSerializers
in classSerializerFactory
-
withAdditionalKeySerializers
public final SerializerFactory withAdditionalKeySerializers(Serializers additional)
Convenience method for creating a new factory instance with an additional key serializer provider.- Specified by:
withAdditionalKeySerializers
in classSerializerFactory
-
withSerializerModifier
public final SerializerFactory withSerializerModifier(BeanSerializerModifier modifier)
Convenience method for creating a new factory instance with additional bean serializer modifier.- Specified by:
withSerializerModifier
in classSerializerFactory
-
createSerializer
public abstract JsonSerializer<java.lang.Object> createSerializer(SerializerProvider prov, JavaType type) throws JsonMappingException
Description copied from class:SerializerFactory
Method called to create (or, for immutable serializers, reuse) a serializer for given type.- Specified by:
createSerializer
in classSerializerFactory
- Parameters:
prov
- Provider that needs to be used to resolve annotation-provided serializers (but NOT for others)- Throws:
JsonMappingException
-
createKeySerializer
public JsonSerializer<java.lang.Object> createKeySerializer(SerializerProvider ctxt, JavaType keyType, JsonSerializer<java.lang.Object> defaultImpl) throws JsonMappingException
Description copied from class:SerializerFactory
Method called to create serializer to use for serializing JSON property names (which must be output asJsonToken.FIELD_NAME
) for Map that has specified declared key type, and is for specified property (or, if property is null, as root value)- Overrides:
createKeySerializer
in classSerializerFactory
keyType
- Declared type for Map keysdefaultImpl
- Default key serializer implementation to use, if no custom ones are found (may be null)- Returns:
- Serializer to use, if factory knows it; null if not (in which case default serializer is to be used)
- Throws:
JsonMappingException
-
createKeySerializer
@Deprecated public JsonSerializer<java.lang.Object> createKeySerializer(SerializationConfig config, JavaType keyType, JsonSerializer<java.lang.Object> defaultImpl)
Deprecated.- Specified by:
createKeySerializer
in classSerializerFactory
-
createTypeSerializer
public TypeSerializer createTypeSerializer(SerializationConfig config, JavaType baseType)
Method called to construct a type serializer for values with given declared base type. This is called for values other than those of bean property types.- Specified by:
createTypeSerializer
in classSerializerFactory
baseType
- Declared type to use as the base type for type information serializer- Returns:
- Type serializer to use for the base type, if one is needed; null if not.
-
buildIndexedListSerializer
public ContainerSerializer<?> buildIndexedListSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, JsonSerializer<java.lang.Object> valueSerializer)
-
buildCollectionSerializer
public ContainerSerializer<?> buildCollectionSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, JsonSerializer<java.lang.Object> valueSerializer)
-
buildEnumSetSerializer
public JsonSerializer<?> buildEnumSetSerializer(JavaType enumType)
-
findReferenceSerializer
public JsonSerializer<?> findReferenceSerializer(SerializerProvider prov, ReferenceType refType, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException
- Throws:
JsonMappingException
- Since:
- 2.7
-
-