com.fasterxml.jackson.databind.type.MapLikeType Java Examples

The following examples show how to use com.fasterxml.jackson.databind.type.MapLikeType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VavrDeserializers.java    From vavr-jackson with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: GuavaSerializers.java    From jackson-datatypes-collections with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: MaplikeDeserializer.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: CompositeDeserializers.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #5
Source File: MultimapSerializer.java    From jackson-datatypes-collections with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: SimpleSerializers.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config,
        MapLikeType type, BeanDescription beanDesc,
        JsonSerializer<Object> keySerializer,
        TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) {
    return findSerializer(config, type, beanDesc);
}
 
Example #7
Source File: VavrSerializers.java    From vavr-jackson with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: MapSerializer.java    From vavr-jackson with Apache License 2.0 4 votes vote down vote up
MapSerializer(MapLikeType mapType, BeanProperty beanProperty) {
    super(mapType, beanProperty);
    this.mapType = mapType;
}
 
Example #9
Source File: MultimapDeserializer.java    From vavr-jackson with Apache License 2.0 4 votes vote down vote up
MultimapDeserializer(MapLikeType mapType, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
                     JsonDeserializer<?> elementDeserializer) {
    super(mapType, keyDeserializer, elementTypeDeserializer, elementDeserializer);
}
 
Example #10
Source File: MapDeserializer.java    From vavr-jackson with Apache License 2.0 4 votes vote down vote up
MapDeserializer(MapLikeType mapType, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
                JsonDeserializer<?> elementDeserializer) {
    super(mapType, keyDeserializer, elementTypeDeserializer, elementDeserializer);
}
 
Example #11
Source File: MultimapSerializer.java    From vavr-jackson with Apache License 2.0 4 votes vote down vote up
MultimapSerializer(MapLikeType mapType, BeanProperty beanProperty) {
    super(mapType, beanProperty);
    this.mapType = mapType;
}
 
Example #12
Source File: MultimapSerializer.java    From vavr-jackson with Apache License 2.0 4 votes vote down vote up
MultimapSerializer(MapLikeType mapType) {
    this(mapType, null);
}
 
Example #13
Source File: MapSerializer.java    From vavr-jackson with Apache License 2.0 4 votes vote down vote up
MapSerializer(MapLikeType mapType) {
    this(mapType, null);
}
 
Example #14
Source File: ConvertingDeserializers.java    From graphql-spqr with Apache License 2.0 4 votes vote down vote up
@Override
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) {
    return forJavaType(type);
}
 
Example #15
Source File: GuavaDeserializers.java    From jackson-datatypes-collections with Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example #16
Source File: AssignableFromDeserializers.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc,
                                                   KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer,
                                                   JsonDeserializer<?> elementDeserializer) throws JsonMappingException {
    return getDeserializer(type.getRawClass());
}
 
Example #17
Source File: BeanDeserializerModifier.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @since 2.2
 */
public JsonDeserializer<?> modifyMapLikeDeserializer(DeserializationConfig config,
        MapLikeType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
    return deserializer;
}