private File scanFor ( final ProviderIdent ident , final File [ ] files ) throws PluginScannerException { final List < FileCache . MemoFile > candidates = new ArrayList <> ( ) ; HashSet < FileCache . MemoFile > prescanned = new HashSet <> ( scannedFiles ) ; HashSet < FileCache . MemoFile > newscanned = new HashSet <> ( ) ; for ( final File file : files ) { FileCache . MemoFile memo = memoize ( file ) ; if ( cachedFileValidity ( file ) ) { newscanned . add ( memo ) ; if ( test ( ident , file ) ) { candidates . add ( memo ) ; } } prescanned . remove ( memo ) ; } clearMemos ( prescanned ) ; scannedFiles = newscanned ; if ( candidates . size ( ) == 1 ) { return candidates . get ( 0 ) . getFile ( ) ; } if ( candidates . size ( ) > 1 ) { final File resolved = resolveProviderConflict ( candidates ) ; if ( null == resolved ) { log . warn ( "More than one plugin file matched: " + StringArrayUtil . asString ( candidates . toArray ( ) , "," ) + ": " + ident ) ; } else { return resolved ; } } return null ; }
Return the first valid file found