class UnmatchedFieldTypeModule extends SimpleModule {

  private boolean logWarnings;
  private boolean restrictToTemplates;

  private static final ThreadLocal<Boolean> IN_TEMPLATE = ThreadLocal.withInitial(() -> false);

  public UnmatchedFieldTypeModule() {
    this(true, true);
  }

  public UnmatchedFieldTypeModule(boolean logWarnings, boolean restrictToTemplates) {
    this.logWarnings = logWarnings;
    this.restrictToTemplates = restrictToTemplates;
    setDeserializerModifier(new BeanDeserializerModifier() {

      @Override
      public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanDescription beanDesc,
          BeanDeserializerBuilder builder) {
        builder.getProperties().forEachRemaining(p -> builder.addOrReplaceProperty(
            new SettableBeanPropertyDelegate(p, builder.getAnySetter(), UnmatchedFieldTypeModule.this::useAnySetter) {
            }, true));
        return builder;
      }
    });
    setSerializerModifier(new BeanSerializerModifier() {
      @Override
      public BeanSerializerBuilder updateBuilder(SerializationConfig config, BeanDescription beanDesc,
          BeanSerializerBuilder builder) {<FILL_FUNCTION_BODY>}
    });
  }

  boolean isLogWarnings() {
    return logWarnings;
  }

  /**
   * Set if warnings should be logged for ambiguous serializer and deserializer situations.
   *
   * @param logWarnings if true, warnings will be logged.
   */
  public void setLogWarnings(boolean logWarnings) {
    this.logWarnings = logWarnings;
  }

  boolean isRestrictToTemplates() {
    return restrictToTemplates;
  }

  boolean useAnySetter() {
    return !restrictToTemplates || isInTemplate();
  }

  /**
   * Sets if the DeserializerModifier should only be applied to Templates or object trees contained in Templates.
   *
   * @param restrictToTemplates if true, the DeserializerModifier will only be applicable for Templates.
   */
  public void setRestrictToTemplates(boolean restrictToTemplates) {
    this.restrictToTemplates = restrictToTemplates;
  }

  public static boolean isInTemplate() {
    return Boolean.TRUE.equals(IN_TEMPLATE.get());
  }

  public static void setInTemplate() {
    IN_TEMPLATE.set(true);
  }

  public static void removeInTemplate() {
    IN_TEMPLATE.remove();
  }

}

        builder.setProperties(builder.getProperties().stream()
            .map(p -> new BeanPropertyWriterDelegate(p, builder.getBeanDescription().findAnyGetter(),
                UnmatchedFieldTypeModule.this::isLogWarnings))
            .collect(Collectors.toList()));
        return builder;
      
<no_super_class>