@ SuppressWarnings ( "PMD.AvoidInstantiatingObjectsInLoops" ) private static Map < String , List < Request > > asMap ( final Collection < Request > reqs ) throws IOException { final Map < String , List < Request > > map = new HashMap <> ( reqs . size ( ) ) ; for ( final Request req : reqs ) { final String header = new RqHeaders . Smart ( req ) . single ( "Content-Disposition" ) ; final Matcher matcher = RqMtBase . NAME . matcher ( header ) ; if ( ! matcher . matches ( ) ) { throw new HttpException ( HttpURLConnection . HTTP_BAD_REQUEST , String . format ( "\"name\" not found in Content-Disposition header: %s" , header ) ) ; } final String name = matcher . group ( 1 ) ; if ( ! map . containsKey ( name ) ) { map . put ( name , new LinkedList <> ( ) ) ; } map . get ( name ) . add ( req ) ; } return map ; }
Convert a list of requests to a map .