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

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

Introduction

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

Prototype

public boolean isCollectionLikeType() 

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));
        }/*from w w w  .j a  v a  2  s.  com*/
    }
    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;/* www.  j a va 2  s .c om*/
        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;
}