Skip to content

Commit

Permalink
DATAES-325 - Replace references to GenericCollectionTypeResolver with…
Browse files Browse the repository at this point in the history
… ResolvableType.

Using ResolvableType instead of GenericCollectionTypeResolver that is removed with Spring 5.

Related ticket: SPR-15160.
  • Loading branch information
mp911de committed Jan 26, 2017
1 parent 6bcf3e0 commit cda6936
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.springframework.core.GenericCollectionTypeResolver;
import org.springframework.core.ResolvableType;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.annotation.Transient;
import org.springframework.data.elasticsearch.annotations.*;
Expand All @@ -47,8 +47,8 @@
* @author Alexander Volz
* @author Dennis Maaß
* @author Pavel Luhin
* @author Mark Paluch
*/

class MappingBuilder {

public static final String FIELD_STORE = "store";
Expand Down Expand Up @@ -315,12 +315,20 @@ protected static boolean isEntity(java.lang.reflect.Field field) {
}

protected static Class<?> getFieldType(java.lang.reflect.Field field) {
Class<?> clazz = field.getType();
TypeInformation typeInformation = ClassTypeInformation.from(clazz);
if (typeInformation.isCollectionLike()) {
clazz = GenericCollectionTypeResolver.getCollectionFieldType(field) != null ? GenericCollectionTypeResolver.getCollectionFieldType(field) : typeInformation.getComponentType().getType();

ResolvableType resolvableType = ResolvableType.forField(field);

if (resolvableType.isArray()) {
return resolvableType.getComponentType().getRawClass();
}
return clazz;

ResolvableType componentType = resolvableType.getGeneric(0);
if (Iterable.class.isAssignableFrom(field.getType())
&& componentType != ResolvableType.NONE) {
return componentType.getRawClass();
}

return resolvableType.getRawClass();
}

private static boolean isAnyPropertyAnnotatedAsField(java.lang.reflect.Field[] fields) {
Expand Down

0 comments on commit cda6936

Please sign in to comment.