@ SuppressWarnings ( "TypeParameterUnusedInFormals" ) public < T extends GraphQLType > T decorate ( GraphQLType objectType ) { GraphQLType out = objectType ; Stack < Class < ? > > wrappingStack = new Stack <> ( ) ; wrappingStack . addAll ( this . decoration ) ; while ( ! wrappingStack . isEmpty ( ) ) { Class < ? > clazz = wrappingStack . pop ( ) ; if ( clazz . equals ( NonNullType . class ) ) { out = nonNull ( out ) ; } if ( clazz . equals ( ListType . class ) ) { out = list ( out ) ; } } // we handle both input and output graphql types //noinspection unchecked return ( T ) out ; }
This will decorate a graphql type with the original hierarchy of non null and list ness it originally contained in its definition type