/**
   * Method for constructing a bean deserializer that uses specified intermediate Builder for
   * binding data, and construction of the value instance. Note that implementation is mostly copied
   * from the regular BeanDeserializer build method.
   */
  @SuppressWarnings("unchecked")
  protected JsonDeserializer<Object> buildBuilderBasedDeserializer(
      DeserializationContext ctxt, JavaType valueType, BeanDescription builderDesc)
      throws JsonMappingException {
    // Creators, anyone? (to create builder itself)
    ValueInstantiator valueInstantiator = findValueInstantiator(ctxt, builderDesc);
    final DeserializationConfig config = ctxt.getConfig();
    BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, builderDesc);
    builder.setValueInstantiator(valueInstantiator);
    // And then "with methods" for deserializing from JSON Object
    addBeanProps(ctxt, builderDesc, builder);
    addObjectIdReader(ctxt, builderDesc, builder);

    // managed/back reference fields/setters need special handling... first part
    addReferenceProperties(ctxt, builderDesc, builder);
    addInjectables(ctxt, builderDesc, builder);

    JsonPOJOBuilder.Value builderConfig = builderDesc.findPOJOBuilderConfig();
    final String buildMethodName =
        (builderConfig == null) ? "build" : builderConfig.buildMethodName;

    // and lastly, find build method to use:
    AnnotatedMethod buildMethod = builderDesc.findMethod(buildMethodName, null);
    if (buildMethod != null) { // note: can't yet throw error; may be given build method
      if (config.canOverrideAccessModifiers()) {
        ClassUtil.checkAndFixAccess(buildMethod.getMember());
      }
    }
    builder.setPOJOBuilder(buildMethod, builderConfig);
    // this may give us more information...
    if (_factoryConfig.hasDeserializerModifiers()) {
      for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
        builder = mod.updateBuilder(config, builderDesc, builder);
      }
    }
    JsonDeserializer<?> deserializer = builder.buildBuilderBased(valueType, buildMethodName);

    // [JACKSON-440]: may have modifier(s) that wants to modify or replace serializer we just built:
    if (_factoryConfig.hasDeserializerModifiers()) {
      for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {
        deserializer = mod.modifyDeserializer(config, builderDesc, deserializer);
      }
    }
    return (JsonDeserializer<Object>) deserializer;
  }
 /**
  * Factory method used when Enum instances are to be deserialized using a creator (static factory
  * method)
  *
  * @return Deserializer based on given factory method, if type was suitable; null if type can not
  *     be used
  */
 public static JsonDeserializer<?> deserializerForCreator(
     DeserializationConfig config, Class<?> enumClass, AnnotatedMethod factory) {
   // note: caller has verified there's just one arg; but we must verify its type
   Class<?> paramClass = factory.getRawParameterType(0);
   if (paramClass == String.class) {
     paramClass = null;
   } else if (paramClass == Integer.TYPE || paramClass == Integer.class) {
     paramClass = Integer.class;
   } else if (paramClass == Long.TYPE || paramClass == Long.class) {
     paramClass = Long.class;
   } else {
     throw new IllegalArgumentException(
         "Parameter #0 type for factory method ("
             + factory
             + ") not suitable, must be java.lang.String or int/Integer/long/Long");
   }
   if (config.canOverrideAccessModifiers()) {
     ClassUtil.checkAndFixAccess(factory.getMember());
   }
   return new FactoryBasedDeserializer(enumClass, factory, paramClass);
 }