question: public static Map < String , Collection < String > > groupFilesByMimeType ( Collection < String > attachments ) { Map < String , Collection < String > > attachmentsByMimeType = new HashMap < > ( ) ; for ( String url : attachments ) { String mimeType = getMimeType ( url ) ; if ( mimeType . length ( ) > 0 ) { Collection < String > mimeTypeList = attachmentsByMimeType . get ( mimeType ) ; if ( mimeTypeList == null ) { mimeTypeList = new ArrayList < > ( ) ; attachmentsByMimeType . put ( mimeType , mimeTypeList ) ; } mimeTypeList . add ( url ) ; } } return attachmentsByMimeType ; }
target:  group given files (URLs) into hash by mime-type