protected void _reportIncompatibleRootType(Object value, JavaType rootType) throws IOException {
   // One special case: allow primitive/wrapper type coercion
   if (rootType.isPrimitive()) {
     Class<?> wrapperType = ClassUtil.wrapperType(rootType.getRawClass());
     // If it's just difference between wrapper, primitive, let it slide
     if (wrapperType.isAssignableFrom(value.getClass())) {
       return;
     }
   }
   throw JsonMappingException.from(
       this,
       "Incompatible types: declared root type ("
           + rootType
           + ") vs "
           + value.getClass().getName());
 }
  protected JsonSerializer<Object> _createAndCacheUntypedSerializer(JavaType type)
      throws JsonMappingException {
    JsonSerializer<Object> ser;
    try {
      ser = _createUntypedSerializer(type);
    } catch (IllegalArgumentException iae) {
      /* We better only expose checked exceptions, since those
       * are what caller is expected to handle
       */
      throw JsonMappingException.from(this, iae.getMessage(), iae);
    }

    if (ser != null) {
      _serializerCache.addAndResolveNonTypedSerializer(type, ser, this);
    }
    return ser;
  }
 protected void _reportIncompatibleRootType(Object value, JavaType rootType) throws IOException {
   /* 07-Jan-2010, tatu: As per [JACKSON-456] better handle distinction between wrapper types,
    *    primitives
    */
   if (rootType.isPrimitive()) {
     Class<?> wrapperType = ClassUtil.wrapperType(rootType.getRawClass());
     // If it's just difference between wrapper, primitive, let it slide
     if (wrapperType.isAssignableFrom(value.getClass())) {
       return;
     }
   }
   throw JsonMappingException.from(
       this,
       "Incompatible types: declared root type ("
           + rootType
           + ") vs "
           + value.getClass().getName());
 }
  /**
   * Method that will try to construct a value serializer; and if one is successfully created, cache
   * it for reuse.
   */
  protected JsonSerializer<Object> _createAndCacheUntypedSerializer(Class<?> rawType)
      throws JsonMappingException {
    JavaType fullType = _config.constructType(rawType);
    JsonSerializer<Object> ser;
    try {
      ser = _createUntypedSerializer(fullType);
    } catch (IllegalArgumentException iae) {
      /* We better only expose checked exceptions, since those
       * are what caller is expected to handle
       */
      throw JsonMappingException.from(this, iae.getMessage(), iae);
    }

    if (ser != null) {
      // 21-Dec-2015, tatu: Best to cache for both raw and full-type key
      _serializerCache.addAndResolveNonTypedSerializer(rawType, fullType, ser, this);
    }
    return ser;
  }
 /**
  * Factory method for constructing a {@link JsonMappingException}; usually only indirectly used by
  * calling {@link #reportMappingProblem(Throwable, String, Object...)}
  *
  * @since 2.8
  */
 protected JsonMappingException mappingException(Throwable t, String message, Object... args) {
   if (args != null && args.length > 0) {
     message = String.format(message, args);
   }
   return JsonMappingException.from(getGenerator(), message, t);
 }
 /**
  * Factory method for constructing a {@link JsonMappingException}; usually only indirectly used by
  * calling {@link #reportMappingProblem(String, Object...)}.
  *
  * @since 2.6
  */
 public JsonMappingException mappingException(String message, Object... args) {
   if (args != null && args.length > 0) {
     message = String.format(message, args);
   }
   return JsonMappingException.from(getGenerator(), message);
 }