Java源码示例:com.fasterxml.jackson.databind.type.MapLikeType

示例1
@Override
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config,
        MapLikeType type, BeanDescription beanDesc, JsonFormat.Value formatOverrides,
        JsonSerializer<Object> keySerializer,
        TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
{
    if (Multimap.class.isAssignableFrom(type.getRawClass())) {
        final AnnotationIntrospector intr = config.getAnnotationIntrospector();
        Object filterId = intr.findFilterId(config, (Annotated)beanDesc.getClassInfo());
        JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(Multimap.class,
                beanDesc.getClassInfo());
        Set<String> ignored = (ignorals == null) ? null : ignorals.getIgnored();
        return new MultimapSerializer(type, beanDesc,
                keySerializer, elementTypeSerializer, elementValueSerializer, ignored, filterId);
    }
    return null;
}
 
示例2
@Override
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type,
                                                   DeserializationConfig config, BeanDescription beanDesc,
                                                   KeyDeserializer keyDeserializer,
                                                   TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
        throws JsonMappingException
{
    Class<?> raw = type.getRawClass();
    if (Map.class.isAssignableFrom(raw)) {
        return new MapDeserializer(type, keyDeserializer, elementTypeDeserializer, elementDeserializer);
    }
    if (Multimap.class.isAssignableFrom(raw)) {
        return new MultimapDeserializer(type, keyDeserializer, elementTypeDeserializer, elementDeserializer);
    }
    return super.findMapLikeDeserializer(type, config, beanDesc, keyDeserializer, elementTypeDeserializer, elementDeserializer);
}
 
示例3
@Override
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config,
        MapLikeType type, BeanDescription beanDesc,
        JsonSerializer<Object> keySerializer,
        TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) {
    return findSerializer(config, type, beanDesc);
}
 
示例4
@Override
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc,
                                                   KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
                                                   JsonDeserializer<?> elementDeserializer) throws JsonMappingException {
    for (Deserializers deserializers : deserializersList) {
        JsonDeserializer<?> deserializer = deserializers.findMapLikeDeserializer(type, config, beanDesc, keyDeserializer, elementTypeDeserializer, elementDeserializer);
        if (deserializer != null) {
            return deserializer;
        }
    }
    return null;
}
 
示例5
public MultimapSerializer(MapLikeType type, BeanDescription beanDesc,
        JsonSerializer<Object> keySerializer, TypeSerializer vts,
        JsonSerializer<Object> valueSerializer,
        Set<String> ignoredEntries, Object filterId)
{
    super(type, null);
    _type = type;
    _keySerializer = keySerializer;
    _valueTypeSerializer = vts;
    _valueSerializer = valueSerializer;
    _ignoredEntries = ignoredEntries;
    _filterId = filterId;
    _sortKeys = false;
}
 
示例6
@Override
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config,
                                               MapLikeType type, BeanDescription beanDesc,
                                               JsonSerializer<Object> keySerializer,
                                               TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) {
    Class<?> raw = type.getRawClass();
    if (Map.class.isAssignableFrom(raw)) {
        return new MapSerializer(type);
    }
    if (Multimap.class.isAssignableFrom(raw)) {
        return new MultimapSerializer(type);
    }
    return super.findMapLikeSerializer(config, type, beanDesc, keySerializer, elementTypeSerializer, elementValueSerializer);
}
 
示例7
MaplikeDeserializer(MapLikeType mapType, KeyDeserializer keyDeserializer,
                    TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) {
    super(mapType);
    this.mapType = mapType;
    this.keyComparator = createKeyComparator(mapType.getKeyType());
    this.keyDeserializer = keyDeserializer;
    this.elementTypeDeserializer = elementTypeDeserializer;
    this.elementDeserializer = elementDeserializer;
}
 
示例8
/**
 * @since 2.2
 */
public JsonDeserializer<?> modifyMapLikeDeserializer(DeserializationConfig config,
        MapLikeType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
    return deserializer;
}
 
