|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2016 the original author or authors. |
| 2 | + * Copyright 2014-2017 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
28 | 28 | import org.apache.commons.lang.StringUtils;
|
29 | 29 | import org.apache.commons.lang.math.NumberUtils;
|
30 | 30 | import org.elasticsearch.common.xcontent.XContentBuilder;
|
31 |
| -import org.springframework.core.GenericCollectionTypeResolver; |
| 31 | +import org.springframework.core.ResolvableType; |
32 | 32 | import org.springframework.core.io.ClassPathResource;
|
33 | 33 | import org.springframework.data.annotation.Transient;
|
34 | 34 | import org.springframework.data.elasticsearch.annotations.*;
|
|
47 | 47 | * @author Alexander Volz
|
48 | 48 | * @author Dennis Maaß
|
49 | 49 | * @author Pavel Luhin
|
| 50 | + * @author Mark Paluch |
50 | 51 | */
|
51 |
| - |
52 | 52 | class MappingBuilder {
|
53 | 53 |
|
54 | 54 | public static final String FIELD_STORE = "store";
|
@@ -315,12 +315,20 @@ protected static boolean isEntity(java.lang.reflect.Field field) {
|
315 | 315 | }
|
316 | 316 |
|
317 | 317 | protected static Class<?> getFieldType(java.lang.reflect.Field field) {
|
318 |
| - Class<?> clazz = field.getType(); |
319 |
| - TypeInformation typeInformation = ClassTypeInformation.from(clazz); |
320 |
| - if (typeInformation.isCollectionLike()) { |
321 |
| - clazz = GenericCollectionTypeResolver.getCollectionFieldType(field) != null ? GenericCollectionTypeResolver.getCollectionFieldType(field) : typeInformation.getComponentType().getType(); |
| 318 | + |
| 319 | + ResolvableType resolvableType = ResolvableType.forField(field); |
| 320 | + |
| 321 | + if (resolvableType.isArray()) { |
| 322 | + return resolvableType.getComponentType().getRawClass(); |
322 | 323 | }
|
323 |
| - return clazz; |
| 324 | + |
| 325 | + ResolvableType componentType = resolvableType.getGeneric(0); |
| 326 | + if (Iterable.class.isAssignableFrom(field.getType()) |
| 327 | + && componentType != ResolvableType.NONE) { |
| 328 | + return componentType.getRawClass(); |
| 329 | + } |
| 330 | + |
| 331 | + return resolvableType.getRawClass(); |
324 | 332 | }
|
325 | 333 |
|
326 | 334 | private static boolean isAnyPropertyAnnotatedAsField(java.lang.reflect.Field[] fields) {
|
|
0 commit comments