• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.cfg;
2 
3 import com.fasterxml.jackson.annotation.JsonAutoDetect;
4 import com.fasterxml.jackson.annotation.JsonFormat;
5 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6 import com.fasterxml.jackson.annotation.JsonInclude;
7 import com.fasterxml.jackson.annotation.JsonSetter;
8 
9 /**
10  * Configuration object that is accessed by databinding functionality
11  * to find overrides to configuration of properties, based on declared
12  * type of the property. Such overrides have precedence over annotations
13  * attached to actual type ({@link java.lang.Class}), but can be further
14  * overridden by annotations attached to the property itself.
15  *
16  * @since 2.8
17  */
18 public abstract class ConfigOverride
19 {
20     /**
21      * Definitions of format overrides, if any.
22      */
23     protected JsonFormat.Value _format;
24 
25     /**
26      * Definitions of inclusion defaults to use for properties included in this POJO type.
27      * Overrides global defaults, may be overridden by per-property-type (see
28      * {@link #_includeAsProperty}) and per-property overrides (annotations).
29      */
30     protected JsonInclude.Value _include;
31 
32     /**
33      * Definitions of inclusion defaults for properties of this specified type (regardless
34      * of POJO in which they are included).
35      * Overrides global defaults, per-POJO inclusion defaults (see {#link {@link #_include}}),
36      * may be overridden by per-property overrides.
37      *
38      * @since 2.9
39      */
40     protected JsonInclude.Value _includeAsProperty;
41 
42     /**
43      * Definitions of property ignoral (whether to serialize, deserialize
44      * given logical property) overrides, if any.
45      */
46     protected JsonIgnoreProperties.Value _ignorals;
47 
48     /**
49      * Definitions of setter overrides regarding null handling
50      *
51      * @since 2.9
52      */
53     protected JsonSetter.Value _setterInfo;
54 
55     /**
56      * Overrides for auto-detection visibility rules for this type.
57      *
58      * @since 2.9
59      */
60     protected JsonAutoDetect.Value _visibility;
61 
62     /**
63      * Flag that indicates whether "is ignorable type" is specified for this type;
64      * and if so, is it to be ignored (true) or not ignored (false); `null` is
65      * used to indicate "not specified", in which case other configuration (class
66      * annotation) is used.
67      */
68     protected Boolean _isIgnoredType;
69 
70     /**
71      * Flag that indicates whether properties of this type default to being merged
72      * or not.
73      */
74     protected Boolean _mergeable;
75 
ConfigOverride()76     protected ConfigOverride() { }
ConfigOverride(ConfigOverride src)77     protected ConfigOverride(ConfigOverride src) {
78         _format = src._format;
79         _include = src._include;
80         _includeAsProperty = src._includeAsProperty;
81         _ignorals = src._ignorals;
82         _setterInfo = src._setterInfo;
83         _visibility = src._visibility;
84         _isIgnoredType = src._isIgnoredType;
85         _mergeable = src._mergeable;
86     }
87 
88     /**
89      * Accessor for immutable "empty" instance that has no configuration overrides defined.
90      *
91      * @since 2.9
92      */
empty()93     public static ConfigOverride empty() {
94         return Empty.INSTANCE;
95     }
96 
getFormat()97     public JsonFormat.Value getFormat() { return _format; }
getInclude()98     public JsonInclude.Value getInclude() { return _include; }
99 
100     /**
101      * @since 2.9
102      */
getIncludeAsProperty()103     public JsonInclude.Value getIncludeAsProperty() { return _includeAsProperty; }
104 
getIgnorals()105     public JsonIgnoreProperties.Value getIgnorals() { return _ignorals; }
106 
getIsIgnoredType()107     public Boolean getIsIgnoredType() {
108         return _isIgnoredType;
109     }
110 
111     /**
112      * @since 2.9
113      */
getSetterInfo()114     public JsonSetter.Value getSetterInfo() { return _setterInfo; }
115 
116     /**
117      * @since 2.9
118      */
getVisibility()119     public JsonAutoDetect.Value getVisibility() { return _visibility; }
120 
121     /**
122      * @since 2.9
123      */
getMergeable()124     public Boolean getMergeable() { return _mergeable; }
125 
126     /**
127      * Implementation used solely for "empty" instance; has no mutators
128      * and is not changed by core functionality.
129      *
130      * @since 2.9
131      */
132     final static class Empty extends ConfigOverride {
133         final static Empty INSTANCE = new Empty();
134 
Empty()135         private Empty() { }
136     }
137 }
138