Refine search
@Override public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, final BeanDescription beanDesc) throws JsonMappingException { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); // 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); } JsonDeserializer<?> deser = _findCustomCollectionLikeDeserializer(type, config, beanDesc, contentTypeDeser, contentDeser); if (deser != null) { // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyCollectionLikeDeserializer(config, type, beanDesc, deser); } } } return deser; }
@Override public CollectionLikeType withContentValueHandler(Object h) { return new CollectionLikeType(_class, _bindings, _superClass, _superInterfaces, _elementType.withValueHandler(h), _valueHandler, _typeHandler, _asStatic); }
@Override public StringBuilder getGenericSignature(StringBuilder sb) { _classSignature(_class, sb, false); sb.append('<'); _elementType.getGenericSignature(sb); sb.append(">;"); return sb; }
/** * @deprecated Since 2.7, use {@link #upgradeFrom} for constructing instances, given * pre-resolved {@link SimpleType}. */ @Deprecated // since 2.7 public static CollectionLikeType construct(Class<?> rawType, JavaType elemT) { // First: may need to fabricate TypeBindings (needed for refining into // concrete collection types, as per [databind#1102]) TypeVariable<?>[] vars = rawType.getTypeParameters(); TypeBindings bindings; if ((vars == null) || (vars.length != 1)) { bindings = TypeBindings.emptyBindings(); } else { bindings = TypeBindings.create(rawType, elemT); } return new CollectionLikeType(rawType, bindings, _bogusSuperClass(rawType), null, elemT, null, null, false); }
if (type.isEnumType()) { return factory.createEnumDeserializer(ctxt, type, beanDesc); if (type.isContainerType()) { if (type.isArrayType()) { return factory.createArrayDeserializer(ctxt, (ArrayType) type, beanDesc); if ((format == null) || format.getShape() != JsonFormat.Shape.OBJECT) { MapLikeType mlt = (MapLikeType) type; if (mlt.isTrueMapType()) { return factory.createMapDeserializer(ctxt,(MapType) mlt, beanDesc); if ((format == null) || format.getShape() != JsonFormat.Shape.OBJECT) { CollectionLikeType clt = (CollectionLikeType) type; if (clt.isTrueCollectionType()) { return factory.createCollectionDeserializer(ctxt, (CollectionType) clt, beanDesc);
if (!staticTyping && type.useStaticType()) { if (!type.isContainerType() || !type.getContentType().isJavaLangObject()) { staticTyping = true; if (mlt.isTrueMapType()) { return buildMapSerializer(prov, (MapType) mlt, beanDesc, staticTyping, keySerializer, elementTypeSerializer, elementValueSerializer); if (type.isCollectionLikeType()) { CollectionLikeType clt = (CollectionLikeType) type; if (clt.isTrueCollectionType()) { return buildCollectionSerializer(prov, (CollectionType) clt, beanDesc, staticTyping, elementTypeSerializer, elementValueSerializer);
@Override public JavaType narrowContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _elementType.getRawClass()) { return this; } return new CollectionLikeType(_class, _elementType.narrowBy(contentClass), _valueHandler, _typeHandler); }
@Override public JavaType modifyType(JavaType type, Type jdkType, TypeBindings bindings, TypeFactory typeFactory) { final Class<?> raw = type.getRawClass(); if (Seq.class.isAssignableFrom(raw) && CharSeq.class != raw) { return CollectionLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (Set.class.isAssignableFrom(raw)) { return CollectionLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (PriorityQueue.class.isAssignableFrom(raw)) { return CollectionLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (Map.class.isAssignableFrom(raw)) { return MapLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0), type.containedTypeOrUnknown(1)); } if (Multimap.class.isAssignableFrom(raw)) { return MapLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0), type.containedTypeOrUnknown(1)); } if (Lazy.class.isAssignableFrom(raw)) { return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (Option.class.isAssignableFrom(raw)) { return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } return type; } }
/** * Same as {@link #getType(com.fasterxml.jackson.databind.type.SimpleType)} * * @param jacksonType * @return */ public Type getType(CollectionLikeType jacksonType) { // try { String signature = JacksonSignature.createSignature(jacksonType); JavaType contentType = jacksonType.getContentType(); String contentSignature = JacksonSignature.createSignature(contentType); Class<?> containerClass = jacksonType.getRawClass(); CollectionTypeJrapidoc type = new CollectionTypeJrapidoc(containerClass.getName(), signature, contentType.getRawClass().getName(), contentSignature); if (cache.containsKey(signature)) { return cache.get(signature); } cache.put(signature, type); getType(jacksonType.getContentType()); return type; }
@Override public JavaType widenContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _elementType.getRawClass()) { return this; } return new CollectionLikeType(_class, _elementType.widenBy(contentClass), _valueHandler, _typeHandler, _asStatic); }
JavaType elementType = type.getContentType(); TypeSerializer elementTypeSerializer = createTypeSerializer(config, elementType); beanDesc.getClassInfo(), property); if (type.isMapLikeType()) { // implements java.util.Map MapLikeType mlt = (MapLikeType) type; JsonSerializer<Object> keySerializer = _findKeySerializer(prov, beanDesc.getClassInfo(), property); if (mlt.isTrueMapType()) { return buildMapSerializer(config, (MapType) mlt, beanDesc, staticTyping, keySerializer, elementTypeSerializer, elementValueSerializer); if (type.isCollectionLikeType()) { CollectionLikeType clt = (CollectionLikeType) type; if (clt.isTrueCollectionType()) { // only have custom ones, if any: return buildCollectionSerializer(config, (CollectionType) clt, beanDesc, property, staticTyping, elementTypeSerializer, elementValueSerializer);
@Override public CollectionLikeType withContentTypeHandler(Object h) { return new CollectionLikeType(_class, _bindings, _superClass, _superInterfaces, _elementType.withTypeHandler(h), _valueHandler, _typeHandler, _asStatic); }
@Override public CollectionLikeType withTypeHandler(Object h) { return new CollectionLikeType(_class, _bindings, _superClass, _superInterfaces, _elementType, _valueHandler, h, _asStatic); }
@Override public CollectionLikeType withStaticTyping() { if (_asStatic) { return this; } return new CollectionLikeType(_class, _bindings, _superClass, _superInterfaces, _elementType.withStaticTyping(), _valueHandler, _typeHandler, true); }
@Override public StringBuilder getErasedSignature(StringBuilder sb) { return _classSignature(_class, sb, true); }
public JsonDeserializer<?> findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); }
@Override JavaType emulatedJavaType(JavaType type, TypeFactory typeFactory) { CollectionLikeType collectionLikeType = (CollectionLikeType) type; return typeFactory.constructCollectionType(ArrayList.class, collectionLikeType.getContentType()); }
/** * Method for constructing a {@link CollectionLikeType}. *<p> * NOTE: type modifiers are NOT called on constructed type itself; but are called * for contained types. */ public CollectionLikeType constructCollectionLikeType(Class<?> collectionClass, JavaType elementType) { return CollectionLikeType.construct(collectionClass, elementType); }
/** * Method for constructing a {@link CollectionLikeType}. *<p> * NOTE: type modifiers are NOT called on constructed type itself; but are called * for contained types. */ public CollectionLikeType constructCollectionLikeType(Class<?> collectionClass, JavaType elementType) { JavaType type = _fromClass(null, collectionClass, TypeBindings.createIfNeeded(collectionClass, elementType)); if (type instanceof CollectionLikeType) { return (CollectionLikeType) type; } return CollectionLikeType.upgradeFrom(type, elementType); }
if (type.isEnumType()) { return factory.createEnumDeserializer(ctxt, type, beanDesc); if (type.isContainerType()) { if (type.isArrayType()) { return factory.createArrayDeserializer(ctxt, (ArrayType) type, beanDesc); if (type.isMapLikeType()) { MapLikeType mlt = (MapLikeType) type; if (mlt.isTrueMapType()) { return factory.createMapDeserializer(ctxt,(MapType) mlt, beanDesc); if (format == null || format.getShape() != JsonFormat.Shape.OBJECT) { CollectionLikeType clt = (CollectionLikeType) type; if (clt.isTrueCollectionType()) { return factory.createCollectionDeserializer(ctxt, (CollectionType) clt, beanDesc);