1 package com.fasterxml.jackson.databind;
2 
3 import java.lang.annotation.Annotation;
4 import java.util.*;
5 
6 import com.fasterxml.jackson.annotation.*;
7 import com.fasterxml.jackson.core.Version;
8 import com.fasterxml.jackson.core.Versioned;
9 
10 import com.fasterxml.jackson.databind.JsonDeserializer;
11 import com.fasterxml.jackson.databind.JsonSerializer;
12 import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
13 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
14 import com.fasterxml.jackson.databind.cfg.MapperConfig;
15 import com.fasterxml.jackson.databind.deser.ValueInstantiator;
16 import com.fasterxml.jackson.databind.introspect.*;
17 import com.fasterxml.jackson.databind.jsontype.NamedType;
18 import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
19 import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
20 import com.fasterxml.jackson.databind.util.Converter;
21 import com.fasterxml.jackson.databind.util.NameTransformer;
22 
23 /**
24  * Abstract class that defines API used for introspecting annotation-based
25  * configuration for serialization and deserialization. Separated
26  * so that different sets of annotations can be supported, and support
27  * plugged-in dynamically.
28  *<p>
29  * Although default implementations are based on using annotations as the only
30  * (or at least main) information source, custom implementations are not limited
31  * in such a way, and in fact there is no expectation they should be. So the name
32  * is bit of misnomer; this is a general configuration introspection facility.
33  *<p>
34  * NOTE: due to rapid addition of new methods (and changes to existing methods),
35  * it is <b>strongly</b> recommended that custom implementations should not directly
36  * extend this class, but rather extend {@link NopAnnotationIntrospector}.
37  * This way added methods will not break backwards compatibility of custom annotation
38  * introspectors.
39  */
40 @SuppressWarnings("serial")
41 public abstract class AnnotationIntrospector
42     implements Versioned, java.io.Serializable
43 {
44     /*
45     /**********************************************************
46     /* Helper types
47     /**********************************************************
48      */
49 
50     /**
51      * Value type used with managed and back references; contains type and
52      * logic name, used to link related references
53      */
54     public static class ReferenceProperty
55     {
56         public enum Type {
57             /**
58              * Reference property that Jackson manages and that is serialized normally (by serializing
59              * reference object), but is used for resolving back references during
60              * deserialization.
61              * Usually this can be defined by using
62              * {@link com.fasterxml.jackson.annotation.JsonManagedReference}
63              */
64             MANAGED_REFERENCE
65 
66             /**
67              * Reference property that Jackson manages by suppressing it during serialization,
68              * and reconstructing during deserialization.
69              * Usually this can be defined by using
70              * {@link com.fasterxml.jackson.annotation.JsonBackReference}
71              */
72             ,BACK_REFERENCE
73             ;
74         }
75 
76         private final Type _type;
77         private final String _name;
78 
ReferenceProperty(Type t, String n)79         public ReferenceProperty(Type t, String n) {
80             _type = t;
81             _name = n;
82         }
83 
managed(String name)84         public static ReferenceProperty managed(String name) { return new ReferenceProperty(Type.MANAGED_REFERENCE, name); }
back(String name)85         public static ReferenceProperty back(String name) { return new ReferenceProperty(Type.BACK_REFERENCE, name); }
86 
getType()87         public Type getType() { return _type; }
getName()88         public String getName() { return _name; }
89 
isManagedReference()90         public boolean isManagedReference() { return _type == Type.MANAGED_REFERENCE; }
isBackReference()91         public boolean isBackReference() { return _type == Type.BACK_REFERENCE; }
92     }
93 
94     /*
95     /**********************************************************
96     /* Factory methods
97     /**********************************************************
98      */
99 
100     /**
101      * Factory method for accessing "no operation" implementation
102      * of introspector: instance that will never find any annotation-based
103      * configuration.
104      *
105      * @return "no operation" instance
106      */
nopInstance()107     public static AnnotationIntrospector nopInstance() {
108         return NopAnnotationIntrospector.instance;
109     }
110 
pair(AnnotationIntrospector a1, AnnotationIntrospector a2)111     public static AnnotationIntrospector pair(AnnotationIntrospector a1, AnnotationIntrospector a2) {
112         return new AnnotationIntrospectorPair(a1, a2);
113     }
114 
115     /*
116     /**********************************************************
117     /* Access to possibly chained introspectors
118     /**********************************************************
119      */
120 
121     /**
122      * Method that can be used to collect all "real" introspectors that
123      * this introspector contains, if any; or this introspector
124      * if it is not a container. Used to get access to all container
125      * introspectors in their priority order.
126      *<p>
127      * Default implementation returns a Singleton list with this introspector
128      * as contents.
129      * This usually works for sub-classes, except for proxy or delegating "container
130      * introspectors" which need to override implementation.
131      *
132      * @return Collection of all introspectors starting with this one, in case
133      *    multiple introspectors are chained
134      */
allIntrospectors()135     public Collection<AnnotationIntrospector> allIntrospectors() {
136         return Collections.singletonList(this);
137     }
138 
139     /**
140      * Method that can be used to collect all "real" introspectors that
141      * this introspector contains, if any; or this introspector
142      * if it is not a container. Used to get access to all container
143      * introspectors in their priority order.
144      *<p>
145      * Default implementation adds this introspector in result; this usually
146      * works for sub-classes, except for proxy or delegating "container
147      * introspectors" which need to override implementation.
148      *
149      * @param result Container to add introspectors to
150      *
151      * @return Passed in {@code Collection} filled with introspectors as explained
152      *    above
153      */
allIntrospectors(Collection<AnnotationIntrospector> result)154     public Collection<AnnotationIntrospector> allIntrospectors(Collection<AnnotationIntrospector> result) {
155         result.add(this);
156         return result;
157     }
158 
159     /*
160     /**********************************************************
161     /* Default Versioned impl
162     /**********************************************************
163      */
164 
165     @Override
version()166     public abstract Version version();
167 
168     /*
169     /**********************************************************
170     /* Meta-annotations (annotations for annotation types)
171     /**********************************************************
172      */
173 
174     /**
175      * Method for checking whether given annotation is considered an
176      * annotation bundle: if so, all meta-annotations it has will
177      * be used instead of annotation ("bundle") itself.
178      *
179      * @param ann Annotated entity to introspect
180      *
181      * @return True if given annotation is considered an annotation
182      *    bundle; false if not
183      */
isAnnotationBundle(Annotation ann)184     public boolean isAnnotationBundle(Annotation ann) {
185         return false;
186     }
187 
188     /*
189     /**********************************************************
190     /* Annotations for Object Id handling
191     /**********************************************************
192      */
193 
194     /**
195      * Method for checking whether given annotated thing
196      * (type, or accessor) indicates that values
197      * referenced (values of type of annotated class, or
198      * values referenced by annotated property; latter
199      * having precedence) should include Object Identifier,
200      * and if so, specify details of Object Identity used.
201      *
202      * @param ann Annotated entity to introspect
203      *
204      * @return Details of Object Id as explained above, if Object Id
205      *    handling to be applied; {@code null} otherwise.
206      */
findObjectIdInfo(Annotated ann)207     public ObjectIdInfo findObjectIdInfo(Annotated ann) {
208         return null;
209     }
210 
211     /**
212      * Method for figuring out additional properties of an Object Identity reference
213      *
214      * @param ann Annotated entity to introspect
215      * @param objectIdInfo (optional) Base Object Id information, if any; {@code null} if none
216      *
217      * @return {@link ObjectIdInfo} augmented with possible additional information
218      *
219      * @since 2.1
220      */
findObjectReferenceInfo(Annotated ann, ObjectIdInfo objectIdInfo)221     public ObjectIdInfo findObjectReferenceInfo(Annotated ann, ObjectIdInfo objectIdInfo) {
222         return objectIdInfo;
223     }
224 
225     /*
226     /**********************************************************
227     /* General class annotations
228     /**********************************************************
229      */
230 
231     /**
232      * Method for locating name used as "root name" (for use by
233      * some serializers when outputting root-level object -- mostly
234      * for XML compatibility purposes) for given class, if one
235      * is defined. Returns null if no declaration found; can return
236      * explicit empty String, which is usually ignored as well as null.
237      *<p>
238      * NOTE: method signature changed in 2.1, to return {@link PropertyName}
239      * instead of String.
240      *
241      * @param ac Annotated class to introspect
242      *
243      * @return Root name to use, if any; {@code null} if not
244      */
findRootName(AnnotatedClass ac)245     public PropertyName findRootName(AnnotatedClass ac) {
246         return null;
247     }
248 
249     /**
250      * Method for checking whether properties that have specified type
251      * (class, not generics aware) should be completely ignored for
252      * serialization and deserialization purposes.
253      *
254      * @param ac Annotated class to introspect
255      *
256      * @return Boolean.TRUE if properties of type should be ignored;
257      *   Boolean.FALSE if they are not to be ignored, null for default
258      *   handling (which is 'do not ignore')
259      */
isIgnorableType(AnnotatedClass ac)260     public Boolean isIgnorableType(AnnotatedClass ac) { return null; }
261 
262     /**
263      * Method for finding information about properties to ignore either by
264      * name, or by more general specification ("ignore all unknown").
265      * This method combines multiple aspects of ignorals and deprecates
266      * earlier methods such as
267      * {@link #findPropertiesToIgnore(Annotated, boolean)} and
268      * {@link #findIgnoreUnknownProperties(AnnotatedClass)}.
269      *
270      * @param config Configuration settings in effect (for serialization or deserialization)
271      * @param ann Annotated entity (Class, Accessor) to introspect
272      *
273      * @since 2.12 (to replace {@code findPropertyIgnorals()})
274      */
findPropertyIgnoralByName(MapperConfig<?> config, Annotated ann)275     public JsonIgnoreProperties.Value findPropertyIgnoralByName(MapperConfig<?> config, Annotated ann)
276     {
277         // In 2.12, remove redirection in future
278         return findPropertyIgnorals(ann);
279     }
280 
281     /**
282      * Method for finding information about names of properties to included.
283      * This is typically used to strictly limit properties to include based
284      * on fully defined set of names ("allow-listing"), as opposed to excluding
285      * potential properties by exclusion ("deny-listing").
286      *
287      * @param config Configuration settings in effect (for serialization or deserialization)
288      * @param ann Annotated entity (Class, Accessor) to introspect
289      *
290      * @since 2.12
291      */
findPropertyInclusionByName(MapperConfig<?> config, Annotated ann)292     public JsonIncludeProperties.Value findPropertyInclusionByName(MapperConfig<?> config, Annotated ann) {
293         return JsonIncludeProperties.Value.all();
294     }
295 
296     /**
297      * Method for finding if annotated class has associated filter; and if so,
298      * to return id that is used to locate filter.
299      *
300      * @param ann Annotated entity to introspect
301      *
302      * @return Id of the filter to use for filtering properties of annotated
303      *    class, if any; or null if none found.
304      */
findFilterId(Annotated ann)305     public Object findFilterId(Annotated ann) { return null; }
306 
307     /**
308      * Method for finding {@link PropertyNamingStrategy} for given
309      * class, if any specified by annotations; and if so, either return
310      * a {@link PropertyNamingStrategy} instance, or Class to use for
311      * creating instance
312      *
313      * @param ac Annotated class to introspect
314      *
315      * @return Sub-class or instance of {@link PropertyNamingStrategy}, if one
316      *   is specified for given class; null if not.
317      *
318      * @since 2.1
319      */
findNamingStrategy(AnnotatedClass ac)320     public Object findNamingStrategy(AnnotatedClass ac) { return null; }
321 
322     /**
323      * Method used to check whether specified class defines a human-readable
324      * description to use for documentation.
325      * There are no further definitions for contents; for example, whether
326      * these may be marked up using HTML (or something like wiki format like Markup)
327      * is not defined.
328      *
329      * @param ac Annotated class to introspect
330      *
331      * @return Human-readable description, if any.
332      *
333      * @since 2.7
334      */
findClassDescription(AnnotatedClass ac)335     public String findClassDescription(AnnotatedClass ac) { return null; }
336 
337     /**
338      * @param forSerialization True if requesting properties to ignore for serialization;
339      *   false if for deserialization
340      * @param ac Annotated class to introspect
341      *
342      * @return Array of names of properties to ignore
343      *
344      * @since 2.6
345      *
346      * @deprecated Since 2.8, use {@link #findPropertyIgnoralByName} instead
347      */
348     @Deprecated // since 2.8
findPropertiesToIgnore(Annotated ac, boolean forSerialization)349     public String[] findPropertiesToIgnore(Annotated ac, boolean forSerialization) {
350         return null;
351     }
352 
353     /**
354      * Method for checking whether an annotation indicates that all unknown properties
355      * should be ignored.
356      *
357      * @param ac Annotated class to introspect
358      *
359      * @return True if class has something indicating "ignore [all] unknown properties"
360      *
361      * @deprecated Since 2.8, use {@link #findPropertyIgnoralByName} instead
362      */
363     @Deprecated // since 2.8
findIgnoreUnknownProperties(AnnotatedClass ac)364     public Boolean findIgnoreUnknownProperties(AnnotatedClass ac) { return null; }
365 
366     /**
367      * @since 2.8
368      * @deprecated 2.12, use {@link #findPropertyIgnoralByName} instead.
369      */
370     @Deprecated // since 2.12
findPropertyIgnorals(Annotated ac)371     public JsonIgnoreProperties.Value findPropertyIgnorals(Annotated ac) {
372         return JsonIgnoreProperties.Value.empty();
373     }
374 
375     /*
376     /**********************************************************
377     /* Property auto-detection
378     /**********************************************************
379      */
380 
381     /**
382      * Method for checking if annotations indicate changes to minimum visibility levels
383      * needed for auto-detecting property elements (fields, methods, constructors).
384      * A baseline checker is given, and introspector is to either return it as is
385      * (if no annotations are found), or build and return a derived instance (using
386      * checker's build methods).
387      */
findAutoDetectVisibility(AnnotatedClass ac, VisibilityChecker<?> checker)388     public VisibilityChecker<?> findAutoDetectVisibility(AnnotatedClass ac, VisibilityChecker<?> checker) {
389         return checker;
390     }
391 
392     /*
393     /**********************************************************
394     /* Annotations for Polymorphic type handling
395     /**********************************************************
396     */
397 
398     /**
399      * Method for checking if given class has annotations that indicate
400      * that specific type resolver is to be used for handling instances.
401      * This includes not only
402      * instantiating resolver builder, but also configuring it based on
403      * relevant annotations (not including ones checked with a call to
404      * {@link #findSubtypes}
405      *
406      * @param config Configuration settings in effect (for serialization or deserialization)
407      * @param ac Annotated class to check for annotations
408      * @param baseType Base java type of value for which resolver is to be found
409      *
410      * @return Type resolver builder for given type, if one found; null if none
411      */
findTypeResolver(MapperConfig<?> config, AnnotatedClass ac, JavaType baseType)412     public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config,
413             AnnotatedClass ac, JavaType baseType) {
414         return null;
415     }
416 
417     /**
418      * Method for checking if given property entity (field or method) has annotations
419      * that indicate that specific type resolver is to be used for handling instances.
420      * This includes not only
421      * instantiating resolver builder, but also configuring it based on
422      * relevant annotations (not including ones checked with a call to
423      * {@link #findSubtypes}
424      *
425      * @param config Configuration settings in effect (for serialization or deserialization)
426      * @param am Annotated member (field or method) to check for annotations
427      * @param baseType Base java type of property for which resolver is to be found
428      *
429      * @return Type resolver builder for properties of given entity, if one found;
430      *    null if none
431      */
findPropertyTypeResolver(MapperConfig<?> config, AnnotatedMember am, JavaType baseType)432     public TypeResolverBuilder<?> findPropertyTypeResolver(MapperConfig<?> config,
433             AnnotatedMember am, JavaType baseType) {
434         return null;
435     }
436 
437     /**
438      * Method for checking if given structured property entity (field or method that
439      * has nominal value of Map, Collection or array type) has annotations
440      * that indicate that specific type resolver is to be used for handling type
441      * information of contained values.
442      * This includes not only
443      * instantiating resolver builder, but also configuring it based on
444      * relevant annotations (not including ones checked with a call to
445      * {@link #findSubtypes}
446      *
447      * @param config Configuration settings in effect (for serialization or deserialization)
448      * @param am Annotated member (field or method) to check for annotations
449      * @param containerType Type of property for which resolver is to be found (must be a container type)
450      *
451      * @return Type resolver builder for values contained in properties of given entity,
452      *    if one found; null if none
453      */
findPropertyContentTypeResolver(MapperConfig<?> config, AnnotatedMember am, JavaType containerType)454     public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> config,
455             AnnotatedMember am, JavaType containerType) {
456         return null;
457     }
458 
459     /**
460      * Method for locating annotation-specified subtypes related to annotated
461      * entity (class, method, field). Note that this is only guaranteed to be
462      * a list of directly
463      * declared subtypes, no recursive processing is guarantees (i.e. caller
464      * has to do it if/as necessary)
465      *
466      * @param a Annotated entity (class, field/method) to check for annotations
467      */
findSubtypes(Annotated a)468     public List<NamedType> findSubtypes(Annotated a) { return null; }
469 
470     /**
471      * Method for checking if specified type has explicit name.
472      *
473      * @param ac Class to check for type name annotations
474      */
findTypeName(AnnotatedClass ac)475     public String findTypeName(AnnotatedClass ac) { return null; }
476 
477     /**
478      * Method for checking whether given accessor claims to represent
479      * type id: if so, its value may be used as an override,
480      * instead of generated type id.
481      */
isTypeId(AnnotatedMember member)482     public Boolean isTypeId(AnnotatedMember member) { return null; }
483 
484     /*
485     /**********************************************************
486     /* General member (field, method/constructor) annotations
487     /**********************************************************
488      */
489 
490     /**
491      * Method for checking if given member indicates that it is part
492      * of a reference (parent/child).
493      */
findReferenceType(AnnotatedMember member)494     public ReferenceProperty findReferenceType(AnnotatedMember member) { return null; }
495 
496     /**
497      * Method called to check whether given property is marked to be "unwrapped"
498      * when being serialized (and appropriately handled in reverse direction,
499      * i.e. expect unwrapped representation during deserialization).
500      * Return value is the name transformation to use, if wrapping/unwrapping
501      * should  be done, or null if not -- note that transformation may simply
502      * be identity transformation (no changes).
503      */
findUnwrappingNameTransformer(AnnotatedMember member)504     public NameTransformer findUnwrappingNameTransformer(AnnotatedMember member) { return null; }
505 
506     /**
507      * Method called to check whether given property is marked to
508      * be ignored. This is used to determine whether to ignore
509      * properties, on per-property basis, usually combining
510      * annotations from multiple accessors (getters, setters, fields,
511      * constructor parameters).
512      */
hasIgnoreMarker(AnnotatedMember m)513     public boolean hasIgnoreMarker(AnnotatedMember m) { return false; }
514 
515     /**
516      * Method called to find out whether given member expectes a value
517      * to be injected, and if so, what is the identifier of the value
518      * to use during injection.
519      * Type if identifier needs to be compatible with provider of
520      * values (of type {@link InjectableValues}); often a simple String
521      * id is used.
522      *
523      * @param m Member to check
524      *
525      * @return Identifier of value to inject, if any; null if no injection
526      *   indicator is found
527      *
528      * @since 2.9
529      */
findInjectableValue(AnnotatedMember m)530     public JacksonInject.Value findInjectableValue(AnnotatedMember m) {
531         // 05-Apr-2017, tatu: Just for 2.9, call deprecated method to help
532         //    with some cases of overrides for legacy code
533         Object id = findInjectableValueId(m);
534         if (id != null) {
535             return JacksonInject.Value.forId(id);
536         }
537         return null;
538     }
539 
540     /**
541      * Method that can be called to check whether this member has
542      * an annotation that suggests whether value for matching property
543      * is required or not.
544      */
hasRequiredMarker(AnnotatedMember m)545     public Boolean hasRequiredMarker(AnnotatedMember m) { return null; }
546 
547     /**
548      * Method for checking if annotated property (represented by a field or
549      * getter/setter method) has definitions for views it is to be included in.
550      * If null is returned, no view definitions exist and property is always
551      * included (or always excluded as per default view inclusion configuration);
552      * otherwise it will only be included for views included in returned
553      * array. View matches are checked using class inheritance rules (sub-classes
554      * inherit inclusions of super-classes)
555      *<p>
556      * Since 2.9 this method may also be called to find "default view(s)" for
557      * {@link AnnotatedClass}
558      *
559      * @param a Annotated property (represented by a method, field or ctor parameter)
560      * @return Array of views (represented by classes) that the property is included in;
561      *    if null, always included (same as returning array containing <code>Object.class</code>)
562      */
findViews(Annotated a)563     public Class<?>[] findViews(Annotated a) { return null; }
564 
565     /**
566      * Method for finding format annotations for property or class.
567      * Return value is typically used by serializers and/or
568      * deserializers to customize presentation aspects of the
569      * serialized value.
570      *
571      * @since 2.1
572      */
findFormat(Annotated memberOrClass)573     public JsonFormat.Value findFormat(Annotated memberOrClass) {
574         return JsonFormat.Value.empty();
575     }
576 
577     /**
578      * Method used to check if specified property has annotation that indicates
579      * that it should be wrapped in an element; and if so, name to use.
580      * Note that not all serializers and deserializers support use this method:
581      * currently (2.1) it is only used by XML-backed handlers.
582      *
583      * @return Wrapper name to use, if any, or {@link PropertyName#USE_DEFAULT}
584      *   to indicate that no wrapper element should be used.
585      *
586      * @since 2.1
587      */
findWrapperName(Annotated ann)588     public PropertyName findWrapperName(Annotated ann) { return null; }
589 
590     /**
591      * Method for finding suggested default value (as simple textual serialization)
592      * for the property. While core databind does not make any use of it, it is exposed
593      * for extension modules to use: an expected use is generation of schema representations
594      * and documentation.
595      *
596      * @since 2.5
597      */
findPropertyDefaultValue(Annotated ann)598     public String findPropertyDefaultValue(Annotated ann) { return null; }
599 
600     /**
601      * Method used to check whether specified property member (accessor
602      * or mutator) defines human-readable description to use for documentation.
603      * There are no further definitions for contents; for example, whether
604      * these may be marked up using HTML is not defined.
605      *
606      * @return Human-readable description, if any.
607      *
608      * @since 2.3
609      */
findPropertyDescription(Annotated ann)610     public String findPropertyDescription(Annotated ann) { return null; }
611 
612     /**
613      * Method used to check whether specified property member (accessor
614      * or mutator) defines numeric index, and if so, what is the index value.
615      * Possible use cases for index values included use by underlying data format
616      * (some binary formats mandate use of index instead of name) and ordering
617      * of properties (for documentation, or during serialization).
618      *
619      * @since 2.4
620      *
621      * @return Explicitly specified index for the property, if any
622      */
findPropertyIndex(Annotated ann)623     public Integer findPropertyIndex(Annotated ann) { return null; }
624 
625     /**
626      * Method for finding implicit name for a property that given annotated
627      * member (field, method, creator parameter) may represent.
628      * This is different from explicit, annotation-based property name, in that
629      * it is "weak" and does not either proof that a property exists (for example,
630      * if visibility is not high enough), or override explicit names.
631      * In practice this method is used to introspect optional names for creator
632      * parameters (which may or may not be available and cannot be detected
633      * by standard databind); or to provide alternate name mangling for
634      * fields, getters and/or setters.
635      *
636      * @since 2.4
637      */
findImplicitPropertyName(AnnotatedMember member)638     public String findImplicitPropertyName(AnnotatedMember member) { return null; }
639 
640     /**
641      * Method called to find if given property has alias(es) defined.
642      *
643      * @return `null` if member has no information; otherwise a `List` (possibly
644      *   empty) of aliases to use.
645      *
646      * @since 2.9
647      */
findPropertyAliases(Annotated ann)648     public List<PropertyName> findPropertyAliases(Annotated ann) { return null; }
649 
650     /**
651      * Method for finding optional access definition for a property, annotated
652      * on one of its accessors. If a definition for read-only, write-only
653      * or read-write cases, visibility rules may be modified. Note, however,
654      * that even more specific annotations (like one for ignoring specific accessor)
655      * may further override behavior of the access definition.
656      *
657      * @since 2.6
658      */
findPropertyAccess(Annotated ann)659     public JsonProperty.Access findPropertyAccess(Annotated ann) { return null; }
660 
661     /**
662      * Method called in cases where a class has two methods eligible to be used
663      * for the same logical property, and default logic is not enough to figure
664      * out clear precedence. Introspector may try to choose one to use; or, if
665      * unable, return `null` to indicate it cannot resolve the problem.
666      *
667      * @since 2.7
668      */
resolveSetterConflict(MapperConfig<?> config, AnnotatedMethod setter1, AnnotatedMethod setter2)669     public AnnotatedMethod resolveSetterConflict(MapperConfig<?> config,
670             AnnotatedMethod setter1, AnnotatedMethod setter2) {
671         return null;
672     }
673 
674     /**
675      * Method called on fields that are eligible candidates for properties
676      * (that is, non-static member fields), but not necessarily selected (may
677      * or may not be visible), to let fields affect name linking.
678      * Call will be made after finding implicit name (which by default is just
679      * name of the field, but may be overridden by introspector), but before
680      * discovering other accessors.
681      * If non-null name returned, it is to be used to find other accessors (getters,
682      * setters, creator parameters) and replace their implicit names with that
683      * of field's implicit name (assuming they differ).
684      *<p>
685      * Specific example (and initial use case is for support Kotlin's "is getter"
686      * matching (see
687      * <a href="https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html">Kotling Interop</a>
688      * for details), in which field like '{@code isOpen}' would have implicit name of
689      * "isOpen", match getter {@code getOpen()} and setter {@code setOpen(boolean)},
690      * but use logical external name of "isOpen" (and not implicit name of getter/setter, "open"!).
691      * To achieve this, field implicit name needs to remain "isOpen" but this method needs
692      * to return name {@code PropertyName.construct("open")}: doing so will "pull in" getter
693      * and/or setter, and rename them as "isOpen".
694      *
695      * @param config Effective mapper configuration in use
696      * @param f Field to check
697      * @param implName Implicit name of the field; usually name of field itself but not always,
698      *    used as the target name for accessors to rename.
699      *
700      * @return Name used to find other accessors to rename, if any; {@code null} to indicate
701      *    no renaming
702      *
703      * @since 2.11
704      */
findRenameByField(MapperConfig<?> config, AnnotatedField f, PropertyName implName)705     public PropertyName findRenameByField(MapperConfig<?> config,
706             AnnotatedField f, PropertyName implName) {
707         return null;
708     }
709 
710     /**
711      * @deprecated Since 2.9 Use {@link #findInjectableValue} instead
712      */
713     @Deprecated // since 2.9
findInjectableValueId(AnnotatedMember m)714     public Object findInjectableValueId(AnnotatedMember m) {
715         return null;
716     }
717 
718     /*
719     /**********************************************************
720     /* Serialization: general annotations
721     /**********************************************************
722      */
723 
724     /**
725      * Method for getting a serializer definition on specified method
726      * or field. Type of definition is either instance (of type {@link JsonSerializer})
727      * or Class (of {@code Class<JsonSerializer>} implementation subtype);
728      * if value of different type is returned, a runtime exception may be thrown by caller.
729      */
findSerializer(Annotated am)730     public Object findSerializer(Annotated am) {
731         return null;
732     }
733 
734     /**
735      * Method for getting a serializer definition for keys of associated {@code java.util.Map} property.
736      * Type of definition is either instance (of type {@link JsonSerializer})
737      * or Class (of type  {@code Class<JsonSerializer>});
738      * if value of different type is returned, a runtime exception may be thrown by caller.
739      */
findKeySerializer(Annotated am)740     public Object findKeySerializer(Annotated am) {
741         return null;
742     }
743 
744     /**
745      * Method for getting a serializer definition for content (values) of
746      * associated <code>Collection</code>, <code>array</code> or {@code Map} property.
747      * Type of definition is either instance (of type {@link JsonSerializer})
748      * or Class (of type  {@code Class<JsonSerializer>});
749      * if value of different
750      * type is returned, a runtime exception may be thrown by caller.
751      */
findContentSerializer(Annotated am)752     public Object findContentSerializer(Annotated am) {
753         return null;
754     }
755 
756     /**
757      * Method for getting a serializer definition for serializer to use
758      * for nulls (null values) of associated property or type.
759      *
760      * @since 2.3
761      */
findNullSerializer(Annotated am)762     public Object findNullSerializer(Annotated am) {
763         return null;
764     }
765 
766     /**
767      * Method for accessing declared typing mode annotated (if any).
768      * This is used for type detection, unless more granular settings
769      * (such as actual exact type; or serializer to use which means
770      * no type information is needed) take precedence.
771      *
772      * @return Typing mode to use, if annotation is found; null otherwise
773      */
findSerializationTyping(Annotated a)774     public JsonSerialize.Typing findSerializationTyping(Annotated a) {
775         return null;
776     }
777 
778     /**
779      * Method for finding {@link Converter} that annotated entity
780      * (property or class) has indicated to be used as part of
781      * serialization. If not null, either has to be actual
782      * {@link Converter} instance, or class for such converter;
783      * and resulting converter will be used first to convert property
784      * value to converter target type, and then serializer for that
785      * type is used for actual serialization.
786      *<p>
787      * This feature is typically used to convert internal values into types
788      * that Jackson can convert.
789      *<p>
790      * Note also that this feature does not necessarily work well with polymorphic
791      * type handling, or object identity handling; if such features are needed
792      * an explicit serializer is usually better way to handle serialization.
793      *
794      * @param a Annotated property (field, method) or class to check for
795      *   annotations
796      *
797      * @since 2.2
798      */
findSerializationConverter(Annotated a)799     public Object findSerializationConverter(Annotated a) {
800         return null;
801     }
802 
803     /**
804      * Method for finding {@link Converter} that annotated property
805      * has indicated needs to be used for values of container type
806      * (this also means that method should only be called for properties
807      * of container types, List/Map/array properties).
808      *<p>
809      * If not null, either has to be actual
810      * {@link Converter} instance, or class for such converter;
811      * and resulting converter will be used first to convert property
812      * value to converter target type, and then serializer for that
813      * type is used for actual serialization.
814      *<p>
815      * Other notes are same as those for {@link #findSerializationConverter}
816      *
817      * @param a Annotated property (field, method) to check.
818      *
819      * @since 2.2
820      */
findSerializationContentConverter(AnnotatedMember a)821     public Object findSerializationContentConverter(AnnotatedMember a) {
822         return null;
823     }
824 
825     /**
826      * Method for checking inclusion criteria for a type (Class) or property (yes, method
827      * name is bit unfortunate -- not just for properties!).
828      * In case of class, acts as the default for properties POJO contains; for properties
829      * acts as override for class defaults and possible global defaults.
830      *
831      * @since 2.6
832      */
findPropertyInclusion(Annotated a)833     public JsonInclude.Value findPropertyInclusion(Annotated a) {
834         return JsonInclude.Value.empty();
835     }
836 
837     /**
838      * Method for checking whether given annotated entity (class, method,
839      * field) defines which Bean/Map properties are to be included in
840      * serialization.
841      * If no annotation is found, method should return given second
842      * argument; otherwise value indicated by the annotation.
843      *<p>
844      * Note that meaning of inclusion value depends on whether it is for
845      * a Class or property (field/method/constructor): in former case,
846      * it is the default for all properties; in latter case it is specific
847      * override for annotated property.
848      *
849      * @return Enumerated value indicating which properties to include
850      *   in serialization
851      *
852      * @deprecated Since 2.7 Use {@link #findPropertyInclusion} instead
853      */
854     @Deprecated // since 2.7
findSerializationInclusion(Annotated a, JsonInclude.Include defValue)855     public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.Include defValue) {
856         return defValue;
857     }
858 
859     /**
860      * Method for checking whether content (entries) of a {@link java.util.Map} property
861      * are to be included during serialization or not.
862      * NOTE: this is NOT called for POJO properties, or array/Collection elements.
863      *
864      * @since 2.5
865      *
866      * @deprecated Since 2.7 Use {@link #findPropertyInclusion} instead
867      */
868     @Deprecated // since 2.7
findSerializationInclusionForContent(Annotated a, JsonInclude.Include defValue)869     public JsonInclude.Include findSerializationInclusionForContent(Annotated a, JsonInclude.Include defValue) {
870         return defValue;
871     }
872 
873     /*
874     /**********************************************************
875     /* Serialization: type refinements
876     /**********************************************************
877      */
878 
879     /**
880      * Method called to find out possible type refinements to use
881      * for deserialization, including not just value itself but
882      * key and/or content type, if type has those.
883      *
884      * @since 2.7
885      */
refineSerializationType(final MapperConfig<?> config, final Annotated a, final JavaType baseType)886     public JavaType refineSerializationType(final MapperConfig<?> config,
887             final Annotated a, final JavaType baseType) throws JsonMappingException
888     {
889         return baseType;
890     }
891 
892     /**
893      * @deprecated Since 2.7 call {@link #refineSerializationType} instead
894      */
895     @Deprecated // since 2.7
findSerializationType(Annotated a)896     public Class<?> findSerializationType(Annotated a) {
897         return null;
898     }
899 
900     /**
901      * @deprecated Since 2.7 call {@link #refineSerializationType} instead
902      */
903     @Deprecated // since 2.7
findSerializationKeyType(Annotated am, JavaType baseType)904     public Class<?> findSerializationKeyType(Annotated am, JavaType baseType) {
905         return null;
906     }
907 
908     /**
909      * @deprecated Since 2.7 call {@link #refineSerializationType} instead
910      */
911     @Deprecated // since 2.7
findSerializationContentType(Annotated am, JavaType baseType)912     public Class<?> findSerializationContentType(Annotated am, JavaType baseType) {
913         return null;
914     }
915 
916     /*
917     /**********************************************************
918     /* Serialization: class annotations
919     /**********************************************************
920      */
921 
922     /**
923      * Method for accessing defined property serialization order (which may be
924      * partial). May return null if no ordering is defined.
925      */
findSerializationPropertyOrder(AnnotatedClass ac)926     public String[] findSerializationPropertyOrder(AnnotatedClass ac) {
927         return null;
928     }
929 
930     /**
931      * Method for checking whether an annotation indicates that serialized properties
932      * for which no explicit is defined should be alphabetically (lexicograpically)
933      * ordered
934      */
findSerializationSortAlphabetically(Annotated ann)935     public Boolean findSerializationSortAlphabetically(Annotated ann) {
936         return null;
937     }
938 
939     /**
940      * Method for adding possible virtual properties to be serialized along
941      * with regular properties.
942      *
943      * @since 2.5
944      */
findAndAddVirtualProperties(MapperConfig<?> config, AnnotatedClass ac, List<BeanPropertyWriter> properties)945     public void findAndAddVirtualProperties(MapperConfig<?> config, AnnotatedClass ac,
946             List<BeanPropertyWriter> properties) { }
947 
948     /*
949     /**********************************************************
950     /* Serialization: property annotations
951     /**********************************************************
952      */
953 
954     /**
955      * Method for checking whether given property accessors (method,
956      * field) has an annotation that suggests property name to use
957      * for serialization.
958      * Should return null if no annotation
959      * is found; otherwise a non-null name (possibly
960      * {@link PropertyName#USE_DEFAULT}, which means "use default heuristics").
961      *
962      * @param a Property accessor to check
963      *
964      * @return Name to use if found; null if not.
965      *
966      * @since 2.1
967      */
findNameForSerialization(Annotated a)968     public PropertyName findNameForSerialization(Annotated a) {
969         return null;
970     }
971 
972     /**
973      * Method for checking whether given method has an annotation
974      * that suggests that the return value of annotated method
975      * should be used as "the value" of the object instance; usually
976      * serialized as a primitive value such as String or number.
977      *
978      * @return {@link Boolean#TRUE} if such annotation is found and is not disabled;
979      *   {@link Boolean#FALSE} if disabled annotation (block) is found (to indicate
980      *   accessor is definitely NOT to be used "as value"); or `null` if no
981      *   information found.
982      *
983      * @since 2.9
984      */
hasAsValue(Annotated a)985     public Boolean hasAsValue(Annotated a) {
986         // 20-Nov-2016, tatu: Delegate in 2.9; remove redirect from later versions
987         if (a instanceof AnnotatedMethod) {
988             if (hasAsValueAnnotation((AnnotatedMethod) a)) {
989                 return true;
990             }
991         }
992         return null;
993     }
994 
995     /**
996      * Method for checking whether given method has an annotation
997      * that suggests that the method is to serve as "any setter";
998      * method to be used for accessing set of miscellaneous "extra"
999      * properties, often bound with matching "any setter" method.
1000      *
1001      * @param ann Annotated entity to check
1002      *
1003      * @return True if such annotation is found (and is not disabled),
1004      *   false otherwise
1005      *
1006      * @since 2.9
1007      */
hasAnyGetter(Annotated ann)1008     public Boolean hasAnyGetter(Annotated ann) {
1009 
1010         // 21-Nov-2016, tatu: Delegate in 2.9; remove redirect from later versions
1011         if (ann instanceof AnnotatedMethod) {
1012             if (hasAnyGetterAnnotation((AnnotatedMethod) ann)) {
1013                 return true;
1014             }
1015         }
1016         return null;
1017     }
1018 
1019     /**
1020      * Method for efficiently figuring out which if given set of <code>Enum</code> values
1021      * have explicitly defined name. Method will overwrite entries in incoming <code>names</code>
1022      * array with explicit names found, if any, leaving other entries unmodified.
1023      *
1024      * @param enumType Type of Enumeration
1025      * @param enumValues Values of enumeration
1026      * @param names Matching declared names of enumeration values (with indexes
1027      *     matching {@code enumValues} entries)
1028      *
1029      * @return Array of names to use (possible {@code names} passed as argument)
1030      *
1031      * @since 2.7
1032      */
findEnumValues(Class<?> enumType, Enum<?>[] enumValues, String[] names)1033     public String[] findEnumValues(Class<?> enumType, Enum<?>[] enumValues, String[] names) {
1034         // 18-Oct-2016, tatu: In 2.8 delegated to deprecated method; not so in 2.9 and beyond
1035         return names;
1036     }
1037 
1038     /**
1039      * Method that is related to {@link #findEnumValues} but is called to check if
1040      * there are alternative names (aliased) that can be accepted for entries, in
1041      * addition to primary names introspected earlier.
1042      * If so, these aliases should be returned in {@code aliases} {@link List} passed
1043      * as argument (and initialized for proper size by caller).
1044      *
1045      * @param enumType Type of Enumeration
1046      * @param enumValues Values of enumeration
1047      * @param aliases (in/out) Pre-allocated array where aliases found, if any, may be
1048      *     added (in indexes matching those of {@code enumValues})
1049      *
1050      * @since 2.11
1051      */
findEnumAliases(Class<?> enumType, Enum<?>[] enumValues, String[][] aliases)1052     public void findEnumAliases(Class<?> enumType, Enum<?>[] enumValues, String[][] aliases) {
1053         ;
1054     }
1055 
1056     /**
1057      * Finds the Enum value that should be considered the default value, if possible.
1058      *
1059      * @param enumCls The Enum class to scan for the default value
1060      *
1061      * @return null if none found or it's not possible to determine one
1062      *
1063      * @since 2.8
1064      */
findDefaultEnumValue(Class<Enum<?>> enumCls)1065     public Enum<?> findDefaultEnumValue(Class<Enum<?>> enumCls) {
1066         return null;
1067     }
1068 
1069     /**
1070      * Method for determining the String value to use for serializing
1071      * given enumeration entry; used when serializing enumerations
1072      * as Strings (the standard method).
1073      *
1074      * @param value Enum value to introspect
1075      *
1076      * @return Serialized enum value.
1077      *
1078      * @deprecated Since 2.8: use {@link #findEnumValues} instead because this method
1079      *    does not properly handle override settings (defaults to <code>enum.name</code>
1080      *    without indicating whether that is explicit or not), and is inefficient to
1081      *    call one-by-one.
1082      */
1083     @Deprecated
findEnumValue(Enum<?> value)1084     public String findEnumValue(Enum<?> value) {
1085         return value.name();
1086     }
1087 
1088     /**
1089      * @param am Annotated method to check
1090      *
1091      * @deprecated Since 2.9 Use {@link #hasAsValue(Annotated)} instead.
1092      */
1093     @Deprecated // since 2.9
hasAsValueAnnotation(AnnotatedMethod am)1094     public boolean hasAsValueAnnotation(AnnotatedMethod am) {
1095         return false;
1096     }
1097 
1098     /**
1099      * @param am Annotated method to check
1100      *
1101      * @deprecated Since 2.9 Use {@link #hasAnyGetter} instead
1102      */
1103     @Deprecated
hasAnyGetterAnnotation(AnnotatedMethod am)1104     public boolean hasAnyGetterAnnotation(AnnotatedMethod am) {
1105         return false;
1106     }
1107 
1108     /*
1109     /**********************************************************
1110     /* Deserialization: general annotations
1111     /**********************************************************
1112      */
1113 
1114     /**
1115      * Method for getting a deserializer definition on specified method
1116      * or field.
1117      * Type of definition is either instance (of type {@link JsonDeserializer})
1118      * or Class (of type  {@code Class&<JsonDeserializer>});
1119      * type is returned, a runtime exception may be thrown by caller.
1120      */
findDeserializer(Annotated am)1121     public Object findDeserializer(Annotated am) {
1122         return null;
1123     }
1124 
1125     /**
1126      * Method for getting a deserializer definition for keys of
1127      * associated <code>Map</code> property.
1128      * Type of definition is either instance (of type {@link JsonDeserializer})
1129      * or Class (of type  {@code Class<JsonDeserializer>});
1130      * if value of different
1131      * type is returned, a runtime exception may be thrown by caller.
1132      */
findKeyDeserializer(Annotated am)1133     public Object findKeyDeserializer(Annotated am) {
1134         return null;
1135     }
1136 
1137     /**
1138      * Method for getting a deserializer definition for content (values) of
1139      * associated <code>Collection</code>, <code>array</code> or
1140      * <code>Map</code> property.
1141      * Type of definition is either instance (of type {@link JsonDeserializer})
1142      * or Class (of type  {@code Class<JsonDeserializer>});
1143      * if value of different
1144      * type is returned, a runtime exception may be thrown by caller.
1145      */
findContentDeserializer(Annotated am)1146     public Object findContentDeserializer(Annotated am) {
1147         return null;
1148     }
1149 
1150     /**
1151      * Method for finding {@link Converter} that annotated entity
1152      * (property or class) has indicated to be used as part of
1153      * deserialization.
1154      * If not null, either has to be actual
1155      * {@link Converter} instance, or class for such converter;
1156      * and resulting converter will be used after Jackson has deserializer
1157      * data into intermediate type (Converter input type), and Converter
1158      * needs to convert this into its target type to be set as property value.
1159      *<p>
1160      * This feature is typically used to convert intermediate Jackson types
1161      * (that default deserializers can produce) into custom type instances.
1162      *<p>
1163      * Note also that this feature does not necessarily work well with polymorphic
1164      * type handling, or object identity handling; if such features are needed
1165      * an explicit deserializer is usually better way to handle deserialization.
1166      *
1167      * @param a Annotated property (field, method) or class to check for
1168      *   annotations
1169      *
1170      * @since 2.2
1171      */
findDeserializationConverter(Annotated a)1172     public Object findDeserializationConverter(Annotated a) {
1173         return null;
1174     }
1175 
1176     /**
1177      * Method for finding {@link Converter} that annotated property
1178      * has indicated needs to be used for values of container type
1179      * (this also means that method should only be called for properties
1180      * of container types, List/Map/array properties).
1181      *<p>
1182      * If not null, either has to be actual
1183      * {@link Converter} instance, or class for such converter;
1184      * and resulting converter will be used after Jackson has deserializer
1185      * data into intermediate type (Converter input type), and Converter
1186      * needs to convert this into its target type to be set as property value.
1187      *<p>
1188      * Other notes are same as those for {@link #findDeserializationConverter}
1189      *
1190      * @param a Annotated property (field, method) to check.
1191      *
1192      * @since 2.2
1193      */
findDeserializationContentConverter(AnnotatedMember a)1194     public Object findDeserializationContentConverter(AnnotatedMember a) {
1195         return null;
1196     }
1197 
1198     /*
1199     /**********************************************************
1200     /* Deserialization: type refinements
1201     /**********************************************************
1202      */
1203 
1204     /**
1205      * Method called to find out possible type refinements to use
1206      * for deserialization.
1207      *
1208      * @since 2.7
1209      */
refineDeserializationType(final MapperConfig<?> config, final Annotated a, final JavaType baseType)1210     public JavaType refineDeserializationType(final MapperConfig<?> config,
1211             final Annotated a, final JavaType baseType) throws JsonMappingException
1212     {
1213         return baseType;
1214     }
1215 
1216     /**
1217      * Method for accessing annotated type definition that a
1218      * property can have, to be used as the type for deserialization
1219      * instead of the static (declared) type.
1220      * Type is usually narrowing conversion (i.e.subtype of declared type).
1221      * Declared return type of the method is also considered acceptable.
1222      *
1223      * @param ann Annotated entity to introspect
1224      * @param baseType Assumed type before considering annotations
1225      *
1226      * @return Class to use for deserialization instead of declared type
1227      *
1228      * @deprecated Since 2.7 call {@link #refineDeserializationType} instead
1229      */
1230     @Deprecated
findDeserializationType(Annotated ann, JavaType baseType)1231     public Class<?> findDeserializationType(Annotated ann, JavaType baseType) {
1232         return null;
1233     }
1234 
1235     /**
1236      * Method for accessing additional narrowing type definition that a
1237      * method can have, to define more specific key type to use.
1238      * It should be only be used with {@link java.util.Map} types.
1239      *
1240      * @param ann Annotated entity to introspect
1241      * @param baseKeyType Assumed key type before considering annotations
1242      *
1243      * @return Class specifying more specific type to use instead of
1244      *   declared type, if annotation found; null if not
1245      *
1246      * @deprecated Since 2.7 call {@link #refineDeserializationType} instead
1247      */
1248     @Deprecated
findDeserializationKeyType(Annotated ann, JavaType baseKeyType)1249     public Class<?> findDeserializationKeyType(Annotated ann, JavaType baseKeyType) {
1250         return null;
1251     }
1252 
1253     /**
1254      * Method for accessing additional narrowing type definition that a
1255      * method can have, to define more specific content type to use;
1256      * content refers to Map values and Collection/array elements.
1257      * It should be only be used with Map, Collection and array types.
1258      *
1259      * @param ann Annotated entity to introspect
1260      * @param baseContentType Assumed content (value) type before considering annotations
1261      *
1262      * @return Class specifying more specific type to use instead of
1263      *   declared type, if annotation found; null if not
1264      *
1265      * @deprecated Since 2.7 call {@link #refineDeserializationType} instead
1266      */
1267     @Deprecated
findDeserializationContentType(Annotated ann, JavaType baseContentType)1268     public Class<?> findDeserializationContentType(Annotated ann, JavaType baseContentType) {
1269         return null;
1270     }
1271 
1272     /*
1273     /**********************************************************
1274     /* Deserialization: class annotations
1275     /**********************************************************
1276      */
1277 
1278     /**
1279      * Method getting {@link ValueInstantiator} to use for given
1280      * type (class): return value can either be an instance of
1281      * instantiator, or class of instantiator to create.
1282      *
1283      * @param ac Annotated class to introspect
1284      */
findValueInstantiator(AnnotatedClass ac)1285     public Object findValueInstantiator(AnnotatedClass ac) {
1286         return null;
1287     }
1288 
1289     /**
1290      * Method for finding Builder object to use for constructing
1291      * value instance and binding data (sort of combining value
1292      * instantiators that can construct, and deserializers
1293      * that can bind data).
1294      *<p>
1295      * Note that unlike accessors for some helper Objects, this
1296      * method does not allow returning instances: the reason is
1297      * that builders have state, and a separate instance needs
1298      * to be created for each deserialization call.
1299      *
1300      * @param ac Annotated class to introspect
1301      *
1302      * @since 2.0
1303      */
findPOJOBuilder(AnnotatedClass ac)1304     public Class<?> findPOJOBuilder(AnnotatedClass ac) {
1305         return null;
1306     }
1307 
1308     /**
1309      * @param ac Annotated class to introspect
1310      *
1311      * @since 2.0
1312      */
findPOJOBuilderConfig(AnnotatedClass ac)1313     public JsonPOJOBuilder.Value findPOJOBuilderConfig(AnnotatedClass ac) {
1314         return null;
1315     }
1316 
1317     /*
1318     /**********************************************************
1319     /* Deserialization: property annotations
1320     /**********************************************************
1321      */
1322 
1323     /**
1324      * Method for checking whether given property accessors (method,
1325      * field) has an annotation that suggests property name to use
1326      * for deserialization (reading JSON into POJOs).
1327      * Should return null if no annotation
1328      * is found; otherwise a non-null name (possibly
1329      * {@link PropertyName#USE_DEFAULT}, which means "use default heuristics").
1330      *
1331      * @param ann Annotated entity to check
1332      *
1333      * @return Name to use if found; null if not.
1334      *
1335      * @since 2.1
1336      */
findNameForDeserialization(Annotated ann)1337     public PropertyName findNameForDeserialization(Annotated ann) {
1338         return null;
1339     }
1340 
1341     /**
1342      * Method for checking whether given method has an annotation
1343      * that suggests that the method is to serve as "any setter";
1344      * method to be used for setting values of any properties for
1345      * which no dedicated setter method is found.
1346      *
1347      * @param ann Annotated entity to check
1348      *
1349      * @return True if such annotation is found (and is not disabled),
1350      *   false otherwise
1351      *
1352      * @since 2.9
1353      */
hasAnySetter(Annotated ann)1354     public Boolean hasAnySetter(Annotated ann) {
1355         return null;
1356     }
1357 
1358     /**
1359      * Method for finding possible settings for property, given annotations
1360      * on an accessor.
1361      *
1362      * @param ann Annotated entity to check
1363      *
1364      * @since 2.9
1365      */
findSetterInfo(Annotated ann)1366     public JsonSetter.Value findSetterInfo(Annotated ann) {
1367         return JsonSetter.Value.empty();
1368     }
1369 
1370     /**
1371      * Method for finding merge settings for property, if any.
1372      *
1373      * @param ann Annotated entity to check
1374      *
1375      * @since 2.9
1376      */
findMergeInfo(Annotated ann)1377     public Boolean findMergeInfo(Annotated ann) {
1378         return null;
1379     }
1380 
1381     /**
1382      * Method called to check whether potential Creator (constructor or static factory
1383      * method) has explicit annotation to indicate it as actual Creator; and if so,
1384      * which {@link com.fasterxml.jackson.annotation.JsonCreator.Mode} to use.
1385      *<p>
1386      * NOTE: caller needs to consider possibility of both `null` (no annotation found)
1387      * and {@link com.fasterxml.jackson.annotation.JsonCreator.Mode#DISABLED} (annotation found,
1388      * but disabled); latter is necessary as marker in case multiple introspectors are chained,
1389      * as well as possibly as when using mix-in annotations.
1390      *
1391      * @param config Configuration settings in effect (for serialization or deserialization)
1392      * @param ann Annotated accessor (usually constructor or static method) to check
1393      *
1394      * @since 2.9
1395      */
findCreatorAnnotation(MapperConfig<?> config, Annotated ann)1396     public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated ann) {
1397         // 13-Sep-2016, tatu: for backwards compatibility, implement using delegation
1398         ///   (remove from version AFTER 2.9)
1399         if (hasCreatorAnnotation(ann)) {
1400             JsonCreator.Mode mode = findCreatorBinding(ann);
1401             if (mode == null) {
1402                 mode = JsonCreator.Mode.DEFAULT;
1403             }
1404             return mode;
1405         }
1406         return null;
1407     }
1408 
1409     /**
1410      * Method for checking whether given annotated item (method, constructor)
1411      * has an annotation
1412      * that suggests that the method is a "creator" (aka factory)
1413      * method to be used for construct new instances of deserialized
1414      * values.
1415      *
1416      * @param ann Annotated entity to check
1417      *
1418      * @return True if such annotation is found (and is not disabled),
1419      *   false otherwise
1420      *
1421      * @deprecated Since 2.9 use {@link #findCreatorAnnotation} instead.
1422      */
1423     @Deprecated
hasCreatorAnnotation(Annotated ann)1424     public boolean hasCreatorAnnotation(Annotated ann) {
1425         return false;
1426     }
1427 
1428     /**
1429      * Method for finding indication of creator binding mode for
1430      * a creator (something for which {@link #hasCreatorAnnotation} returns
1431      * true), for cases where there may be ambiguity (currently: single-argument
1432      * creator with implicit but no explicit name for the argument).
1433      *
1434      * @param ann Annotated entity to check
1435      *
1436      * @since 2.5
1437      * @deprecated Since 2.9 use {@link #findCreatorAnnotation} instead.
1438      */
1439     @Deprecated
findCreatorBinding(Annotated ann)1440     public JsonCreator.Mode findCreatorBinding(Annotated ann) {
1441         return null;
1442     }
1443 
1444     /**
1445      * @param am Annotated method to check
1446      *
1447      * @deprecated Since 2.9 use {@link #hasAnySetter} instead.
1448      *
1449      * @return {@code true} if "any-setter" annotation was found; {@code false} otherwise
1450      */
1451     @Deprecated // since 2.9
hasAnySetterAnnotation(AnnotatedMethod am)1452     public boolean hasAnySetterAnnotation(AnnotatedMethod am) {
1453         return false;
1454     }
1455 
1456     /*
1457     /**********************************************************
1458     /* Overridable methods: may be used as low-level extension
1459     /* points.
1460     /**********************************************************
1461      */
1462 
1463     /**
1464      * Method that should be used by sub-classes for ALL
1465      * annotation access;
1466      * overridable so
1467      * that sub-classes may, if they choose to, mangle actual access to
1468      * block access ("hide" annotations) or perhaps change it.
1469      *<p>
1470      * Default implementation is simply:
1471      *<code>
1472      *  return annotated.getAnnotation(annoClass);
1473      *</code>
1474      *
1475      * @param ann Annotated entity to check for specified annotation
1476      * @param annoClass Type of annotation to find
1477      *
1478      * @return Value of given annotation (as per {@code annoClass}), if entity
1479      *    has one; {@code null} otherwise
1480      *
1481      * @since 2.5
1482      */
_findAnnotation(Annotated ann, Class<A> annoClass)1483     protected <A extends Annotation> A _findAnnotation(Annotated ann,
1484             Class<A> annoClass) {
1485         return ann.getAnnotation(annoClass);
1486     }
1487 
1488     /**
1489      * Method that should be used by sub-classes for ALL
1490      * annotation existence access;
1491      * overridable so  that sub-classes may, if they choose to, mangle actual access to
1492      * block access ("hide" annotations) or perhaps change value seen.
1493      *<p>
1494      * Default implementation is simply:
1495      *<code>
1496      *  return annotated.hasAnnotation(annoClass);
1497      *</code>
1498      *
1499      * @param ann Annotated entity to check for specified annotation
1500      * @param annoClass Type of annotation to find
1501      *
1502      * @return {@code true} if specified annotation exists in given entity; {@code false} if not
1503      *
1504      * @since 2.5
1505      */
_hasAnnotation(Annotated ann, Class<? extends Annotation> annoClass)1506     protected boolean _hasAnnotation(Annotated ann, Class<? extends Annotation> annoClass) {
1507         return ann.hasAnnotation(annoClass);
1508     }
1509 
1510     /**
1511      * Alternative lookup method that is used to see if annotation has at least one of
1512      * annotations of types listed in second argument.
1513      *
1514      * @param ann Annotated entity to check for specified annotation
1515      * @param annoClasses Types of annotation to find
1516      *
1517      * @return {@code true} if at least one of specified annotation exists in given entity;
1518      *    {@code false} otherwise
1519      *
1520      * @since 2.7
1521      */
_hasOneOf(Annotated ann, Class<? extends Annotation>[] annoClasses)1522     protected boolean _hasOneOf(Annotated ann, Class<? extends Annotation>[] annoClasses) {
1523         return ann.hasOneOf(annoClasses);
1524     }
1525 }
1526