View Javadoc
1   package top.infra.jackson2;
2   
3   import static java.lang.Boolean.FALSE;
4   
5   import com.fasterxml.jackson.annotation.JsonInclude;
6   import com.fasterxml.jackson.core.JsonGenerator;
7   import com.fasterxml.jackson.core.JsonParser;
8   import com.fasterxml.jackson.databind.DeserializationFeature;
9   import com.fasterxml.jackson.databind.MapperFeature;
10  import com.fasterxml.jackson.databind.SerializationFeature;
11  
12  import lombok.Data;
13  import lombok.Getter;
14  import lombok.Setter;
15  
16  import org.springframework.boot.context.properties.ConfigurationProperties;
17  import org.springframework.boot.context.properties.NestedConfigurationProperty;
18  
19  import java.util.HashMap;
20  import java.util.Locale;
21  import java.util.Map;
22  import java.util.TimeZone;
23  
24  /**
25   * see {@link org.springframework.boot.autoconfigure.jackson.JacksonProperties}
26   */
27  @ConfigurationProperties(prefix = "spring.jackson")
28  @Getter
29  @Setter
30  public class Jackson2Properties {
31  
32      /**
33       * Date format string (yyyy-MM-dd HH:mm:ss), or a fully-qualified date format class
34       * name.
35       */
36      private String dateFormat;
37  
38      /**
39       * Joda date time format string (yyyy-MM-dd HH:mm:ss). If not configured,
40       * "date-format" will be used as a fallback if it is configured with a format string.
41       */
42      private String jodaDateTimeFormat;
43  
44      /**
45       * One of the constants on Jackson's PropertyNamingStrategy
46       * (CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES). Can also be a fully-qualified class
47       * name of a PropertyNamingStrategy subclass.
48       */
49      private String propertyNamingStrategy;
50  
51      /**
52       * Jackson on/off features that affect the way Java objects are serialized.
53       */
54      private Map<SerializationFeature, Boolean> serialization = new HashMap<SerializationFeature, Boolean>();
55  
56      /**
57       * Jackson on/off features that affect the way Java objects are deserialized.
58       */
59      private Map<DeserializationFeature, Boolean> deserialization = new HashMap<DeserializationFeature, Boolean>();
60  
61      /**
62       * Jackson general purpose on/off features.
63       */
64      private Map<MapperFeature, Boolean> mapper = new HashMap<MapperFeature, Boolean>();
65  
66      /**
67       * Jackson on/off features for parsers.
68       */
69      private Map<JsonParser.Feature, Boolean> parser = new HashMap<JsonParser.Feature, Boolean>();
70  
71      /**
72       * Jackson on/off features for generators.
73       */
74      private Map<JsonGenerator.Feature, Boolean> generator = new HashMap<JsonGenerator.Feature, Boolean>();
75  
76      /**
77       * Controls the inclusion of properties during serialization. Configured with one of
78       * the values in Jackson's JsonInclude.Include enumeration.
79       */
80      private JsonInclude.Include defaultPropertyInclusion;
81  
82      /**
83       * Time zone used when formatting dates. Configured using any recognized time zone
84       * identifier, for example "America/Los_Angeles" or "GMT+10".
85       */
86      private TimeZone timeZone = null;
87  
88      /**
89       * Locale used for formatting.
90       */
91      private Locale locale;
92      @NestedConfigurationProperty
93      private Jaxb jaxb = new Jaxb();
94  
95      @Data
96      public static class Jaxb {
97  
98          private Boolean enabled = FALSE;
99      }
100 }