From: Svjatoslav Agejenko Date: Thu, 13 Oct 2022 19:46:51 +0000 (+0300) Subject: Code refactoring X-Git-Tag: meviz-1.4~1 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=4a166a0592ad9bf57b68d831ed20d7d784fc2ff6;hp=d91415122cdb6221a8de40311683d4316486065b;p=meviz.git Code refactoring --- diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/AbstractIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/AbstractIndexer.java index 258f2f1..0aa459b 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/AbstractIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/AbstractIndexer.java @@ -8,16 +8,15 @@ import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.*; 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) { diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/FilesystemIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/FilesystemIndexer.java index e553c80..ce8e3fb 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/FilesystemIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/indexer/FilesystemIndexer.java @@ -107,8 +107,7 @@ public class FilesystemIndexer extends AbstractIndexer { private List getChildPath(final File file) { - final List result = new ArrayList<>(); - result.addAll(pathElements); + final List result = new ArrayList<>(pathElements); result.add(file.getName()); return result; diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java index 64933e1..0725382 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java @@ -33,15 +33,7 @@ public class DirectoryMetadata implements Serializable { * images that no longer exist in the filesystem. */ public void cleanup() { - final Iterator 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, @@ -105,7 +97,7 @@ public class DirectoryMetadata implements Serializable { final ArrayList files = new ArrayList<>( fileNameToFileMap.values()); - Collections.sort(files, new FileSortComparator()); + files.sort(new FileSortComparator()); return files; }