@@ -76,10 +76,13 @@ public class IntrospectionResultToSchema {
7676 *
7777 * @return a IDL Document of the schema
7878 */
79+ @ SuppressWarnings ("unchecked" )
7980 public Document createSchemaDefinition (Map <String , Object > introspectionResult ) {
80- Map <String , Object > schema = assertNotNull ((Map <String , Object >) introspectionResult .get ("__schema" ), "__schema expected" );
81+ Map <String , Object > schema = (Map <String , Object >) introspectionResult .get ("__schema" );
82+ assertNotNull (schema , "__schema expected" );
8183
82- Map <String , Object > queryType = assertNotNull ((Map <String , Object >) schema .get ("queryType" ), "queryType expected" );
84+ Map <String , Object > queryType = (Map <String , Object >) schema .get ("queryType" );
85+ assertNotNull (queryType , "queryType expected" );
8386 TypeName query = TypeName .newTypeName ().name (assertValidName ((String ) queryType .get ("name" ))).build ();
8487 boolean nonDefaultQueryName = !"Query" .equals (query .getName ());
8588
@@ -167,12 +170,12 @@ private List<DirectiveLocation> createDirectiveLocations(List<Object> locations)
167170 }
168171
169172 private @ Nullable TypeDefinition createTypeDefinition (Map <String , Object > type ) {
170- String kind = assertNotNull (( String ) type .get ("kind" ), "kind expected " );
171- String name = assertValidName ((String ) type .get ("name" ));
173+ String kind = ( String ) type .get ("kind" );
174+ String name = assertNotNull ((String ) type .get ("name" ), "name expected" );
172175 if (name .startsWith ("__" )) {
173176 return null ;
174177 }
175- switch (kind ) {
178+ switch (assertNotNull ( kind , "kind expected" ) ) {
176179 case "INTERFACE" :
177180 return createInterface (type );
178181 case "OBJECT" :
@@ -202,6 +205,7 @@ private List<DirectiveLocation> createDirectiveLocations(List<Object> locations)
202205 }
203206
204207
208+ @ SuppressWarnings ("unchecked" )
205209 UnionTypeDefinition createUnion (Map <String , Object > input ) {
206210 assertTrue ("UNION" .equals (input .get ("kind" )), "wrong input" );
207211
@@ -219,6 +223,7 @@ UnionTypeDefinition createUnion(Map<String, Object> input) {
219223 return unionTypeDefinition .build ();
220224 }
221225
226+ @ SuppressWarnings ("unchecked" )
222227 EnumTypeDefinition createEnum (Map <String , Object > input ) {
223228 assertTrue ("ENUM" .equals (input .get ("kind" )), "wrong input" );
224229
@@ -240,15 +245,18 @@ EnumTypeDefinition createEnum(Map<String, Object> input) {
240245 return enumTypeDefinition .build ();
241246 }
242247
248+ @ SuppressWarnings ("unchecked" )
243249 InterfaceTypeDefinition createInterface (Map <String , Object > input ) {
244250 assertTrue ("INTERFACE" .equals (input .get ("kind" )), "wrong input" );
245251
246252 InterfaceTypeDefinition .Builder interfaceTypeDefinition = InterfaceTypeDefinition .newInterfaceTypeDefinition ().name (assertValidName ((String ) input .get ("name" )));
247253 interfaceTypeDefinition .description (toDescription (input ));
248- List <Map <String , Object >> interfaces = (List <Map <String , Object >>) input .get ("interfaces" );
249- if (interfaces != null ) {
254+ if (input .containsKey ("interfaces" ) && input .get ("interfaces" ) != null ) {
250255 interfaceTypeDefinition .implementz (
251- map (interfaces , this ::createTypeIndirection )
256+ map (
257+ (List <Map <String , Object >>) input .get ("interfaces" ),
258+ this ::createTypeIndirection
259+ )
252260 );
253261 }
254262 List <Map <String , Object >> fields = assertNotNull ((List <Map <String , Object >>) input .get ("fields" ), "fields expected" );
@@ -258,6 +266,7 @@ InterfaceTypeDefinition createInterface(Map<String, Object> input) {
258266
259267 }
260268
269+ @ SuppressWarnings ("unchecked" )
261270 InputObjectTypeDefinition createInputObject (Map <String , Object > input ) {
262271 assertTrue ("INPUT_OBJECT" .equals (input .get ("kind" )), "wrong input" );
263272
@@ -276,6 +285,7 @@ InputObjectTypeDefinition createInputObject(Map<String, Object> input) {
276285 return inputObjectTypeDefinition .build ();
277286 }
278287
288+ @ SuppressWarnings ("unchecked" )
279289 ObjectTypeDefinition createObject (Map <String , Object > input ) {
280290 assertTrue ("OBJECT" .equals (input .get ("kind" )), "wrong input" );
281291
@@ -323,6 +333,7 @@ private void createDeprecatedDirective(Map<String, Object> field, NodeDirectives
323333 }
324334 }
325335
336+ @ SuppressWarnings ("unchecked" )
326337 private List <InputValueDefinition > createInputValueDefinitions (List <Map <String , Object >> args ) {
327338 List <InputValueDefinition > result = new ArrayList <>(args .size ());
328339 for (Map <String , Object > arg : args ) {
@@ -341,6 +352,7 @@ private List<InputValueDefinition> createInputValueDefinitions(List<Map<String,
341352 return result ;
342353 }
343354
355+ @ SuppressWarnings ("unchecked" )
344356 private Type createTypeIndirection (Map <String , Object > type ) {
345357 String kind = assertNotNull ((String ) type .get ("kind" ), "kind expected" );
346358 switch (kind ) {
0 commit comments