import java.io.File;
import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
import static eu.svjatoslav.meviz.htmlindexer.Constants.SUPPORTED_IMAGE_EXTENSIONS;
import static eu.svjatoslav.meviz.htmlindexer.Constants.SUPPORTED_VIDEO_EXTENSIONS;
-import static java.util.Arrays.stream;
public abstract class AbstractIndexer {
public static boolean isImage(final String fileExtension) {
- return stream(SUPPORTED_IMAGE_EXTENSIONS)
- .anyMatch(ext -> ext.equals(fileExtension));
+ return Arrays.asList(SUPPORTED_IMAGE_EXTENSIONS).contains(fileExtension);
}
public static boolean isVideo(final String fileExtension) {
private List<String> getChildPath(final File file) {
- final List<String> result = new ArrayList<>();
- result.addAll(pathElements);
+ final List<String> result = new ArrayList<>(pathElements);
result.add(file.getName());
return result;
* images that no longer exist in the filesystem.
*/
public void cleanup() {
- final Iterator<AbstractFile> fileIterator = fileNameToFileMap.values()
- .iterator();
-
- while (fileIterator.hasNext()) {
- final AbstractFile file = fileIterator.next();
-
- if (!file.isMetadataVerified())
- fileIterator.remove();
- }
+ fileNameToFileMap.values().removeIf(file -> !file.isMetadataVerified());
}
public void ensureFileMetadataIsUpToDate(final File parentDirectory,
final ArrayList<AbstractFile> files = new ArrayList<>(
fileNameToFileMap.values());
- Collections.sort(files, new FileSortComparator());
+ files.sort(new FileSortComparator());
return files;
}