Top Fields Constructors Methods
tools.jackson.datatype.guava.deser.multimap

public abstract Class GuavaMultimapDeserializer<T extends Multimap<Object, Object>>

extends ContainerDeserializerBase<T extends Multimap<Object, Object>>
Class Inheritance
Known Direct Subclasses
tools.jackson.datatype.guava.deser.multimap.list.ArrayListMultimapDeserializer, tools.jackson.datatype.guava.deser.multimap.list.LinkedListMultimapDeserializer, tools.jackson.datatype.guava.deser.multimap.set.HashMultimapDeserializer, tools.jackson.datatype.guava.deser.multimap.set.LinkedHashMultimapDeserializer
Imports
java.lang.reflect.InvocationTargetException, .Method, java.util.List, tools.jackson.core.JacksonException, .JsonParser, .JsonToken, tools.jackson.databind.*, tools.jackson.databind.deser.NullValueProvider, tools.jackson.databind.deser.std.ContainerDeserializerBase, tools.jackson.databind.jsontype.TypeDeserializer, tools.jackson.databind.type.LogicalType, com.google.common.collect.ImmutableList, .LinkedListMultimap, .ListMultimap, .Multimap

Author
mvolkhart

Field Summary

Modifier and TypeField and Description
private final KeyDeserializer
private final ValueDeserializer<Object>
private final TypeDeserializer
private final Method
creatorMethod

Since we have to use a method to transform from a known multi-map type into actual one, we'll resolve method just once, use it.

private static final List<String>
Inherited from tools.jackson.databind.deser.std.ContainerDeserializerBase:
_containerType_nullProvider_skipNullValues_unwrapSingle

Constructor Summary

AccessConstructor and Description
public
GuavaMultimapDeserializer(JavaType type, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer<?> elementDeserializer)

public
GuavaMultimapDeserializer(JavaType type, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer<?> elementDeserializer, Method creatorMethod, NullValueProvider nvp)

Method Summary

Modifier and TypeMethod and Description
protected abstract ValueDeserializer<?>
public ValueDeserializer<?>
createContextual(DeserializationContext ctxt, BeanProperty property)

Overrides tools.jackson.databind.ValueDeserializer.createContextual.

We need to use this method to properly handle possible contextual variants of key and value deserializers, as well as type deserializers.

protected abstract T
public T
deserialize(JsonParser p, DeserializationContext ctxt)

Implements abstract tools.jackson.databind.ValueDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles.

private T
private T
private void
private static Method
findTransformer(Class<?> rawType)

public ValueDeserializer<Object>
getContentDeserializer()

Implements abstract tools.jackson.databind.deser.std.ContainerDeserializerBase.getContentDeserializer.

Accesor for deserializer use for deserializing content values.

private Object
public LogicalType
logicalType()

Overrides tools.jackson.databind.ValueDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces.

Inherited from tools.jackson.databind.deser.std.ContainerDeserializerBase:
findBackReferencegetContentTypegetEmptyAccessPatterngetEmptyValuegetValueTypesupportsUpdatewrapAndThrow

Field Detail

_keyDeserializerback to summary
private final KeyDeserializer _keyDeserializer
_valueDeserializerback to summary
private final ValueDeserializer<Object> _valueDeserializer
_valueTypeDeserializerback to summary
private final TypeDeserializer _valueTypeDeserializer
creatorMethodback to summary
private final Method creatorMethod

Since we have to use a method to transform from a known multi-map type into actual one, we'll resolve method just once, use it. Note that if this is set to null, we can just construct a com.google.common.collect.LinkedListMultimap instance and be done with it.

METHOD_NAMESback to summary
private static final List<String> METHOD_NAMES

Constructor Detail

GuavaMultimapDeserializerback to summary
public GuavaMultimapDeserializer(JavaType type, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer<?> elementDeserializer)
GuavaMultimapDeserializerback to summary
public GuavaMultimapDeserializer(JavaType type, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer<?> elementDeserializer, Method creatorMethod, NullValueProvider nvp)
Annotations
@SuppressWarnings:unchecked

Method Detail

_createContextualback to summary
protected abstract ValueDeserializer<?> _createContextual(JavaType t, KeyDeserializer kd, TypeDeserializer vtd, ValueDeserializer<?> vd, Method method, NullValueProvider np)
createContextualback to summary
public ValueDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property)

Overrides tools.jackson.databind.ValueDeserializer.createContextual.

We need to use this method to properly handle possible contextual variants of key and value deserializers, as well as type deserializers.

Annotations
@Override
createMultimapback to summary
protected abstract T createMultimap()
deserializeback to summary
public T deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException

Implements abstract tools.jackson.databind.ValueDeserializer.deserialize.

Doc from tools.jackson.databind.ValueDeserializer.deserialize.

Method that can be called to ask implementation to deserialize JSON content into the value type this serializer handles. Returned instance is to be constructed by method itself.

Pre-condition for this method is that the parser points to the first event that is part of value to deserializer (and which is never JSON 'null' literal, more on this below): for simple types it may be the only value; and for structured types the Object start marker or a FIELD_NAME.

The two possible input conditions for structured types result from polymorphism via fields. In the ordinary case, Jackson calls this method when it has encountered an OBJECT_START, and the method implementation must advance to the next token to see the first field name. If the application configures polymorphism via a field, then the object looks like the following.

      {
          "@class": "class name",
          ...
      }
  
Jackson consumes the two tokens (the @class field name and its value) in order to learn the class and select the deserializer. Thus, the stream is pointing to the FIELD_NAME for the first field after the @class. Thus, if you want your method to work correctly both with and without polymorphism, you must begin your method with:
       if (p.currentToken() == JsonToken.START_OBJECT) {
         p.nextToken();
       }
  
This results in the stream pointing to the field name, so that the two conditions align.

Post-condition is that the parser will point to the last event that is part of deserialized value (or in case deserialization fails, event that was not recognized or usable, which may be the same event as the one it pointed to upon call).

Handling null values (JsonToken.VALUE_NULL)
: Note that this method is never called for the JSON null literal to avoid every deserializer from having to handle null values. Instead, the ValueDeserializer#getNullValue(DeserializationContext) method is called to produce a null value. To influence null handling, custom deserializers should override ValueDeserializer#getNullValue(DeserializationContext) and usually also ValueDeserializer#getNullAccessPattern().

Annotations
@Override
deserializeContentsback to summary
private T deserializeContents(JsonParser p, DeserializationContext ctxt) throws JacksonException
deserializeFromSingleValueback to summary
private T deserializeFromSingleValue(JsonParser p, DeserializationContext ctxt) throws JacksonException
expectback to summary
private void expect(DeserializationContext ctxt, JsonParser p, JsonToken token)
findTransformerback to summary
private static Method findTransformer(Class<?> rawType)
getContentDeserializerback to summary
public ValueDeserializer<Object> getContentDeserializer()

Implements abstract tools.jackson.databind.deser.std.ContainerDeserializerBase.getContentDeserializer.

Doc from tools.jackson.databind.deser.std.ContainerDeserializerBase.getContentDeserializer.

Accesor for deserializer use for deserializing content values.

Annotations
@Override
getCurrentTokenValueback to summary
private Object getCurrentTokenValue(JsonParser p, DeserializationContext ctxt)
logicalTypeback to summary
public LogicalType logicalType()

Overrides tools.jackson.databind.ValueDeserializer.logicalType.

Doc from tools.jackson.databind.ValueDeserializer.logicalType.

Method for accessing logical type of values this deserializer produces. Typically used for further configuring handling of values, for example, to find which coercions are legal.

Annotations
@Override