Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.jsontype.impl;
  
  import java.util.HashMap;
  
  
Base class for all standard Jackson com.fasterxml.jackson.databind.jsontype.TypeDeserializers.
 
 public abstract class TypeDeserializerBase
     extends TypeDeserializer
     implements java.io.Serializable
 {
     private static final long serialVersionUID = 278445030337366675L;
 
     protected final TypeIdResolver _idResolver;
     
     protected final JavaType _baseType;

    
Property that contains value for which type information is included; null if value is a root value. Note that this value is not assigned during construction but only when forProperty(com.fasterxml.jackson.databind.BeanProperty) is called to create a copy.
 
     protected final BeanProperty _property;

    
Type to use as the default implementation, if type id is missing or can not be resolved.
 
     protected final JavaType _defaultImpl;

    
Name of type property used; needed for non-property versions too, in cases where type id is to be exposed as part of JSON.
 
     protected final String _typePropertyName;
     
     protected final boolean _typeIdVisible;
    
    
For efficient operation we will lazily build mappings from type ids to actual deserializers, once needed.
 
     protected final HashMap<String,JsonDeserializer<Object>> _deserializers;
 
 
     /*
     /**********************************************************
     /* Life-cycle
     /**********************************************************
      */
     
     protected TypeDeserializerBase(JavaType baseTypeTypeIdResolver idRes,
             String typePropertyNameboolean typeIdVisibleClass<?> defaultImpl)
     {
          = baseType;
          = idRes;
          = typePropertyName;
          = typeIdVisible;
          = new HashMap<String,JsonDeserializer<Object>>();
         if (defaultImpl == null) {
              = null;
         } else {
             /* 16-Oct-2011, tatu: should call this via TypeFactory; this is
              *    not entirely safe... however, since Collections/Maps are
              *    seldom (if ever) base types, may be ok.
              */
              = baseType.forcedNarrowBy(defaultImpl);
         }
 
          = null;
     }
 
     protected TypeDeserializerBase(TypeDeserializerBase srcBeanProperty property)
     {
          = src._baseType;
          = src._idResolver;
          = src._typePropertyName;
          = src._typeIdVisible;
          = src._deserializers;
          = src._defaultImpl;
          = src._defaultImplDeserializer;
 
          = property;
     }
 
    @Override
    public abstract TypeDeserializer forProperty(BeanProperty prop);
    
    /*
    /**********************************************************
    /* Accessors
    /**********************************************************
     */
    
    @Override
    public abstract JsonTypeInfo.As getTypeInclusion();
    public String baseTypeName() { return .getRawClass().getName(); }
    @Override
    public final String getPropertyName() { return ; }
    
    @Override    
    public TypeIdResolver getTypeIdResolver() { return ; }
    @Override    
    public Class<?> getDefaultImpl() {
        return ( == null) ? null : .getRawClass();
    }
    
    @Override
    public String toString()
    {
    	StringBuilder sb = new StringBuilder();
    	sb.append('[').append(getClass().getName());
    	sb.append("; base-type:").append();
    	sb.append("; id-resolver: ").append();
    	sb.append(']');
    	return sb.toString();
    }
    
    /*
    /**********************************************************
    /* Helper methods for sub-classes
    /**********************************************************
     */
            String typeId)
        throws IOExceptionJsonProcessingException
    {
        JsonDeserializer<Objectdeser;
        synchronized () {
            deser = .get(typeId);
            if (deser == null) {
                JavaType type = .typeFromId(typeId);
                if (type == null) {
                    // As per [JACKSON-614], use the default impl if no type id available:
                    if ( == null) {
                        throw ctxt.unknownTypeException(typeId);
                    }
                    deser = _findDefaultImplDeserializer(ctxt);
                } else {
                    /* 16-Dec-2010, tatu: Since nominal type we get here has no (generic) type parameters,
                     *   we actually now need to explicitly narrow from base type (which may have parameterization)
                     *   using raw type.
                     *   
                     *   One complication, though; can not change 'type class' (simple type to container); otherwise
                     *   we may try to narrow a SimpleType (Object.class) into MapType (Map.class), losing actual
                     *   type in process (getting SimpleType of Map.class which will not work as expected)
                     */
                    if ( != null && .getClass() == type.getClass()) {
                        type = .narrowBy(type.getRawClass());
                    }
                    deser = ctxt.findContextualValueDeserializer(type);
                }
                .put(typeIddeser);
            }
        }
        return deser;
    }
        throws IOExceptionJsonProcessingException
    {
        if ( == null) {
            return null;
        }
        synchronized () {
            if ( == null) {
                 = ctxt.findContextualValueDeserializer(
                        );
            }
            return ;
        }
    }
New to GrepCode? Check out our FAQ X