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

com.fitbur.fasterxml.jackson.databind.deser.DeserializerFactory Maven / Gradle / Ivy

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

import com.fitbur.fasterxml.jackson.databind.*;
import com.fitbur.fasterxml.jackson.databind.jsontype.TypeDeserializer;
import com.fitbur.fasterxml.jackson.databind.type.*;

/**
 * Abstract class that com.fitburfines API used by {@link DeserializationContext}
 * to construct actual
 * {@link JsonDeserializer} instances (which are then cached by
 * context and/or com.fitburdicated cache).
 *

* Since there are multiple broad categories of com.fitburserializers, there are * multiple factory methods: *

    *
  • For JSON "Array" type, we need 2 methods: one to com.fitbural with expected * Java arrays ({@link #createArrayDeserializer}) * and the other for other Java containers like {@link java.util.List}s * and {@link java.util.Set}s ({@link #createCollectionDeserializer}). * Actually there is also a third method for "Collection-like" types; * things like Scala collections that act like JDK collections but do not * implement same interfaces. *
  • *
  • For JSON "Object" type, we need 2 methods: one to com.fitbural with * expected Java {@link java.util.Map}s * ({@link #createMapDeserializer}), and another for POJOs * ({@link #createBeanDeserializer}. * As an additional twist there is also a callback for "Map-like" types, * mostly to make it possible to support Scala Maps (which are NOT JDK * Map com.fitburpatible). *
  • *
  • For Tree Model ({@link com.fitbur.fasterxml.jackson.databind.JsonNode}) properties there is * {@link #createTreeDeserializer} *
  • For enumerated types ({@link java.lang.Enum}) there is * {@link #createEnumDeserializer} *
  • *
  • For all other types, {@link #createBeanDeserializer} is used. *
*

*/ public abstract class DeserializerFactory { protected final static Deserializers[] NO_DESERIALIZERS = new Deserializers[0]; /* /******************************************************** /* Configuration handling /******************************************************** */ /** * Convenience method for creating a new factory instance with additional com.fitburserializer * provider. */ public abstract DeserializerFactory withAdditionalDeserializers(Deserializers additional); /** * Convenience method for creating a new factory instance with additional * {@link KeyDeserializers}. */ public abstract DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional); /** * Convenience method for creating a new factory instance with additional * {@link BeanDeserializerModifier}. */ public abstract DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier); /** * Convenience method for creating a new factory instance with additional * {@link AbstractTypeResolver}. */ public abstract DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver); /** * Convenience method for creating a new factory instance with additional * {@link ValueInstantiators}. */ public abstract DeserializerFactory withValueInstantiators(ValueInstantiators instantiators); /* /********************************************************** /* Basic DeserializerFactory API: /********************************************************** */ /** * Method that can be called to try to resolve an abstract type * (interface, abstract class) into a concrete type, or at least * something "more concrete" (abstract class instead of interface). * Will either return passed type, or a more specific type. */ public abstract JavaType mapAbstractType(DeserializationConfig config, JavaType type) throws JsonMappingException; /** * Method that is to find all creators (constructors, factory methods) * for the bean type to com.fitburserialize. */ public abstract ValueInstantiator findValueInstantiator(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to create (or, for com.fitburpletely immutable com.fitburserializers, * reuse) a com.fitburserializer that can convert JSON content into values of * specified Java "bean" (POJO) type. * At this point it is known that the type is not otherwise recognized * as one of structured types (array, Collection, Map) or a well-known * JDK type (enum, primitives/wrappers, String); this method only * gets called if other options are exhausted. This also means that * this method can be overridden to add support for custom types. * * @param type Type to be com.fitburserialized */ public abstract JsonDeserializer createBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to create a com.fitburserializer that will use specified Builder * class for building value instances. * * @since 2.0 */ public abstract JsonDeserializer createBuilderBasedDeserializer( DeserializationContext ctxt, JavaType type, BeanDescription beanDesc, Class builderClass) throws JsonMappingException; /** * Method called to create (or, for com.fitburpletely immutable com.fitburserializers, * reuse) a com.fitburserializer that can convert JSON content into values of * specified Java type. * * @param type Type to be com.fitburserialized */ public abstract JsonDeserializer createArrayDeserializer(DeserializationContext ctxt, ArrayType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to create and return a com.fitburserializer that can construct * JsonNode(s) from JSON content. */ public abstract JsonDeserializer createTreeDeserializer(DeserializationConfig config, JavaType type, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to find if factory knows how to create a key com.fitburserializer * for specified type; currently this means checking if a module has registered * possible com.fitburserializers. * * @return Key com.fitburserializer to use for specified type, if one found; null if not * (and com.fitburfault key com.fitburserializer should be used) */ public abstract KeyDeserializer createKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException; /** * Method called to find and create a type information com.fitburserializer for given base type, * if one is needed. If not needed (no polymorphic handling configured for type), * should return null. *

* Note that this method is usually only directly called for values of container (Collection, * array, Map) types and root values, but not for bean property values. * * @param baseType Declared base type of the value to com.fitburserializer (actual * com.fitburserializer type will be this type or its subtype) * * @return Type com.fitburserializer to use for given base type, if one is needed; null if not. */ public abstract TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType) throws JsonMappingException; }