Example usage for com.fasterxml.jackson.databind JavaType isMapLikeType

List of usage examples for com.fasterxml.jackson.databind JavaType isMapLikeType

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JavaType isMapLikeType.

Prototype

public boolean isMapLikeType() 

Source Link

Usage

From source file:org.mongojack.internal.MongoAnnotationIntrospector.java

@Override
public JsonDeserializer findContentDeserializer(Annotated am) {
    if (am.hasAnnotation(ObjectId.class)) {
        JavaType type = typeFactory.constructType(am.getGenericType());
        if (type.isCollectionLikeType()) {
            return findObjectIdDeserializer(type.containedType(0));
        } else if (type.isMapLikeType()) {
            return findObjectIdDeserializer(type.containedType(1));
        }/* w  ww .j ava  2s.c  om*/
    }
    return null;
}

From source file:org.mongojack.internal.MongoAnnotationIntrospector.java

public JsonDeserializer findObjectIdDeserializer(JavaType type) {
    if (type.getRawClass() == String.class) {
        return new ObjectIdDeserializers.ToStringDeserializer();
    } else if (type.getRawClass() == byte[].class) {
        return new ObjectIdDeserializers.ToByteArrayDeserializer();
    } else if (type.getRawClass() == DBRef.class) {
        JavaType dbRefType;/*from w  ww. ja  va 2 s. co m*/
        if (type.isContainerType()) {
            if (type.isCollectionLikeType()) {
                dbRefType = type.containedType(0);
            } else if (type.isMapLikeType()) {
                dbRefType = type.containedType(1);
            } else {
                return null;
            }
        } else {
            dbRefType = type;
        }
        JsonDeserializer keyDeserializer = findObjectIdDeserializer(dbRefType.containedType(1));
        return new DBRefDeserializer(dbRefType.containedType(0), dbRefType.containedType(1), keyDeserializer);
    } else if (type.getRawClass() == org.bson.types.ObjectId.class) {
        // Don't know why someone would annotated an ObjectId with
        // @ObjectId, but handle it
        return new ObjectIdDeserializers.ToObjectIdDeserializer();
    }
    return null;
}