DATAES-408 - Ensure Spring Framework 5 compatibility.

Polished use of TypeInformation in MappingBuilder to remove reference to GenericCollectionTypeResolver which was removed in Spring Framework 5.
This commit is contained in:
Oliver Gierke 2017-10-16 19:40:44 +02:00
parent 4daadf0d98
commit d7b94e53a5

View File

@ -28,7 +28,6 @@ import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils; import org.apache.commons.lang.math.NumberUtils;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.springframework.core.GenericCollectionTypeResolver;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import org.springframework.data.elasticsearch.annotations.*; import org.springframework.data.elasticsearch.annotations.*;
@ -47,6 +46,7 @@ import org.springframework.data.util.TypeInformation;
* @author Alexander Volz * @author Alexander Volz
* @author Dennis Maaß * @author Dennis Maaß
* @author Pavel Luhin * @author Pavel Luhin
* @author Oliver Gierke
*/ */
class MappingBuilder { class MappingBuilder {
@ -308,19 +308,19 @@ class MappingBuilder {
} }
protected static boolean isEntity(java.lang.reflect.Field field) { protected static boolean isEntity(java.lang.reflect.Field field) {
TypeInformation typeInformation = ClassTypeInformation.from(field.getType());
TypeInformation<?> typeInformation = ClassTypeInformation.from(field.getType());
Class<?> clazz = getFieldType(field); Class<?> clazz = getFieldType(field);
boolean isComplexType = !SIMPLE_TYPE_HOLDER.isSimpleType(clazz); boolean isComplexType = !SIMPLE_TYPE_HOLDER.isSimpleType(clazz);
return isComplexType && !Map.class.isAssignableFrom(typeInformation.getType()); return isComplexType && !typeInformation.isMap();
} }
protected static Class<?> getFieldType(java.lang.reflect.Field field) { protected static Class<?> getFieldType(java.lang.reflect.Field field) {
Class<?> clazz = field.getType();
TypeInformation typeInformation = ClassTypeInformation.from(clazz); return ClassTypeInformation.from(field.getDeclaringClass()) //
if (typeInformation.isCollectionLike()) { .getProperty(field.getName()) //
clazz = GenericCollectionTypeResolver.getCollectionFieldType(field) != null ? GenericCollectionTypeResolver.getCollectionFieldType(field) : typeInformation.getComponentType().getType(); .getActualType() //
} .getType();
return clazz;
} }
private static boolean isAnyPropertyAnnotatedAsField(java.lang.reflect.Field[] fields) { private static boolean isAnyPropertyAnnotatedAsField(java.lang.reflect.Field[] fields) {