示例9
@Override
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc,
                                                   KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
                                                   JsonDeserializer<?> elementDeserializer) throws JsonMappingException {
    return getDeserializer(type.getRawClass());
}
 
示例10
@Override
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type,
        DeserializationConfig config, BeanDescription beanDesc,
        KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
        JsonDeserializer<?> elementDeserializer)
    throws JsonMappingException
{
    Class<?> raw = type.getRawClass();

    // ListMultimaps
    if (ListMultimap.class.isAssignableFrom(raw)) {
        if (ImmutableListMultimap.class.isAssignableFrom(raw)) {
            // TODO
        }
        if (ArrayListMultimap.class.isAssignableFrom(raw)) {
            return new ArrayListMultimapDeserializer(type, keyDeserializer,
                    elementTypeDeserializer, elementDeserializer);
        }
        if (LinkedListMultimap.class.isAssignableFrom(raw)) {
            return new LinkedListMultimapDeserializer(type, keyDeserializer,
                    elementTypeDeserializer, elementDeserializer);
        }
        if (ForwardingListMultimap.class.isAssignableFrom(raw)) {
            // TODO
        }

        // TODO: Remove the default fall-through once all implementations are in place.
        return new ArrayListMultimapDeserializer(type, keyDeserializer,
                elementTypeDeserializer, elementDeserializer);
    }

    // SetMultimaps
    if (SetMultimap.class.isAssignableFrom(raw)) {

        // SortedSetMultimap
        if (SortedSetMultimap.class.isAssignableFrom(raw)) {
            if (TreeMultimap.class.isAssignableFrom(raw)) {
                // TODO
            }
            if (ForwardingSortedSetMultimap.class.isAssignableFrom(raw)) {
                // TODO
            }
        }

        if (ImmutableSetMultimap.class.isAssignableFrom(raw)) {
            // [#67]: Preserve order of entries
            return new LinkedHashMultimapDeserializer(type, keyDeserializer,
                    elementTypeDeserializer, elementDeserializer);
        }
        if (HashMultimap.class.isAssignableFrom(raw)) {
            return new HashMultimapDeserializer(type, keyDeserializer, elementTypeDeserializer,
                    elementDeserializer);
        }
        if (LinkedHashMultimap.class.isAssignableFrom(raw)) {
            return new LinkedHashMultimapDeserializer(type, keyDeserializer,
                    elementTypeDeserializer, elementDeserializer);
        }
        if (ForwardingSetMultimap.class.isAssignableFrom(raw)) {
            // TODO
        }

        // TODO: Remove the default fall-through once all implementations are covered.
        return new HashMultimapDeserializer(type, keyDeserializer, elementTypeDeserializer,
                elementDeserializer);
    }

    // Handle the case where nothing more specific was provided.
    if (Multimap.class.isAssignableFrom(raw)) {
        return new LinkedListMultimapDeserializer(type, keyDeserializer,
                elementTypeDeserializer, elementDeserializer);
    }

    if (Table.class.isAssignableFrom(raw)) {
        // !!! TODO
    }

    return null;
}
 
示例11
@Override
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) {
    return forJavaType(type);
}
 
示例12
MapSerializer(MapLikeType mapType, BeanProperty beanProperty) {
    super(mapType, beanProperty);
    this.mapType = mapType;
}
 
示例13
MapSerializer(MapLikeType mapType) {
    this(mapType, null);
}
 
示例14
MultimapSerializer(MapLikeType mapType) {
    this(mapType, null);
}
 
示例15
MultimapSerializer(MapLikeType mapType, BeanProperty beanProperty) {
    super(mapType, beanProperty);
    this.mapType = mapType;
}
 
示例16
MapDeserializer(MapLikeType mapType, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
                JsonDeserializer<?> elementDeserializer) {
    super(mapType, keyDeserializer, elementTypeDeserializer, elementDeserializer);
}
 
示例17
MultimapDeserializer(MapLikeType mapType, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
                     JsonDeserializer<?> elementDeserializer) {
    super(mapType, keyDeserializer, elementTypeDeserializer, elementDeserializer);
}