Refine search
return null; Class<?> raw = type.getRawClass(); if (EnumSet.class.isAssignableFrom(raw)) { JavaType enumType = type.getContentType(); if (!enumType.isEnumType()) { enumType = null; Class<?> elementRaw = type.getContentType().getRawClass(); if (isIndexedList(raw)) { if (elementRaw == String.class) { if (ClassUtil.isJacksonStdImpl(elementValueSerializer)) { ser = IndexedStringListSerializer.instance; ser = buildIndexedListSerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer); if (ClassUtil.isJacksonStdImpl(elementValueSerializer)) { ser = StringCollectionSerializer.instance; ser = buildCollectionSerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer);
private JavaType _collectionType(Class<?> rawClass, TypeBindings bindings, JavaType superClass, JavaType[] superInterfaces) { List<JavaType> typeParams = bindings.getTypeParameters(); // ok to have no types ("raw") JavaType ct; if (typeParams.isEmpty()) { ct = _unknownType(); } else if (typeParams.size() == 1) { ct = typeParams.get(0); } else { throw new IllegalArgumentException("Strange Collection type "+rawClass.getName()+": cannot determine type parameters"); } return CollectionType.construct(rawClass, bindings, superClass, superInterfaces, ct); }
@Override public CollectionType withContentTypeHandler(Object h) { return new CollectionType(_class, _bindings, _superClass, _superInterfaces, _elementType.withTypeHandler(h), _valueHandler, _typeHandler, _asStatic); }
/** * @deprecated Since 2.7, remove from 2.9 */ @Deprecated // since 2.7 public static CollectionType 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 CollectionType(rawType, bindings, // !!! TODO: Wrong, does have supertypes, but: _bogusSuperClass(rawType), null, elemT, null, null, false); }
throws JsonMappingException JavaType contentType = type.getContentType(); JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); config, beanDesc, contentTypeDeser, contentDeser); if (deser == null) { Class<?> collectionClass = type.getRawClass(); if (contentDeser == null) { // not defined by annotation if (type.isInterface() || type.isAbstract()) { CollectionType implType = _mapAbstractCollectionType(type, config); if (implType == null) { if (type.getTypeHandler() == null) { throw new IllegalArgumentException("Cannot find a deserializer for non-concrete Collection type "+type); if (!inst.canCreateUsingDefault()) { if (type.hasRawClass(ArrayBlockingQueue.class)) { return new ArrayBlockingQueueDeserializer(type, contentDeser, contentTypeDeser, inst); if (contentType.hasRawClass(String.class)) {
Class<?> enumClass = ClassUtil.findEnumType((EnumSet<?>) value); str = typeFactory.constructCollectionType(EnumSet.class, enumClass).toCanonical(); } else if (value instanceof EnumMap<?,?>) { Class<?> enumClass = ClassUtil.findEnumType((EnumMap<?,?>) value); Class<?> valueClass = Object.class; str = typeFactory.constructMapType(EnumMap.class, enumClass, valueClass).toCanonical(); Class<?> outer = ClassUtil.getOuterClass(cls); if (outer != null) { Class<?> staticType = _baseType.getRawClass(); if (ClassUtil.getOuterClass(staticType) == null) { cls = _baseType.getRawClass(); str = cls.getName();
/** * Method for constructing a {@link CollectionType}. *<p> * NOTE: type modifiers are NOT called on Collection type itself; but are called * for contained types. */ public CollectionType constructCollectionType(Class<? extends Collection> collectionClass, Class<?> elementClass) { return CollectionType.construct(collectionClass, constructType(elementClass)); }
throws JsonMappingException JavaType contentType = type.getContentType(); JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); Class<?> collectionClass = type.getRawClass(); if (contentDeser == null) { // not defined by annotation if (type.isInterface() || type.isAbstract()) { @SuppressWarnings({ "rawtypes" }) Class<? extends Collection> fallback = _collectionFallbacks.get(collectionClass.getName()); if (contentType.getRawClass() == String.class) {
private void requireCollectionOfComparableElements(CollectionType actualType, String targetType) { Class<?> elemType = actualType.getContentType().getRawClass(); if (!Comparable.class.isAssignableFrom(elemType)) { throw new IllegalArgumentException("Can not handle " + targetType + " with elements that are not Comparable<?> (" + elemType.getName() + ")"); } }
/** {@inheritDoc} */ @Override public JsonSerializer<?> findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) { if (Collection.class.isAssignableFrom(type.getRawClass()) && jsonContext.isSupportedType(type.getContentType().getRawClass())) { return createSerializer(); } return null; }
@Override public JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { if (type.getContentType().isTypeOrSubTypeOf(EObject.class)) { return new CollectionDeserializer(new EObjectDeserializer(builder, type.getContentType().getRawClass()), _referenceDeserializer); } return super.findCollectionDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer); }
@Override public JavaType widenContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _elementType.getRawClass()) { return this; } return new CollectionType(_class, _elementType.widenBy(contentClass), _valueHandler, _typeHandler); }
@Override public JavaType narrowContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _elementType.getRawClass()) { return this; } return new CollectionType(_class, _elementType.narrowBy(contentClass), _valueHandler, _typeHandler); }
return ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); keyType = paramTypes.get(0); contentType = (paramTypes.size() >= 2) ? paramTypes.get(1) : _unknownType(); return MapType.construct(clz, keyType, contentType); return _mapType(clz); return CollectionType.construct(clz, paramTypes.get(0)); return _collectionType(clz);
/** * Method that can be used to construct "raw" Collection type; meaning that its * parameterization is unknown. * This is similar to using <code>Object.class</code> parameterization, * and is equivalent to calling: *<pre> * typeFactory.constructCollectionType(collectionClass, typeFactory.unknownType()); *<pre> *<p> * This method should only be used if parameterization is completely unavailable. */ public CollectionType constructRawCollectionType(Class<? extends Collection> collectionClass) { return CollectionType.construct(collectionClass, unknownType()); }
private JavaType _collectionType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Collection.class); // ok to have no types ("raw") if (typeParams == null) { return CollectionType.construct(rawClass, _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 1) { throw new IllegalArgumentException("Strange Collection type "+rawClass.getName()+": can not determine type parameters"); } return CollectionType.construct(rawClass, typeParams[0]); }
throws JsonMappingException Class<?> raw = type.getRawClass();
public MapDeserializer(JavaType pairType) { super( CollectionType.construct(ArrayList.class, null, null, null, pairType), // null, null, new ValueInstantiator() { @Override public Object createUsingDefault(DeserializationContext ctxt) throws IOException { return new ArrayList(); } }); }
@Override public JsonSerializer<?> findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) { if (type.getContentType().isReferenceType()) { return new CollectionSerializer(type.getContentType(), false, null, (JsonSerializer) _referenceSerializer); } return super.findCollectionSerializer(config, type, beanDesc, elementTypeSerializer, elementValueSerializer); }
@Override public CollectionType withContentValueHandler(Object h) { return new CollectionType(_class, _bindings, _superClass, _superInterfaces, _elementType.withValueHandler(h), _valueHandler, _typeHandler, _asStatic); }