Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.jsontype;
  
  
Interface that defines builders that are configured based on annotations (like com.fasterxml.jackson.annotation.JsonTypeInfo or JAXB annotations), and produce type serializers and deserializers used for handling type information embedded in JSON to allow for safe polymorphic type handling.

Builder is first initialized by calling init(com.fasterxml.jackson.annotation.JsonTypeInfo.Id,com.fasterxml.jackson.databind.jsontype.TypeIdResolver) method, and then configured using setXxx (and registerXxx) methods. Finally, after calling all configuration methods, buildTypeSerializer(com.fasterxml.jackson.databind.SerializationConfig,com.fasterxml.jackson.databind.JavaType,java.util.Collection) or buildTypeDeserializer(com.fasterxml.jackson.databind.DeserializationConfig,com.fasterxml.jackson.databind.JavaType,java.util.Collection) will be called to get actual type resolver constructed and used for resolving types for configured base type and its subtypes.

Note that instances are used for two related but distinct use cases:

  • To create builders to use with explicit type information inclusion (usually via @JsonTypeInfo annotation)
  • To create builders when "default typing" is used; if so, type information is automatically included for certain kind of types, regardless of annotations
Important distinction between the cases is that in first case, calls to create builders are only made when builders are certainly needed; whereas in second case builder has to first verify whether type information is applicable for given type, and if not, just return null to indicate this.

Author(s):
tatu
 
 public interface TypeResolverBuilder<T extends TypeResolverBuilder<T>>
 {
     /*
     /**********************************************************
     /* Accessors
     /**********************************************************
      */

    
Accessor for currently configured default type; implementation class that may be used in case no valid type information is available during type resolution
 
     public Class<?> getDefaultImpl();
     
     /*
     /**********************************************************
     /* Actual builder methods
     /**********************************************************
      */

    
Method for building type serializer based on current configuration of this builder.

Parameters:
baseType Base type that constructed resolver will handle; super type of all types it will be used for.
 
             JavaType baseTypeCollection<NamedTypesubtypes);

    
Method for building type deserializer based on current configuration of this builder.

Parameters:
baseType Base type that constructed resolver will handle; super type of all types it will be used for.
subtypes Known subtypes of the base type.
 
             JavaType baseTypeCollection<NamedTypesubtypes);
     
     /*
     /**********************************************************
     /* Initialization method(s) that must be called before other
     /* configuration
     /**********************************************************
      */

    
Initialization method that is called right after constructing the builder instance.

Parameters:
idType Which type metadata is used
res (optional) Custom type id resolver used, if any
Returns:
Resulting builder instance (usually this builder, but not necessarily)
    public T init(JsonTypeInfo.Id idTypeTypeIdResolver res);
    
    /*
    /**********************************************************
    /* Methods for configuring resolver to build 
    /**********************************************************
     */
    
    
Method for specifying mechanism to use for including type metadata in JSON. If not explicitly called, setting defaults to com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY.

Parameters:
includeAs Mechanism used for including type metadata in JSON
Returns:
Resulting builder instance (usually this builder, but not necessarily)
    public T inclusion(As includeAs);

    
Method for specifying name of property used for including type information. Not used for all inclusion mechanisms; usually only used with com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY.

If not explicitly called, name of property to use is based on defaults for com.fasterxml.jackson.annotation.JsonTypeInfo.Id configured.

Parameters:
propName Name of JSON property to use for including type information
Returns:
Resulting builder instance (usually this builder, but not necessarily)
    public T typeProperty(String propName);

    
Method for specifying default implementation to use if type id is either not available, or can not be resolved.
    public T defaultImpl(Class<?> defaultImpl);

    
Method for specifying whether type id should be visible to com.fasterxml.jackson.databind.JsonDeserializers or not.

Since:
2.0
    public T typeIdVisibility(boolean isVisible);
New to GrepCode? Check out our FAQ X