|
20 | 20 |
|
21 | 21 | package com.arangodb.springframework.core.convert; |
22 | 22 |
|
23 | | -import java.lang.annotation.Annotation; |
24 | | -import java.lang.reflect.Array; |
25 | | -import java.math.BigDecimal; |
26 | | -import java.math.BigInteger; |
27 | | -import java.sql.Timestamp; |
28 | | -import java.text.ParseException; |
29 | | -import java.time.Instant; |
30 | | -import java.time.LocalDate; |
31 | | -import java.time.LocalDateTime; |
32 | | -import java.time.OffsetDateTime; |
33 | | -import java.time.ZonedDateTime; |
34 | | -import java.util.Collection; |
35 | | -import java.util.Collections; |
36 | | -import java.util.Date; |
37 | | -import java.util.Iterator; |
38 | | -import java.util.Map; |
39 | | -import java.util.Map.Entry; |
40 | | -import java.util.Optional; |
41 | | - |
| 23 | +import com.arangodb.entity.BaseDocument; |
| 24 | +import com.arangodb.entity.BaseEdgeDocument; |
| 25 | +import com.arangodb.springframework.annotation.*; |
| 26 | +import com.arangodb.springframework.core.convert.resolver.LazyLoadingProxy; |
| 27 | +import com.arangodb.springframework.core.convert.resolver.ReferenceResolver; |
| 28 | +import com.arangodb.springframework.core.convert.resolver.RelationResolver; |
| 29 | +import com.arangodb.springframework.core.convert.resolver.ResolverFactory; |
| 30 | +import com.arangodb.springframework.core.mapping.ArangoPersistentEntity; |
| 31 | +import com.arangodb.springframework.core.mapping.ArangoPersistentProperty; |
| 32 | +import com.arangodb.springframework.core.mapping.ArangoSimpleTypes; |
| 33 | +import com.arangodb.springframework.core.util.MetadataUtils; |
| 34 | +import com.arangodb.velocypack.VPackBuilder; |
| 35 | +import com.arangodb.velocypack.VPackSlice; |
| 36 | +import com.arangodb.velocypack.ValueType; |
| 37 | +import com.arangodb.velocypack.internal.util.DateUtil; |
| 38 | +import com.arangodb.velocypack.module.jdk8.internal.util.JavaTimeUtil; |
42 | 39 | import org.springframework.core.CollectionFactory; |
43 | 40 | import org.springframework.core.convert.support.DefaultConversionService; |
44 | 41 | import org.springframework.core.convert.support.GenericConversionService; |
|
58 | 55 | import org.springframework.util.ClassUtils; |
59 | 56 | import org.springframework.util.CollectionUtils; |
60 | 57 |
|
61 | | -import com.arangodb.entity.BaseDocument; |
62 | | -import com.arangodb.entity.BaseEdgeDocument; |
63 | | -import com.arangodb.springframework.annotation.Document; |
64 | | -import com.arangodb.springframework.annotation.Edge; |
65 | | -import com.arangodb.springframework.annotation.From; |
66 | | -import com.arangodb.springframework.annotation.Ref; |
67 | | -import com.arangodb.springframework.annotation.Relations; |
68 | | -import com.arangodb.springframework.annotation.To; |
69 | | -import com.arangodb.springframework.core.convert.resolver.LazyLoadingProxy; |
70 | | -import com.arangodb.springframework.core.convert.resolver.ReferenceResolver; |
71 | | -import com.arangodb.springframework.core.convert.resolver.RelationResolver; |
72 | | -import com.arangodb.springframework.core.convert.resolver.ResolverFactory; |
73 | | -import com.arangodb.springframework.core.mapping.ArangoPersistentEntity; |
74 | | -import com.arangodb.springframework.core.mapping.ArangoPersistentProperty; |
75 | | -import com.arangodb.springframework.core.mapping.ArangoSimpleTypes; |
76 | | -import com.arangodb.springframework.core.util.MetadataUtils; |
77 | | -import com.arangodb.velocypack.VPackBuilder; |
78 | | -import com.arangodb.velocypack.VPackSlice; |
79 | | -import com.arangodb.velocypack.ValueType; |
80 | | -import com.arangodb.velocypack.internal.util.DateUtil; |
81 | | -import com.arangodb.velocypack.module.jdk8.internal.util.JavaTimeUtil; |
| 58 | +import java.lang.annotation.Annotation; |
| 59 | +import java.lang.reflect.Array; |
| 60 | +import java.math.BigDecimal; |
| 61 | +import java.math.BigInteger; |
| 62 | +import java.sql.Timestamp; |
| 63 | +import java.text.ParseException; |
| 64 | +import java.time.*; |
| 65 | +import java.util.*; |
| 66 | +import java.util.Map.Entry; |
82 | 67 |
|
83 | 68 | /** |
84 | 69 | * @author Mark Vollmary |
@@ -290,16 +275,18 @@ private Object readMap(final TypeInformation<?> type, final VPackSlice source) { |
290 | 275 | return map; |
291 | 276 | } |
292 | 277 |
|
293 | | - private Object readCollection(final TypeInformation<?> type, final VPackSlice source) { |
| 278 | + private Collection<?> readCollection(final TypeInformation<?> type, final VPackSlice source) { |
294 | 279 | if (!source.isArray()) { |
295 | 280 | throw new MappingException( |
296 | 281 | String.format("Can't read collection type %s from VPack type %s!", type, source.getType())); |
297 | 282 | } |
298 | 283 |
|
299 | 284 | final TypeInformation<?> componentType = getNonNullComponentType(type); |
300 | 285 | final Class<?> collectionType = Iterable.class.equals(type.getType()) ? Collection.class : type.getType(); |
301 | | - final Collection<Object> collection = CollectionFactory.createCollection(collectionType, |
302 | | - componentType.getType(), source.getLength()); |
| 286 | + |
| 287 | + final Collection<Object> collection = Collection.class == collectionType || List.class == collectionType ? |
| 288 | + new ArrayList<>(source.getLength()) : |
| 289 | + CollectionFactory.createCollection(collectionType, componentType.getType(), source.getLength()); |
303 | 290 |
|
304 | 291 | final Iterator<VPackSlice> iterator = source.arrayIterator(); |
305 | 292 |
|
|
0 commit comments