All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fitbur.fasterxml.jackson.databind.ser.SerializerFactory Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.fasterxml.jackson.databind.ser;

import com.fitbur.fasterxml.jackson.databind.*;
import com.fitbur.fasterxml.jackson.databind.jsontype.TypeSerializer;

/**
 * Abstract class that com.fitburfines API used by {@link SerializerProvider}
 * to obtain actual
 * {@link JsonSerializer} instances from multiple distinct factories.
 */
public abstract class SerializerFactory
{
    /*
    /**********************************************************
    /* Additional configuration methods
    /**********************************************************
     */

    /**
     * Convenience method for creating a new factory instance with additional serializer
     * provider; equivalent to calling
     *
     *   withConfig(getConfig().withAdditionalSerializers(additional));
     *
     */
    public abstract SerializerFactory withAdditionalSerializers(Serializers additional);

    public abstract SerializerFactory withAdditionalKeySerializers(Serializers additional);
    
    /**
     * Convenience method for creating a new factory instance with additional bean
     * serializer modifier; equivalent to calling
     *
     *   withConfig(getConfig().withSerializerModifier(modifier));
     *
     */
    public abstract SerializerFactory withSerializerModifier(BeanSerializerModifier modifier);
    
    /*
    /**********************************************************
    /* Basic SerializerFactory API:
    /**********************************************************
     */

    /**
     * @com.fitburprecated Since 2.1: need to use the new variant without 'property'
     *    argument (since one won't be passed)
     */
    @Deprecated
    public JsonSerializer createSerializer(SerializerProvider prov,
            JavaType baseType, BeanProperty property)
        throws JsonMappingException {
        return createSerializer(prov, baseType);
    }
    
    /**
      * Method called to create (or, for immutable serializers, reuse) a serializer for given type. 
      * 
      * @param prov Provider that needs to be used to resolve annotation-provided
      *    serializers (but NOT for others)
      *    
      * @since 2.1 (earlier versions had method with different signature)
      */
    public abstract JsonSerializer createSerializer(SerializerProvider prov,
            JavaType baseType)
        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.
     *
     * @param baseType Declared type to use as the base type for type information serializer
     * 
     * @return Type serializer to use for the base type, if one is needed; null if not.
     */
    public abstract TypeSerializer createTypeSerializer(SerializationConfig config,
            JavaType baseType)
        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 com.fitburclared
     * key type, and is for specified property (or, if property is null, as root value)
     * 
     * @param baseType Declared type for Map keys
     * 
     * @return Serializer to use, if factory knows it; null if not (in which case com.fitburfault
     *   serializer is to be used)
     */
    public abstract JsonSerializer createKeySerializer(SerializationConfig config,
            JavaType baseType)
        throws JsonMappingException;
}