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

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

Introduction

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

Prototype

public int containedTypeCount() 

Source Link

Usage

From source file:javaslang.jackson.datatype.deserialize.MaplikeDeserializer.java

private static MapLikeType mapLike(JavaType type, DeserializationContext ctxt) {
    JavaType keyType = type.containedTypeCount() > 0 ? type.containedType(0) : TypeFactory.unknownType();
    JavaType valueType = type.containedTypeCount() > 1 ? type.containedType(1) : TypeFactory.unknownType();
    return ctxt.getTypeFactory().constructMapLikeType(type.getRawClass(), keyType, valueType);
}

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

@Override
public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config,
        BeanDescription beanDesc) throws JsonMappingException {
    if (type.getRawClass() == DBRef.class) {
        if (type.containedTypeCount() != 2) {
            throw new JsonMappingException("Property doesn't declare object and key type");
        }/*from w  w  w  .  j  a  va 2  s  .  c om*/
        JavaType objectType = type.containedType(0);
        JavaType keyType = type.containedType(1);
        return new DBRefDeserializer(objectType, keyType);
    }
    return super.findBeanDeserializer(type, config, beanDesc);
}