diff --git a/src/main/java/org/jabref/JabRefExecutorService.java b/src/main/java/org/jabref/JabRefExecutorService.java index df127df89f6..10fd1ee19cc 100644 --- a/src/main/java/org/jabref/JabRefExecutorService.java +++ b/src/main/java/org/jabref/JabRefExecutorService.java @@ -143,7 +143,7 @@ public void shutdownEverything() { timer.cancel(); } - private class NamedRunnable implements Runnable { + private static class NamedRunnable implements Runnable { private final String name; diff --git a/src/main/java/org/jabref/gui/SidePaneManager.java b/src/main/java/org/jabref/gui/SidePaneManager.java index 324810dd6ed..55b55d4f795 100644 --- a/src/main/java/org/jabref/gui/SidePaneManager.java +++ b/src/main/java/org/jabref/gui/SidePaneManager.java @@ -176,7 +176,7 @@ private void updateView() { /** * Helper class for sorting visible components based on their preferred position. */ - private class PreferredIndexSort implements Comparator { + private static class PreferredIndexSort implements Comparator { private final Map preferredPositions; diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java index 2b78f4dd74d..aa3c7982175 100644 --- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java +++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesTask.java @@ -50,7 +50,7 @@ public CopyFilesTask(BibDatabaseContext databaseContext, List entries, this.databaseContext = databaseContext; this.entries = entries; this.exportPath = path; - totalFilesCount = entries.stream().flatMap(entry -> entry.getFiles().stream()).count(); + totalFilesCount = entries.stream().mapToLong(entry -> entry.getFiles().size()).sum(); } @Override diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java index 2c7dc4db6ab..1336e505afc 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java @@ -184,7 +184,7 @@ private void handleDuplicates(DuplicateSearchResult result) { * Uses {@link System#identityHashCode(Object)} for identifying objects for removal, as completely identical * {@link BibEntry BibEntries} are equal to each other. */ - class DuplicateSearchResult { + static class DuplicateSearchResult { private final Map toRemove = new HashMap<>(); private final List toAdd = new ArrayList<>(); diff --git a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java index 94b63150d15..606706a89da 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java +++ b/src/main/java/org/jabref/gui/exporter/ExportToClipboardAction.java @@ -150,7 +150,7 @@ private String readFileToString(Path tmp) throws IOException { } } - private class ExportResult { + private static class ExportResult { final String content; final FileType fileType; diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index c26db16fc85..856edb67a19 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -393,7 +393,7 @@ private void setupClearButtonField(CustomTextField customTextField) { } } - private class DragExpansionHandler { + private static class DragExpansionHandler { private static final long DRAG_TIME_BEFORE_EXPANDING_MS = 1000; private TreeItem draggedItem; private long dragStarted; diff --git a/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java b/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java index f8d83ed5c5a..1f04933adde 100644 --- a/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java +++ b/src/main/java/org/jabref/gui/groups/UndoableModifySubtree.java @@ -43,9 +43,7 @@ public void undo() { m_modifiedSubtree.clear(); // get node to edit final GroupTreeNode subtreeRoot = m_groupRoot.getDescendant(m_subtreeRootPath).get(); //TODO: NULL - for (GroupTreeNode child : subtreeRoot.getChildren()) { - m_modifiedSubtree.add(child); - } + m_modifiedSubtree.addAll(subtreeRoot.getChildren()); // keep subtree handle, but restore everything else from backup subtreeRoot.removeAllChildren(); for (GroupTreeNode child : m_subtreeBackup.getChildren()) { diff --git a/src/main/java/org/jabref/gui/util/BackgroundTask.java b/src/main/java/org/jabref/gui/util/BackgroundTask.java index c07f3b70485..f3f2cd24d09 100644 --- a/src/main/java/org/jabref/gui/util/BackgroundTask.java +++ b/src/main/java/org/jabref/gui/util/BackgroundTask.java @@ -233,7 +233,7 @@ public BackgroundTask withInitialMessage(String message) { return this; } - class BackgroundProgress { + static class BackgroundProgress { private final double workDone; private final double max; diff --git a/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java b/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java index a5f8ec393a1..e615225f715 100644 --- a/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java +++ b/src/main/java/org/jabref/gui/util/CurrentThreadTaskExecutor.java @@ -74,7 +74,7 @@ public DelayTaskThrottler createThrottler(int delay) { return throttler; } - private class FailedFuture implements Future { + private static class FailedFuture implements Future { private final Throwable exception; FailedFuture(Throwable exception) { diff --git a/src/main/java/org/jabref/gui/util/IconValidationDecorator.java b/src/main/java/org/jabref/gui/util/IconValidationDecorator.java index ada1bf7ab21..2608c5c0663 100644 --- a/src/main/java/org/jabref/gui/util/IconValidationDecorator.java +++ b/src/main/java/org/jabref/gui/util/IconValidationDecorator.java @@ -1,7 +1,7 @@ package org.jabref.gui.util; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import javafx.geometry.Pos; import javafx.scene.Node; @@ -61,6 +61,6 @@ protected Tooltip createTooltip(ValidationMessage message) { @Override protected Collection createValidationDecorations(ValidationMessage message) { - return Arrays.asList(new GraphicDecoration(createDecorationNode(message), position)); + return Collections.singletonList(new GraphicDecoration(createDecorationNode(message), position)); } } diff --git a/src/main/java/org/jabref/gui/util/component/TagBar.java b/src/main/java/org/jabref/gui/util/component/TagBar.java index 3c7161ae05d..3265567869b 100644 --- a/src/main/java/org/jabref/gui/util/component/TagBar.java +++ b/src/main/java/org/jabref/gui/util/component/TagBar.java @@ -56,7 +56,7 @@ public ObservableList getTags() { } public void setTags(Collection newTags) { - this.tags.setAll(tags); + this.tags.setAll(newTags); } public ListProperty tagsProperty() { diff --git a/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java b/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java index f0f4912780a..005ef6577ee 100644 --- a/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java +++ b/src/main/java/org/jabref/logic/bibtex/comparator/FieldComparator.java @@ -130,13 +130,13 @@ public int compare(BibEntry e1, BibEntry e2) { // Ok, parsing was successful. Update f1 and f2: return i1.get().compareTo(i2.get()) * multiplier; } else if (i1.isPresent()) { - // The first one was parseable, but not the second one. + // The first one was parsable, but not the second one. // This means we consider one < two return -1 * multiplier; } else if (i2.isPresent()) { - // The second one was parseable, but not the first one. + // The second one was parsable, but not the first one. // This means we consider one > two - return 1 * multiplier; + return multiplier; } // Else none of them were parseable, and we can fall back on comparing strings. } diff --git a/src/main/java/org/jabref/logic/bst/VM.java b/src/main/java/org/jabref/logic/bst/VM.java index f3dce6d5cfb..7b120710e1b 100644 --- a/src/main/java/org/jabref/logic/bst/VM.java +++ b/src/main/java/org/jabref/logic/bst/VM.java @@ -510,7 +510,7 @@ private VM(CommonTree tree) { */ buildInFunctions.put("stack$", context -> { while (!stack.empty()) { - LOGGER.debug("Stack entry", stack.pop()); + LOGGER.debug("Stack entry {}", stack.pop()); } }); @@ -574,7 +574,7 @@ private VM(CommonTree tree) { /* * Pops and prints the top of the stack to the log file. It's useful for debugging. */ - buildInFunctions.put("top$", context -> LOGGER.debug("Stack entry", stack.pop())); + buildInFunctions.put("top$", context -> LOGGER.debug("Stack entry {}", stack.pop())); /* * Pushes the current entry's type (book, article, etc.), but pushes diff --git a/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java b/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java index 1e5b6b310ca..db32ced0e5d 100644 --- a/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java +++ b/src/main/java/org/jabref/logic/exporter/BibTeXMLExporter.java @@ -211,7 +211,7 @@ private void parse(T entryType, BibEntry bibEntry, Entry entry) { try { method.invoke(entryType, new BigInteger(value)); } catch (NumberFormatException exception) { - LOGGER.warn("The value %s of the 'number' field is not an integer and thus is ignored for the export", value); + LOGGER.warn("The value {} of the 'number' field is not an integer and thus is ignored for the export", value); } break; } else if (StandardField.MONTH.equals(key)) { diff --git a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java index 3b04572b50b..3d95d91a3da 100644 --- a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java +++ b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java @@ -247,7 +247,7 @@ public void export(final BibDatabaseContext databaseContext, final Path file, if (defLayout != null) { missingFormatters.addAll(defLayout.getMissingFormatters()); if (!missingFormatters.isEmpty()) { - LOGGER.warn("Missing formatters found ", missingFormatters); + LOGGER.warn("Missing formatters found: {}", missingFormatters); } } Map layouts = new HashMap<>(); @@ -310,10 +310,10 @@ public void export(final BibDatabaseContext databaseContext, final Path file, // Clear custom name formatters: layoutPreferences.clearCustomExportNameFormatters(); - if (!missingFormatters.isEmpty()) { + if (!missingFormatters.isEmpty() && LOGGER.isWarnEnabled()) { StringBuilder sb = new StringBuilder("The following formatters could not be found: "); sb.append(String.join(", ", missingFormatters)); - LOGGER.warn("Formatters not found", sb); + LOGGER.warn("Formatters {} not found", sb.toString()); } } } diff --git a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java index aa7e0207e7d..2f56dffd0ad 100644 --- a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java +++ b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java @@ -12,7 +12,6 @@ import org.jabref.logic.importer.fileformat.BiblioscapeImporter; import org.jabref.logic.importer.fileformat.BibtexImporter; import org.jabref.logic.importer.fileformat.CopacImporter; -import org.jabref.logic.importer.fileformat.CustomImporter; import org.jabref.logic.importer.fileformat.EndnoteImporter; import org.jabref.logic.importer.fileformat.EndnoteXmlImporter; import org.jabref.logic.importer.fileformat.InspecImporter; @@ -71,9 +70,7 @@ public void resetImportFormats(ImportFormatPreferences newImportFormatPreference formats.add(new SilverPlatterImporter()); // Get custom import formats - for (CustomImporter importer : importFormatPreferences.getCustomImportList()) { - formats.add(importer); - } + formats.addAll(importFormatPreferences.getCustomImportList()); } /** diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java index fcc72396631..4924b1f50f0 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MrDLibImporter.java @@ -91,7 +91,7 @@ private String convertToString(BufferedReader input) throws IOException { /** * Small pair-class to ensure the right order of the recommendations. */ - private class RankedBibEntry { + private static class RankedBibEntry { public BibEntry entry; public Integer rank; diff --git a/src/main/java/org/jabref/logic/layout/format/RTFChars.java b/src/main/java/org/jabref/logic/layout/format/RTFChars.java index 61945a01d51..e9d58e32a6d 100644 --- a/src/main/java/org/jabref/logic/layout/format/RTFChars.java +++ b/src/main/java/org/jabref/logic/layout/format/RTFChars.java @@ -15,7 +15,7 @@ * * 1.) Remove LaTeX-Command sequences. * - * 2.) Replace LaTeX-Special chars with RTF aquivalents. + * 2.) Replace LaTeX-Special chars with RTF equivalents. * * 3.) Replace emph and textit and textbf with their RTF replacements. * diff --git a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java index 5ca89ec4009..6a5302e8d7f 100644 --- a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java +++ b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java @@ -5,6 +5,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.stream.Collectors; @@ -67,7 +68,7 @@ private static List findWindowsOpenOfficeDirs() { } private static List findOSXOpenOfficeDirs() { - List sourceList = Arrays.asList(Paths.get("/Applications")); + List sourceList = Collections.singletonList(Paths.get("/Applications")); return findOpenOfficeDirectories(sourceList); }