|
9 | 9 | public class MapperSupport { |
10 | 10 |
|
11 | 11 | public static ObjectMapper objectMapper() { |
12 | | - final ObjectMapper om = Holder.INSTANCE; |
13 | | - configure(om); |
14 | | - return om; |
| 12 | + return Holder.INSTANCE; |
15 | 13 | } |
16 | 14 |
|
17 | | - private static void configure(ObjectMapper objectMapper) { |
18 | | - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); |
19 | | - objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); |
20 | | - objectMapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false); |
21 | | - objectMapper.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); |
22 | | - objectMapper.registerModule(customAttributeModule()); |
23 | | - } |
| 15 | + private static class Holder { |
| 16 | + private static final ObjectMapper INSTANCE = new Holder().configure(new ObjectMapper()); |
24 | 17 |
|
25 | | - private static SimpleModule customAttributeModule() { |
26 | | - final SimpleModule customAttributeModule = new SimpleModule( |
27 | | - "IntercomClientModule", |
28 | | - new Version(1, 0, 0, null, "", "") |
29 | | - ); |
30 | | - customAttributeModule.addDeserializer(CustomAttribute.class, new CustomAttributeDeserializer()); |
31 | | - customAttributeModule.addSerializer(CustomAttribute.class, new CustomAttributeSerializer()); |
32 | | - customAttributeModule.addDeserializer(Subscription.Topic.class, new TopicDeserializer()); |
33 | | - customAttributeModule.addSerializer(Subscription.Topic.class, new TopicSerializer()); |
34 | | - customAttributeModule.addSerializer(Counts.CountItem.class, new CountItemSerializer()); |
35 | | - customAttributeModule.addDeserializer(Counts.CountItem.class, new CountItemDeserializer()); |
36 | | - return customAttributeModule; |
37 | | - } |
| 18 | + private ObjectMapper configure(ObjectMapper om) { |
| 19 | + return om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true) |
| 20 | + .configure(SerializationFeature.INDENT_OUTPUT, true) |
| 21 | + .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false) |
| 22 | + .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false) |
| 23 | + .registerModule(customAttributeModule()); |
| 24 | + } |
38 | 25 |
|
39 | | - private static class Holder { |
40 | | - private static final ObjectMapper INSTANCE = new ObjectMapper(); |
| 26 | + private SimpleModule customAttributeModule() { |
| 27 | + final SimpleModule customAttributeModule = new SimpleModule( |
| 28 | + "IntercomClientModule", |
| 29 | + new Version(1, 0, 0, null, "", "") |
| 30 | + ); |
| 31 | + customAttributeModule.addDeserializer(CustomAttribute.class, new CustomAttributeDeserializer()); |
| 32 | + customAttributeModule.addSerializer(CustomAttribute.class, new CustomAttributeSerializer()); |
| 33 | + customAttributeModule.addDeserializer(Subscription.Topic.class, new TopicDeserializer()); |
| 34 | + customAttributeModule.addSerializer(Subscription.Topic.class, new TopicSerializer()); |
| 35 | + customAttributeModule.addSerializer(Counts.CountItem.class, new CountItemSerializer()); |
| 36 | + customAttributeModule.addDeserializer(Counts.CountItem.class, new CountItemDeserializer()); |
| 37 | + return customAttributeModule; |
| 38 | + } |
41 | 39 | } |
42 | 40 | } |
0 commit comments