private Set < Resource < T > > filterResources ( Path path , Predicate < Resource > test ) { validatePath ( path ) ; if ( ! hasDirectory ( path ) ) { throw StorageException . listException ( path , "not a directory path: " + path ) ; } File file = filepathMapper . directoryForPath ( path ) ; HashSet < Resource < T > > files = new HashSet < Resource < T > > ( ) ; try { for ( File file1 : file . listFiles ( ) ) { Resource < T > res = loadResource ( filepathMapper . pathForContentFile ( file1 ) , false ) ; if ( null == test || test . apply ( res ) ) { files . add ( res ) ; } } } catch ( IOException e ) { throw StorageException . listException ( path , "Failed to list directory: " + path + ": " + e . getMessage ( ) , e ) ; } return files ; }
Return a filtered set of resources