Class SerializerFactory

    • Constructor Detail

      • SerializerFactory

        public SerializerFactory()
    • Method Detail

      • withConfig

        public abstract SerializerFactory withConfig​(SerializerFactory.Config 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.

        Since:
        1.7
      • withAdditionalSerializers

        public final SerializerFactory withAdditionalSerializers​(Serializers additional)
        Convenience method for creating a new factory instance with additional serializer provider; equivalent to calling
           withConfig(getConfig().withAdditionalSerializers(additional));
        
        Since:
        1.7
      • withSerializerModifier

        public final SerializerFactory withSerializerModifier​(BeanSerializerModifier modifier)
        Convenience method for creating a new factory instance with additional bean serializer modifier; equivalent to calling
           withConfig(getConfig().withSerializerModifier(modifier));
        
        Since:
        1.7
      • createTypeSerializer

        public abstract TypeSerializer createTypeSerializer​(SerializationConfig config,
                                                            JavaType baseType,
                                                            BeanProperty property)
                                                     throws JsonMappingException
        Method called to create a type information serializer for given base type, if one is needed. If not needed (no polymorphic handling configured), should return null.
        Parameters:
        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.
        Throws:
        JsonMappingException
        Since:
        1.7
      • createKeySerializer

        public abstract JsonSerializer<java.lang.Object> createKeySerializer​(SerializationConfig config,
                                                                             JavaType baseType,
                                                                             BeanProperty property)
                                                                      throws JsonMappingException
        Method called to create serializer to use for serializing JSON property names (which must be output as JsonToken.FIELD_NAME) for Map that has specified declared key type, and is for specified property (or, if property is null, as root value)
        Parameters:
        config - Serialization configuration in use
        baseType - Declared type for Map keys
        property - Property that contains Map being serialized; null when serializing root Map value.
        Returns:
        Serializer to use, if factory knows it; null if not (in which case default serializer is to be used)
        Throws:
        JsonMappingException
        Since:
        1.8
      • createSerializer

        @Deprecated
        public final JsonSerializer<java.lang.Object> createSerializer​(JavaType type,
                                                                       SerializationConfig config)
        Deprecated.
        Since 1.7, call variant with more arguments
        Deprecated version of accessor for type id serializer: as of 1.7 one needs to instead call version that passes property information through.
        Since:
        1.5
      • createTypeSerializer

        @Deprecated
        public final TypeSerializer createTypeSerializer​(JavaType baseType,
                                                         SerializationConfig config)
        Deprecated.
        Since 1.7, call variant with more arguments
        Deprecated version of accessor for type id serializer: as of 1.7 one needs to instead call version that passes property information through.
        Since:
        1.5