diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java index 71eafe553b..d2f2dfd9b1 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java @@ -529,7 +529,7 @@ public class Jackson2ObjectMapperBuilder { /** * Specify one or more modules to be registered with the {@link ObjectMapper}. - * Multiple invocations are not additive, the last one defines the modules to + *
Multiple invocations are not additive, the last one defines the modules to * register. *
Note: If this is set, no finding of modules is going to happen - not by * Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}). @@ -546,7 +546,7 @@ public class Jackson2ObjectMapperBuilder { /** * Set a complete list of modules to be registered with the {@link ObjectMapper}. - * Multiple invocations are not additive, the last one defines the modules to + *
Multiple invocations are not additive, the last one defines the modules to * register. *
Note: If this is set, no finding of modules is going to happen - not by * Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}). @@ -565,14 +565,15 @@ public class Jackson2ObjectMapperBuilder { /** * Specify one or more modules to be registered with the {@link ObjectMapper}. - * Multiple invocations are not additive, the last one defines the modules + *
Multiple invocations are not additive, the last one defines the modules * to register. *
Modules specified here will be registered after * Spring's autodetection of JSR-310 and Joda-Time, or Jackson's * finding of modules (see {@link #findModulesViaServiceLoader}), * allowing to eventually override their configuration. - *
Specify either this or {@link #modules}, not both. + *
Specify either this or {@link #modules(Module...)}, not both. * @since 4.1.5 + * @see #modulesToInstall(Class...) * @see com.fasterxml.jackson.databind.Module */ public Jackson2ObjectMapperBuilder modulesToInstall(Module... modules) { @@ -583,13 +584,14 @@ public class Jackson2ObjectMapperBuilder { /** * Specify one or more modules by class to be registered with - * the {@link ObjectMapper}. Multiple invocations are not additive, - * the last one defines the modules to register. + * the {@link ObjectMapper}. + *
Multiple invocations are not additive, the last one defines the modules + * to register. *
Modules specified here will be registered after * Spring's autodetection of JSR-310 and Joda-Time, or Jackson's * finding of modules (see {@link #findModulesViaServiceLoader}), * allowing to eventually override their configuration. - *
Specify either this or {@link #modules}, not both. + *
Specify either this or {@link #modules(Module...)}, not both.
* @see #modulesToInstall(Module...)
* @see com.fasterxml.jackson.databind.Module
*/
diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java
index 9399d8e78b..d52db8bd7e 100644
--- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java
+++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java
@@ -97,7 +97,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author EddĂș MelĂ©ndez
*/
@SuppressWarnings("deprecation")
-public class Jackson2ObjectMapperBuilderTests {
+class Jackson2ObjectMapperBuilderTests {
private static final String DATE_FORMAT = "yyyy-MM-dd";
@@ -105,13 +105,13 @@ public class Jackson2ObjectMapperBuilderTests {
@Test
- public void unknownFeature() {
+ void unknownFeature() {
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() ->
Jackson2ObjectMapperBuilder.json().featuresToEnable(Boolean.TRUE).build());
}
@Test
- public void defaultProperties() {
+ void defaultProperties() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
assertThat(objectMapper).isNotNull();
assertThat(objectMapper.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)).isFalse();
@@ -125,7 +125,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void propertiesShortcut() {
+ void propertiesShortcut() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().autoDetectFields(false)
.defaultViewInclusion(true).failOnUnknownProperties(true).failOnEmptyBeans(false)
.autoDetectGettersSetters(false).indentOutput(true).build();
@@ -141,7 +141,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void booleanSetters() {
+ void booleanSetters() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.featuresToEnable(MapperFeature.DEFAULT_VIEW_INCLUSION,
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
@@ -161,7 +161,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void setNotNullSerializationInclusion() {
+ void setNotNullSerializationInclusion() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
assertThat(objectMapper.getSerializationConfig().getSerializationInclusion()).isSameAs(JsonInclude.Include.ALWAYS);
objectMapper = Jackson2ObjectMapperBuilder.json().serializationInclusion(JsonInclude.Include.NON_NULL).build();
@@ -169,7 +169,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void setNotDefaultSerializationInclusion() {
+ void setNotDefaultSerializationInclusion() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
assertThat(objectMapper.getSerializationConfig().getSerializationInclusion()).isSameAs(JsonInclude.Include.ALWAYS);
objectMapper = Jackson2ObjectMapperBuilder.json().serializationInclusion(JsonInclude.Include.NON_DEFAULT).build();
@@ -177,7 +177,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void setNotEmptySerializationInclusion() {
+ void setNotEmptySerializationInclusion() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
assertThat(objectMapper.getSerializationConfig().getSerializationInclusion()).isSameAs(JsonInclude.Include.ALWAYS);
objectMapper = Jackson2ObjectMapperBuilder.json().serializationInclusion(JsonInclude.Include.NON_EMPTY).build();
@@ -185,7 +185,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void dateTimeFormatSetter() {
+ void dateTimeFormatSetter() {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().dateFormat(dateFormat).build();
assertThat(objectMapper.getSerializationConfig().getDateFormat()).isEqualTo(dateFormat);
@@ -193,7 +193,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void simpleDateFormatStringSetter() {
+ void simpleDateFormatStringSetter() {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().simpleDateFormat(DATE_FORMAT).build();
assertThat(objectMapper.getSerializationConfig().getDateFormat()).isEqualTo(dateFormat);
@@ -201,14 +201,14 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void localeSetter() {
+ void localeSetter() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().locale(Locale.FRENCH).build();
assertThat(objectMapper.getSerializationConfig().getLocale()).isEqualTo(Locale.FRENCH);
assertThat(objectMapper.getDeserializationConfig().getLocale()).isEqualTo(Locale.FRENCH);
}
@Test
- public void timeZoneSetter() {
+ void timeZoneSetter() {
TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().timeZone(timeZone).build();
assertThat(objectMapper.getSerializationConfig().getTimeZone()).isEqualTo(timeZone);
@@ -216,7 +216,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void timeZoneStringSetter() {
+ void timeZoneStringSetter() {
String zoneId = "Europe/Paris";
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().timeZone(zoneId).build();
TimeZone timeZone = TimeZone.getTimeZone(zoneId);
@@ -225,14 +225,14 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void wrongTimeZoneStringSetter() {
+ void wrongTimeZoneStringSetter() {
String zoneId = "foo";
assertThatIllegalArgumentException().isThrownBy(() ->
Jackson2ObjectMapperBuilder.json().timeZone(zoneId).build());
}
@Test
- public void modules() {
+ void modules() {
NumberSerializer serializer1 = new NumberSerializer(Integer.class);
SimpleModule module = new SimpleModule();
module.addSerializer(Integer.class, serializer1);
@@ -243,7 +243,7 @@ public class Jackson2ObjectMapperBuilderTests {
@Test
@SuppressWarnings("unchecked")
- public void modulesToInstallByClass() {
+ void modulesToInstallByClass() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.modulesToInstall(CustomIntegerModule.class)
.build();
@@ -252,7 +252,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void modulesToInstallByInstance() {
+ void modulesToInstallByInstance() {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.modulesToInstall(new CustomIntegerModule())
.build();
@@ -261,7 +261,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void wellKnownModules() throws JsonProcessingException, UnsupportedEncodingException {
+ void wellKnownModules() throws JsonProcessingException, UnsupportedEncodingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
Long timestamp = 1322903730000L;
@@ -280,7 +280,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test // SPR-12634
- public void customizeWellKnownModulesWithModule()
+ void customizeWellKnownModulesWithModule()
throws JsonProcessingException, UnsupportedEncodingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
@@ -293,7 +293,7 @@ public class Jackson2ObjectMapperBuilderTests {
@Test // SPR-12634
@SuppressWarnings("unchecked")
- public void customizeWellKnownModulesWithModuleClass()
+ void customizeWellKnownModulesWithModuleClass()
throws JsonProcessingException, UnsupportedEncodingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
@@ -305,7 +305,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test // SPR-12634
- public void customizeWellKnownModulesWithSerializer()
+ void customizeWellKnownModulesWithSerializer()
throws JsonProcessingException, UnsupportedEncodingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
@@ -316,7 +316,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test // gh-22576
- public void overrideWellKnownModuleWithModule() throws IOException {
+ void overrideWellKnownModuleWithModule() throws IOException {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addDeserializer(OffsetDateTime.class, new OffsetDateTimeDeserializer());
@@ -328,7 +328,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test // gh-22740
- public void registerMultipleModulesWithNullTypeId() {
+ void registerMultipleModulesWithNullTypeId() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
SimpleModule fooModule = new SimpleModule();
fooModule.addSerializer(new FooSerializer());
@@ -355,7 +355,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void propertyNamingStrategy() {
+ void propertyNamingStrategy() {
PropertyNamingStrategy strategy = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy();
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().propertyNamingStrategy(strategy).build();
assertThat(objectMapper.getSerializationConfig().getPropertyNamingStrategy()).isSameAs(strategy);
@@ -363,7 +363,7 @@ public class Jackson2ObjectMapperBuilderTests {
}
@Test
- public void serializerByType() {
+ void serializerByType() {
JsonSerializer