• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.deser;
2 
3 import com.fasterxml.jackson.databind.DeserializationContext;
4 import com.fasterxml.jackson.databind.JsonMappingException;
5 
6 /**
7  * Interface used to indicate deserializers that want to do post-processing
8  * after construction but before being returned to caller (and possibly cached)
9  * and used.
10  * This is typically used to resolve references
11  * to other contained types; for example, bean deserializers use this callback
12  * to locate deserializers for contained field types.
13  * Main reason for using a callback (instead of trying to resolve dependencies
14  * immediately) is to make it possible to cleanly handle self-references;
15  * otherwise it would be easy to get into infinite recursion.
16  *<p>
17  * Note that {@link #resolve} method does NOT allow returning anything
18  * (specifically, a new deserializer instance): reason for this is that
19  * allowing this would not work with proper handling of cyclic dependencies,
20  * which are resolved by two-phase processing, where initially constructed
21  * deserializer is added as known deserializer, and only after this
22  * resolution is done. Resolution is the part that results in lookups for
23  * dependant deserializers, which may include handling references to
24  * deserializer itself.
25  *<p>
26  * Note that in cases where deserializer needs both contextualization and
27  * resolution -- that is, implements both this interface and {@link ContextualDeserializer}
28  * -- resolution via this interface occurs first, and contextual
29  * resolution (using {@link ContextualDeserializer}) later on.
30  */
31 public interface ResolvableDeserializer
32 {
33     /**
34      * Method called after deserializer instance has been constructed
35      * (and registered as necessary by provider objects),
36      * but before it has returned it to the caller.
37      * Called object can then resolve its dependencies to other types,
38      * including self-references (direct or indirect).
39      *
40      * @param ctxt Context to use for accessing configuration, resolving
41      *    secondary deserializers
42      */
resolve(DeserializationContext ctxt)43     public abstract void resolve(DeserializationContext ctxt)
44         throws JsonMappingException;
45 }
46