private < T extends Index > List < T > listIndexType ( String type , Class < T > modelType ) { List < T > indexesOfType = new ArrayList < T > ( ) ; Gson g = new Gson ( ) ; for ( JsonElement index : indexes ) { if ( index . isJsonObject ( ) ) { JsonObject indexDefinition = index . getAsJsonObject ( ) ; JsonElement indexType = indexDefinition . get ( "type" ) ; if ( indexType != null && indexType . isJsonPrimitive ( ) ) { JsonPrimitive indexTypePrimitive = indexType . getAsJsonPrimitive ( ) ; if ( type == null || ( indexTypePrimitive . isString ( ) && indexTypePrimitive . getAsString ( ) . equals ( type ) ) ) { indexesOfType . add ( g . fromJson ( indexDefinition , modelType ) ) ; } } } } return indexesOfType ; }
Utility to list indexes of a given type .