1515 */
1616package org .springframework .data .elasticsearch .core ;
1717
18+ import static org .elasticsearch .common .xcontent .XContentFactory .*;
19+ import static org .springframework .util .StringUtils .*;
20+
1821import java .io .IOException ;
1922import java .util .ArrayList ;
2023import java .util .Arrays ;
2124import java .util .List ;
2225import java .util .Map ;
26+
2327import org .elasticsearch .common .xcontent .XContentBuilder ;
28+ import org .elasticsearch .common .xcontent .XContentType ;
2429import org .springframework .core .ResolvableType ;
2530import org .springframework .core .io .ClassPathResource ;
2631import org .springframework .data .annotation .Transient ;
4045import org .springframework .data .util .TypeInformation ;
4146import org .springframework .util .StringUtils ;
4247
43- import static org .elasticsearch .common .xcontent .XContentFactory .*;
44- import static org .springframework .util .StringUtils .*;
45-
4648/**
4749 * @author Rizwan Idrees
4850 * @author Mohsin Husen
@@ -85,9 +87,8 @@ class MappingBuilder {
8587 public static final String TYPE_VALUE_GEO_HASH_PRECISION = "geohash_precision" ;
8688
8789 private static SimpleTypeHolder SIMPLE_TYPE_HOLDER = SimpleTypeHolder .DEFAULT ;
88- private XContentBuilder xContentBuilder ;
8990
90- static XContentBuilder buildMapping (Class clazz , String indexType , String idFieldName , String parentType ) throws IOException {
91+ static XContentBuilder buildMapping (Class <?> clazz , String indexType , String idFieldName , String parentType ) throws IOException {
9192
9293 XContentBuilder mapping = jsonBuilder ().startObject ().startObject (indexType );
9394 // Parent
@@ -103,7 +104,7 @@ static XContentBuilder buildMapping(Class clazz, String indexType, String idFiel
103104 return xContentBuilder .endObject ().endObject ().endObject ();
104105 }
105106
106- private static void mapEntity (XContentBuilder xContentBuilder , Class clazz , boolean isRootObject , String idFieldName ,
107+ private static void mapEntity (XContentBuilder xContentBuilder , Class <?> clazz , boolean isRootObject , String idFieldName ,
107108 String nestedObjectFieldName , boolean nestedOrObjectField , FieldType fieldType , Field fieldAnnotation ) throws IOException {
108109
109110 java .lang .reflect .Field [] fields = retrieveFields (clazz );
@@ -132,7 +133,7 @@ private static void mapEntity(XContentBuilder xContentBuilder, Class clazz, bool
132133 if (!StringUtils .isEmpty (mappingPath )) {
133134 ClassPathResource mappings = new ClassPathResource (mappingPath );
134135 if (mappings .exists ()) {
135- xContentBuilder .rawField (field .getName (), mappings .getInputStream ());
136+ xContentBuilder .rawField (field .getName (), mappings .getInputStream (), XContentType . JSON );
136137 continue ;
137138 }
138139 }
@@ -178,12 +179,12 @@ private static void mapEntity(XContentBuilder xContentBuilder, Class clazz, bool
178179 }
179180 }
180181
181- private static java .lang .reflect .Field [] retrieveFields (Class clazz ) {
182+ private static java .lang .reflect .Field [] retrieveFields (Class <?> clazz ) {
182183 // Create list of fields.
183184 List <java .lang .reflect .Field > fields = new ArrayList <>();
184185
185186 // Keep backing up the inheritance hierarchy.
186- Class targetClass = clazz ;
187+ Class <?> targetClass = clazz ;
187188 do {
188189 fields .addAll (Arrays .asList (targetClass .getDeclaredFields ()));
189190 targetClass = targetClass .getSuperclass ();
@@ -355,7 +356,7 @@ private static void addFieldMappingParameters(XContentBuilder builder, Object an
355356 }
356357
357358 protected static boolean isEntity (java .lang .reflect .Field field ) {
358- TypeInformation typeInformation = ClassTypeInformation .from (field .getType ());
359+ TypeInformation <?> typeInformation = ClassTypeInformation .from (field .getType ());
359360 Class <?> clazz = getFieldType (field );
360361 boolean isComplexType = !SIMPLE_TYPE_HOLDER .isSimpleType (clazz );
361362 return isComplexType && !Map .class .isAssignableFrom (typeInformation .getType ());
0 commit comments