@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) private void mergeResponsesNamedList ( NamedList < Object > mainResponse , NamedList < Object > shardResponse ) throws IOException { Iterator < Entry < String , Object > > it = shardResponse . iterator ( ) ; while ( it . hasNext ( ) ) { Entry < String , Object > entry = it . next ( ) ; String name = entry . getKey ( ) ; Object shardValue = entry . getValue ( ) ; int originalId = mainResponse . indexOf ( name , 0 ) ; if ( originalId < 0 ) { mainResponse . add ( name , adjustablePartsCloned ( shardValue ) ) ; } else { Object original = mainResponse . getVal ( originalId ) ; if ( original == null ) { original = adjustablePartsCloned ( shardValue ) ; } else if ( shardValue != null && original . getClass ( ) . equals ( shardValue . getClass ( ) ) ) { // merge ArrayList if ( original instanceof ArrayList ) { ArrayList originalList = ( ArrayList ) original ; ArrayList shardList = ( ArrayList ) shardValue ; mergeResponsesArrayList ( originalList , shardList ) ; // merge Namedlist } else if ( original instanceof NamedList < ? > ) { mergeResponsesNamedList ( ( NamedList < Object > ) original , ( NamedList < Object > ) shardValue ) ; // merge SortedSet } else if ( original instanceof SortedSet < ? > ) { mergeResponsesSortedSet ( ( SortedSet < Object > ) original , ( SortedSet < Object > ) shardValue ) ; } else if ( original instanceof MtasSolrMtasResult ) { MtasSolrMtasResult originalComponentResult = ( MtasSolrMtasResult ) original ; originalComponentResult . merge ( ( MtasSolrMtasResult ) shardValue ) ; } else if ( original instanceof MtasSolrCollectionResult ) { MtasSolrCollectionResult originalComponentResult = ( MtasSolrCollectionResult ) original ; originalComponentResult . merge ( ( MtasSolrCollectionResult ) shardValue ) ; } else if ( original instanceof String ) { // ignore? } else if ( original instanceof Integer ) { original = ( Integer ) original + ( ( Integer ) shardValue ) ; } else if ( original instanceof Long ) { original = ( Long ) original + ( ( Long ) shardValue ) ; } else { // ignore? } mainResponse . setVal ( originalId , original ) ; } else { // ignore? } } } }
Merge responses named list .