publicvoidconfigure(ObjectMapper objectMapper) { Assert.notNull(objectMapper, "ObjectMapper must not be null");
if (this.findModulesViaServiceLoader) { // Jackson 2.2+ objectMapper.registerModules(ObjectMapper.findModules(this.moduleClassLoader)); } elseif (this.findWellKnownModules) { registerWellKnownModulesIfAvailable(objectMapper); }
if (this.modules != null) { for (Module module : this.modules) { // Using Jackson 2.0+ registerModule method, not Jackson 2.2+ registerModules objectMapper.registerModule(module); } } if (this.moduleClasses != null) { for (Class<? extendsModule> module : this.moduleClasses) { objectMapper.registerModule(BeanUtils.instantiate(module)); } }
if (this.dateFormat != null) { objectMapper.setDateFormat(this.dateFormat); } if (this.locale != null) { objectMapper.setLocale(this.locale); } if (this.timeZone != null) { objectMapper.setTimeZone(this.timeZone); }
if (this.annotationIntrospector != null) { objectMapper.setAnnotationIntrospector(this.annotationIntrospector); } if (this.propertyNamingStrategy != null) { objectMapper.setPropertyNamingStrategy(this.propertyNamingStrategy); } if (this.defaultTyping != null) { objectMapper.setDefaultTyping(this.defaultTyping); } if (this.serializationInclusion != null) { objectMapper.setSerializationInclusion(this.serializationInclusion); }
if (this.filters != null) { objectMapper.setFilterProvider(this.filters); }
for (Class<?> target : this.mixIns.keySet()) { objectMapper.addMixIn(target, this.mixIns.get(target)); }
if (!this.serializers.isEmpty() || !this.deserializers.isEmpty()) { SimpleModulemodule=newSimpleModule(); addSerializers(module); addDeserializers(module); objectMapper.registerModule(module); }