return deser;
}
// If not, any type modifiers? (@JsonDeserialize.as)
type = modifyTypeByAnnotation(config, beanDesc.getClassInfo(), type, null);
JavaType contentType = type.getContentType();
// Very first thing: is deserializer hard-coded for elements?
JsonDeserializer<Object> contentDeser = contentType.getValueHandler();
// Then optional type info (1.5): if type has been resolved, we may already know type deserializer:
TypeDeserializer contentTypeDeser = contentType.getTypeHandler();
// but if not, may still be possible to find:
if (contentTypeDeser == null) {
contentTypeDeser = findTypeDeserializer(config, contentType, property);
}
// 23-Nov-2010, tatu: Custom deserializer?
JsonDeserializer<?> custom = _findCustomCollectionDeserializer(type, config, p, beanDesc, property,
contentTypeDeser, contentDeser);
if (custom != null) {
return custom;
}
if (contentDeser == null) { // not defined by annotation
// One special type: EnumSet:
if (EnumSet.class.isAssignableFrom(collectionClass)) {
return new EnumSetDeserializer(contentType.getRawClass(),
createEnumDeserializer(config, p, contentType, property));
}
// But otherwise we can just use a generic value deserializer:
// 'null' -> collections have no referring fields
contentDeser = p.findValueDeserializer(config, contentType, property);
}
/* One twist: if we are being asked to instantiate an interface or
* abstract Collection, we need to either find something that implements
* the thing, or give up.
*
* Note that we do NOT try to guess based on secondary interfaces
* here; that would probably not work correctly since casts would
* fail later on (as the primary type is not the interface we'd
* be implementing)
*/
if (type.isInterface() || type.isAbstract()) {
@SuppressWarnings({ "rawtypes" })
Class<? extends Collection> fallback = _collectionFallbacks.get(collectionClass.getName());
if (fallback == null) {
throw new IllegalArgumentException("Can not find a deserializer for non-concrete Collection type "+type);
}
collectionClass = fallback;
type = (CollectionType) config.constructSpecializedType(type, collectionClass);
// But if so, also need to re-check creators...
beanDesc = config.introspectForCreation(type);
}
ValueInstantiator inst = findValueInstantiator(config, beanDesc);
// 13-Dec-2010, tatu: Can use more optimal deserializer if content type is String, so:
if (contentType.getRawClass() == String.class) {
// no value type deserializer because Strings are one of natural/native types:
return new StringCollectionDeserializer(type, contentDeser, inst);
}
return new CollectionDeserializer(type, contentDeser, contentTypeDeser, inst);
}