/** * Get <tt>size</tt> number of files, starting at <tt>start</tt>. Only get files containing the query. Leave the * query empty to get all files. * * @param query the query to filter for * @param limit the limit to apply * @return all files which contain the query */ public List<StoredObject> getObjects(@Nonnull String query, Limit limit) { try (Stream<Path> stream = Files.list(file.toPath())) { return stream.map(Path::toFile) .filter(currentFile -> isMatchingObject(query, currentFile)) .filter(limit.asPredicate()) .map(StoredObject::new) .collect(Collectors.toList()); } catch (IOException e) { throw Exceptions.handle(e); } }