diff --git a/rewrite.yml b/rewrite.yml index 7414f42c3e0..155ca0a12cd 100644 --- a/rewrite.yml +++ b/rewrite.yml @@ -164,7 +164,7 @@ recipeList: # - org.openrewrite.java.cleanup.StaticMethodNotFinal - org.openrewrite.java.cleanup.StringLiteralEquality - org.openrewrite.java.cleanup.TypecastParenPad -# - org.openrewrite.java.cleanup.UnnecessaryParentheses + - org.openrewrite.java.cleanup.UnnecessaryParentheses - org.openrewrite.java.cleanup.UnwrapRepeatableAnnotations - org.openrewrite.java.cleanup.UpperCaseLiteralSuffixes # - org.openrewrite.java.cleanup.UseJavaStyleArrayDeclarations diff --git a/src/main/java/org/jabref/gui/EntryTypeView.java b/src/main/java/org/jabref/gui/EntryTypeView.java index 9ef6f563566..9ea60fbf25c 100644 --- a/src/main/java/org/jabref/gui/EntryTypeView.java +++ b/src/main/java/org/jabref/gui/EntryTypeView.java @@ -89,7 +89,7 @@ public EntryTypeView(LibraryTab libraryTab, DialogService dialogService, Prefere Button btnGenerate = (Button) this.getDialogPane().lookupButton(generateButton); - btnGenerate.textProperty().bind(EasyBind.map(viewModel.searchingProperty(), searching -> (searching) ? Localization.lang("Searching...") : Localization.lang("Generate"))); + btnGenerate.textProperty().bind(EasyBind.map(viewModel.searchingProperty(), searching -> searching ? Localization.lang("Searching...") : Localization.lang("Generate"))); btnGenerate.disableProperty().bind(viewModel.idFieldValidationStatus().validProperty().not().or(viewModel.searchingProperty())); EasyBind.subscribe(viewModel.searchSuccesfulProperty(), value -> { diff --git a/src/main/java/org/jabref/gui/JabRefDialogService.java b/src/main/java/org/jabref/gui/JabRefDialogService.java index 9709223cc2b..45924192ee5 100644 --- a/src/main/java/org/jabref/gui/JabRefDialogService.java +++ b/src/main/java/org/jabref/gui/JabRefDialogService.java @@ -364,7 +364,7 @@ public void notify(String message) { .text( "(" + Localization.lang("Check the event log to see all notifications") + ")" + "\n\n" + message) - .onAction((e)-> { + .onAction(e-> { ErrorConsoleAction ec = new ErrorConsoleAction(); ec.execute(); })) diff --git a/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java b/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java index de43a067eb8..619aaa88770 100644 --- a/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java +++ b/src/main/java/org/jabref/gui/backup/BackupResolverDialog.java @@ -47,7 +47,7 @@ public BackupResolverDialog(Path originalPath, Path backupDir) { HyperlinkLabel contentLabel = new HyperlinkLabel(content); contentLabel.setPrefWidth(360); - contentLabel.setOnAction((e) -> { + contentLabel.setOnAction(e -> { if (backupPathOpt.isPresent()) { if (!(e.getSource() instanceof Hyperlink)) { return; diff --git a/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java b/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java index 418706815b2..5250767f6c3 100644 --- a/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java +++ b/src/main/java/org/jabref/gui/bibtexextractor/BibtexExtractorViewModel.java @@ -82,7 +82,7 @@ private void parseUsingGrobid() { GrobidCitationFetcher grobidCitationFetcher = new GrobidCitationFetcher(preferencesService.getGrobidPreferences(), preferencesService.getImportFormatPreferences()); BackgroundTask.wrap(() -> grobidCitationFetcher.performSearch(inputTextProperty.getValue())) .onRunning(() -> dialogService.notify(Localization.lang("Your text is being parsed..."))) - .onFailure((e) -> { + .onFailure(e -> { if (e instanceof FetcherException) { String msg = Localization.lang("There are connection issues with a JabRef server. Detailed information: %0", e.getMessage()); diff --git a/src/main/java/org/jabref/gui/bibtexextractor/ExtractBibtexDialog.java b/src/main/java/org/jabref/gui/bibtexextractor/ExtractBibtexDialog.java index 95d6ba5a692..db9f2c4d5f6 100644 --- a/src/main/java/org/jabref/gui/bibtexextractor/ExtractBibtexDialog.java +++ b/src/main/java/org/jabref/gui/bibtexextractor/ExtractBibtexDialog.java @@ -48,7 +48,7 @@ public ExtractBibtexDialog() { buttonParse = (Button) getDialogPane().lookupButton(parseButtonType); buttonParse.setTooltip(new Tooltip((Localization.lang("Starts the extraction and adds the resulting entries to the currently opened database")))); - buttonParse.setOnAction((event) -> viewModel.startParsing()); + buttonParse.setOnAction(event -> viewModel.startParsing()); buttonParse.disableProperty().bind(viewModel.inputTextProperty().isEmpty()); } diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java index 77d38da37a9..41b47510acd 100644 --- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java +++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesAction.java @@ -57,7 +57,7 @@ public void execute() { Localization.lang("Copy linked files to folder..."), exportTask); Globals.TASK_EXECUTOR.execute(exportTask); - exportTask.setOnSucceeded((e) -> showDialog(exportTask.getValue())); + exportTask.setOnSucceeded(e -> showDialog(exportTask.getValue())); }); } } diff --git a/src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogView.java b/src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogView.java index e8d6d20f859..7b1bfcc2f58 100644 --- a/src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogView.java +++ b/src/main/java/org/jabref/gui/copyfiles/CopyFilesDialogView.java @@ -56,6 +56,6 @@ private void setupTable() { })); tvResult.setItems(viewModel.copyFilesResultListProperty()); - tvResult.setColumnResizePolicy((param) -> true); + tvResult.setColumnResizePolicy(param -> true); } } diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index c08ca68aa2c..f3c3c3e3b4f 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -109,7 +109,7 @@ public void openFolderAndSelectFile(Path filePath) throws IOException { cmd = new String[] {"nemo", absoluteFilePath}; // Although nemo is based on nautilus it does not support --select, it directly highlights the file } } - ProcessBuilder processBuilder = new ProcessBuilder((cmd)); + ProcessBuilder processBuilder = new ProcessBuilder(cmd); Process process = processBuilder.start(); StreamGobbler streamGobblerInput = new StreamGobbler(process.getInputStream(), LOGGER::debug); diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java index 611240c2701..29d91ec02d1 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java @@ -87,8 +87,8 @@ public void execute() { } private void searchPossibleDuplicates(List entries, BibDatabaseMode databaseMode) { - for (int i = 0; (i < (entries.size() - 1)); i++) { - for (int j = i + 1; (j < entries.size()); j++) { + for (int i = 0; i < (entries.size() - 1); i++) { + for (int j = i + 1; j < entries.size(); j++) { if (Thread.interrupted()) { return; } diff --git a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationViewModel.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationViewModel.java index 13a881e701e..d6cd4175103 100644 --- a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationViewModel.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationViewModel.java @@ -31,7 +31,7 @@ private void setupContentProperties(FileAnnotation annotation) { this.content.set(annotation.getLinkedFileAnnotation().getContent()); String annotationContent = annotation.getContent(); String illegibleTextMessage = Localization.lang("The marked area does not contain any legible text!"); - String markingContent = (annotationContent.isEmpty() ? illegibleTextMessage : annotationContent); + String markingContent = annotationContent.isEmpty() ? illegibleTextMessage : annotationContent; this.marking.set(removePunctuationMark(markingContent)); } else { String content = annotation.getContent(); diff --git a/src/main/java/org/jabref/gui/errorconsole/LogEventViewModel.java b/src/main/java/org/jabref/gui/errorconsole/LogEventViewModel.java index 0694c080b14..24152e82f01 100644 --- a/src/main/java/org/jabref/gui/errorconsole/LogEventViewModel.java +++ b/src/main/java/org/jabref/gui/errorconsole/LogEventViewModel.java @@ -37,12 +37,12 @@ public String getStyleClass() { public JabRefIcon getIcon() { switch (logEvent.getLevel()) { case ERROR: - return (IconTheme.JabRefIcons.INTEGRITY_FAIL); + return IconTheme.JabRefIcons.INTEGRITY_FAIL; case WARN: - return (IconTheme.JabRefIcons.INTEGRITY_WARN); + return IconTheme.JabRefIcons.INTEGRITY_WARN; case INFO: default: - return (IconTheme.JabRefIcons.INTEGRITY_INFO); + return IconTheme.JabRefIcons.INTEGRITY_INFO; } } diff --git a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java index 13ddbe4bd34..c7ac781fa39 100644 --- a/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java +++ b/src/main/java/org/jabref/gui/externalfiles/UnlinkedFilesDialogView.java @@ -208,7 +208,7 @@ private void initResultTable() { colStatus.setCellValueFactory(cellData -> cellData.getValue().icon()); colStatus.setCellFactory(new ValueTableCellFactory().withGraphic(JabRefIcon::getGraphicNode)); - importResultTable.setColumnResizePolicy((param) -> true); + importResultTable.setColumnResizePolicy(param -> true); importResultTable.setItems(viewModel.resultTableItems()); } diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index 723a765ba69..614176aaee8 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -303,7 +303,7 @@ public void moveToDefaultDirectory() { } Optional file = linkedFile.findIn(databaseContext, preferences.getFilePreferences()); - if ((file.isPresent())) { + if (file.isPresent()) { // Found the linked file, so move it try { linkedFileHandler.moveToDefaultDirectory(); diff --git a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java index f63eafc2470..ff9cf822a82 100644 --- a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java @@ -59,7 +59,7 @@ public class GroupNodeViewModel { private final CustomLocalDragboard localDragBoard; private final ObservableList entriesList; private final PreferencesService preferencesService; - private final InvalidationListener onInvalidatedGroup = (listener) -> refreshGroup(); + private final InvalidationListener onInvalidatedGroup = listener -> refreshGroup(); public GroupNodeViewModel(BibDatabaseContext databaseContext, StateManager stateManager, TaskExecutor taskExecutor, GroupTreeNode groupNode, CustomLocalDragboard localDragBoard, PreferencesService preferencesService) { this.databaseContext = Objects.requireNonNull(databaseContext); diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 9da46651442..792fc00c42a 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -175,7 +175,7 @@ private void initialize() { BindingsHelper.bindContentBidirectional( groupTree.getSelectionModel().getSelectedItems(), viewModel.selectedGroupsProperty(), - (newSelectedGroups) -> newSelectedGroups.forEach(this::selectNode), + newSelectedGroups -> newSelectedGroups.forEach(this::selectNode), this::updateSelection )); @@ -275,7 +275,7 @@ private StackPane createNumberCell(GroupNodeViewModel group) { } Text text = new Text(); EasyBind.subscribe(preferencesService.getGroupsPreferences().displayGroupCountProperty(), - (newValue) -> { + newValue -> { if (text.textProperty().isBound()) { text.textProperty().unbind(); text.setText(""); @@ -442,11 +442,11 @@ private void setupDragScrolling() { scrollBar.setValue(newValue); })); - groupTree.setOnScroll((event) -> scrollTimer.stop()); - groupTree.setOnDragDone((event) -> scrollTimer.stop()); - groupTree.setOnDragEntered((event) -> scrollTimer.stop()); - groupTree.setOnDragDropped((event) -> scrollTimer.stop()); - groupTree.setOnDragExited((event) -> { + groupTree.setOnScroll(event -> scrollTimer.stop()); + groupTree.setOnDragDone(event -> scrollTimer.stop()); + groupTree.setOnDragEntered(event -> scrollTimer.stop()); + groupTree.setOnDragDropped(event -> scrollTimer.stop()); + groupTree.setOnDragExited(event -> { if (event.getY() > 0) { scrollVelocity = 1.0 / SCROLL_SPEED; } else { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index b57f0bc5d63..2b08879d9cb 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -219,7 +219,7 @@ boolean onlyMinorChanges(AbstractGroup oldGroup, AbstractGroup newGroup) { return Objects.equals(oldRegexKeywordGroup.getSearchField().getName(), newRegexKeywordGroup.getSearchField().getName()) && Objects.equals(oldRegexKeywordGroup.getSearchExpression(), newRegexKeywordGroup.getSearchExpression()) && Objects.equals(oldRegexKeywordGroup.isCaseSensitive(), newRegexKeywordGroup.isCaseSensitive()); - } else if ((oldGroup.getClass() == SearchGroup.class)) { + } else if (oldGroup.getClass() == SearchGroup.class) { SearchGroup oldSearchGroup = (SearchGroup) oldGroup; SearchGroup newSearchGroup = (SearchGroup) newGroup; diff --git a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java index ca9127fef2c..adad1645feb 100644 --- a/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java +++ b/src/main/java/org/jabref/gui/importer/GenerateEntryFromIdAction.java @@ -56,7 +56,7 @@ public void execute() { backgroundTask.titleProperty().set(Localization.lang("Import by ID")); backgroundTask.showToUser(true); backgroundTask.onRunning(() -> dialogService.notify("%s".formatted(backgroundTask.messageProperty().get()))); - backgroundTask.onFailure((exception) -> { + backgroundTask.onFailure(exception -> { String fetcherExceptionMessage = exception.getMessage(); String msg; @@ -76,7 +76,7 @@ public void execute() { preferencesService, stateManager).execute(); } }); - backgroundTask.onSuccess((bibEntry) -> { + backgroundTask.onSuccess(bibEntry -> { Optional result = bibEntry; if (result.isPresent()) { final BibEntry entry = result.get(); diff --git a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java index cf21a38a30c..07382713e29 100644 --- a/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java +++ b/src/main/java/org/jabref/gui/importer/GrobidOptInDialogHelper.java @@ -29,7 +29,7 @@ public static boolean showAndWaitIfUserIsUndecided(DialogService dialogService, Localization.lang("Remote services"), Localization.lang("Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results."), Localization.lang("Do not ask again"), - (optOut) -> preferences.grobidOptOutProperty().setValue(optOut)); + optOut -> preferences.grobidOptOutProperty().setValue(optOut)); preferences.grobidEnabledProperty().setValue(grobidEnabled); return grobidEnabled; } diff --git a/src/main/java/org/jabref/gui/libraryproperties/general/GeneralPropertiesViewModel.java b/src/main/java/org/jabref/gui/libraryproperties/general/GeneralPropertiesViewModel.java index 0830d7d008c..fa0cc2c4ea1 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/general/GeneralPropertiesViewModel.java +++ b/src/main/java/org/jabref/gui/libraryproperties/general/GeneralPropertiesViewModel.java @@ -54,7 +54,7 @@ public class GeneralPropertiesViewModel implements PropertiesTabViewModel { @Override public void setValues() { - boolean isShared = (databaseContext.getLocation() == DatabaseLocation.SHARED); + boolean isShared = databaseContext.getLocation() == DatabaseLocation.SHARED; encodingDisableProperty.setValue(isShared); // the encoding of shared database is always UTF-8 selectedEncodingProperty.setValue(metaData.getEncoding().orElse(StandardCharsets.UTF_8)); diff --git a/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java b/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java index 92c8404ca39..b7da7f5be6e 100644 --- a/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java +++ b/src/main/java/org/jabref/gui/maintable/OpenFolderAction.java @@ -41,7 +41,7 @@ public OpenFolderAction(DialogService dialogService, StateManager stateManager, public void execute() { stateManager.getActiveDatabase().ifPresent(databaseContext -> { if (entry == null) { - stateManager.getSelectedEntries().stream().filter((entry) -> !entry.getFiles().isEmpty()).forEach(entry -> { + stateManager.getSelectedEntries().stream().filter(entry -> !entry.getFiles().isEmpty()).forEach(entry -> { LinkedFileViewModel linkedFileViewModel = new LinkedFileViewModel( entry.getFiles().get(0), entry, diff --git a/src/main/java/org/jabref/gui/openoffice/Bootstrap.java b/src/main/java/org/jabref/gui/openoffice/Bootstrap.java index ff5a4e980c8..be47f545264 100644 --- a/src/main/java/org/jabref/gui/openoffice/Bootstrap.java +++ b/src/main/java/org/jabref/gui/openoffice/Bootstrap.java @@ -282,7 +282,7 @@ public static final XComponentContext bootstrap(String[] argArray, Path path) th // We need a socket, pipe does not work. https://api.libreoffice.org/examples/examples.html String[] cmdArray = new String[argArray.length + 2]; cmdArray[0] = path.toAbsolutePath().toString(); - cmdArray[1] = ("--accept=socket,host=localhost,port=2083" + ";urp;"); + cmdArray[1] = "--accept=socket,host=localhost,port=2083" + ";urp;"; System.arraycopy(argArray, 0, cmdArray, 2, argArray.length); diff --git a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java index 20254bc0bd8..f89fcde15ba 100644 --- a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java +++ b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java @@ -147,10 +147,10 @@ void showDialog(String errorTitle, OOError err) { } OOVoidResult collectResults(String errorTitle, List> results) { - String msg = (results.stream() + String msg = results.stream() .filter(OOVoidResult::isError) .map(e -> e.getError().getLocalizedMessage()) - .collect(Collectors.joining("\n\n"))); + .collect(Collectors.joining("\n\n")); if (msg.isEmpty()) { return OOVoidResult.ok(); } else { @@ -219,11 +219,11 @@ private static OOVoidResult checkRangeOverlaps(XTextDocument doc, OOFro boolean requireSeparation = false; int maxReportedOverlaps = 10; try { - return (frontend.checkRangeOverlaps(doc, + return frontend.checkRangeOverlaps(doc, new ArrayList<>(), requireSeparation, maxReportedOverlaps) - .mapError(OOError::from)); + .mapError(OOError::from); } catch (NoDocumentException ex) { return OOVoidResult.error(OOError.from(ex).setTitle(errorTitle)); } catch (WrappedTargetException ex) { diff --git a/src/main/java/org/jabref/gui/openoffice/OOBibBaseConnect.java b/src/main/java/org/jabref/gui/openoffice/OOBibBaseConnect.java index 8a12722a17b..e256793cb9b 100644 --- a/src/main/java/org/jabref/gui/openoffice/OOBibBaseConnect.java +++ b/src/main/java/org/jabref/gui/openoffice/OOBibBaseConnect.java @@ -146,9 +146,9 @@ public String toString() { } } - List viewModel = (list.stream() + List viewModel = list.stream() .map(DocumentTitleViewModel::new) - .collect(Collectors.toList())); + .collect(Collectors.toList()); // This whole method is part of a background task when // auto-detecting instances, so we need to show dialog in FX diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 4ddf2ac7a42..a0b3e7344ee 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -155,9 +155,9 @@ private boolean getOrUpdateTheStyle(String title) { style.ensureUpToDate(); } catch (IOException ex) { LOGGER.warn("Unable to reload style file '" + style.getPath() + "'", ex); - String msg = (Localization.lang("Unable to reload style file") + String msg = Localization.lang("Unable to reload style file") + "'" + style.getPath() + "'" - + "\n" + ex.getMessage()); + + "\n" + ex.getMessage(); new OOError(title, msg, ex).showErrorDialog(dialogService); return FAIL; } @@ -330,7 +330,7 @@ private void connectManually() { } private void updateButtonAvailability() { - boolean isConnected = (ooBase != null); + boolean isConnected = ooBase != null; boolean isConnectedToDocument = isConnected && !ooBase.isDocumentConnectionMissing(); // For these, we need to watch something @@ -338,7 +338,7 @@ private void updateButtonAvailability() { boolean hasDatabase = true; // !getBaseList().isEmpty(); boolean hasSelectedBibEntry = true; - selectDocument.setDisable(!(isConnected)); + selectDocument.setDisable(!isConnected); pushEntries.setDisable(!(isConnectedToDocument && hasStyle && hasDatabase)); boolean canCite = isConnectedToDocument && hasStyle && hasSelectedBibEntry; @@ -418,9 +418,9 @@ private static CitationType citationTypeFromOptions(boolean withText, boolean in if (!withText) { return CitationType.INVISIBLE_CIT; } - return (inParenthesis + return inParenthesis ? CitationType.AUTHORYEAR_PAR - : CitationType.AUTHORYEAR_INTEXT); + : CitationType.AUTHORYEAR_INTEXT; } private void pushEntries(CitationType citationType, boolean addPageInfo) { @@ -477,9 +477,9 @@ private void pushEntries(CitationType citationType, boolean addPageInfo) { } Optional syncOptions = - (preferencesService.getOpenOfficePreferences().getSyncWhenCiting() + preferencesService.getOpenOfficePreferences().getSyncWhenCiting() ? Optional.of(new Update.SyncOptions(getBaseList())) - : Optional.empty()); + : Optional.empty(); ooBase.guiActionInsertEntry(entries, database, diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesFilterDialog.java b/src/main/java/org/jabref/gui/preferences/PreferencesFilterDialog.java index f0ae7e486b0..9b57810578b 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesFilterDialog.java +++ b/src/main/java/org/jabref/gui/preferences/PreferencesFilterDialog.java @@ -58,7 +58,7 @@ private void initialize() { return null; } String lowerCaseSearchText = searchText.toLowerCase(Locale.ROOT); - return (option) -> option.getKey().toLowerCase(Locale.ROOT).contains(lowerCaseSearchText); + return option -> option.getKey().toLowerCase(Locale.ROOT).contains(lowerCaseSearchText); })); columnType.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getType())); columnKey.setCellValueFactory(data -> new ReadOnlyStringWrapper(data.getValue().getKey())); diff --git a/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTab.java b/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTab.java index 8a68708a785..e58dd4bd94f 100644 --- a/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTab.java +++ b/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTab.java @@ -113,7 +113,7 @@ private void setupEntryTypesTable() { }) .withTooltip((type, name) -> { if (type instanceof CustomEntryTypeViewModel) { - return (Localization.lang("Remove entry type") + " " + name); + return Localization.lang("Remove entry type") + " " + name; } else { return null; } diff --git a/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java b/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java index 679a713f13e..c4bf34cbab7 100644 --- a/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/customentrytypes/CustomEntryTypesTabViewModel.java @@ -57,7 +57,7 @@ public class CustomEntryTypesTabViewModel implements PreferenceTabViewModel { private final Validator fieldValidator; private final Set multiLineFields = new HashSet<>(); - Predicate isMultiline = (field) -> this.multiLineFields.contains(field) || field.getProperties().contains(FieldProperty.MULTILINE_TEXT); + Predicate isMultiline = field -> this.multiLineFields.contains(field) || field.getProperties().contains(FieldProperty.MULTILINE_TEXT); public CustomEntryTypesTabViewModel(BibDatabaseMode mode, BibEntryTypesManager entryTypesManager, diff --git a/src/main/java/org/jabref/gui/preferences/customentrytypes/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/preferences/customentrytypes/EntryTypeViewModel.java index db001559d44..4083de4f1ec 100644 --- a/src/main/java/org/jabref/gui/preferences/customentrytypes/EntryTypeViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/customentrytypes/EntryTypeViewModel.java @@ -29,7 +29,7 @@ public EntryTypeViewModel(BibEntryType entryType, Predicate isMultiline) bibField.priority(), isMultiline.test(bibField.field()))) .collect(Collectors.toList()); - fields = FXCollections.observableArrayList((allFieldsForType)); + fields = FXCollections.observableArrayList(allFieldsForType); } @Override diff --git a/src/main/java/org/jabref/gui/preferences/journals/JournalAbbreviationsTabViewModel.java b/src/main/java/org/jabref/gui/preferences/journals/JournalAbbreviationsTabViewModel.java index 78da755da3f..c7be0ebe1a3 100644 --- a/src/main/java/org/jabref/gui/preferences/journals/JournalAbbreviationsTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/journals/JournalAbbreviationsTabViewModel.java @@ -341,7 +341,7 @@ public void storeSettings() { shouldWriteLists = false; } }) - .onSuccess((success) -> Globals.journalAbbreviationRepository = + .onSuccess(success -> Globals.journalAbbreviationRepository = JournalAbbreviationLoader.loadRepository(abbreviationsPreferences)) .onFailure(exception -> LOGGER.error("Failed to store journal preferences.", exception)) .executeWith(taskExecutor); diff --git a/src/main/java/org/jabref/gui/preferences/keybindings/KeyBindingsTab.java b/src/main/java/org/jabref/gui/preferences/keybindings/KeyBindingsTab.java index ecfe7d7286f..973159b9378 100644 --- a/src/main/java/org/jabref/gui/preferences/keybindings/KeyBindingsTab.java +++ b/src/main/java/org/jabref/gui/preferences/keybindings/KeyBindingsTab.java @@ -75,7 +75,7 @@ private void initialize() { private MenuItem createMenuItem(KeyBindingPreset preset) { MenuItem item = new MenuItem(preset.getName()); - item.setOnAction((event) -> viewModel.loadPreset(preset)); + item.setOnAction(event -> viewModel.loadPreset(preset)); return item; } diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java index e7e9256c63b..0b022eca421 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java @@ -444,12 +444,12 @@ public SearchPopupSkin(AutoCompletePopup control) { } private void registerEventListener() { - this.suggestionList.setOnMouseClicked((me) -> { + this.suggestionList.setOnMouseClicked(me -> { if (me.getButton() == MouseButton.PRIMARY) { this.onSuggestionChosen(this.suggestionList.getSelectionModel().getSelectedItem()); } }); - this.suggestionList.setOnKeyPressed((ke) -> { + this.suggestionList.setOnKeyPressed(ke -> { switch (ke.getCode()) { case TAB: case ENTER: diff --git a/src/main/java/org/jabref/gui/search/SearchResultsTableDataModel.java b/src/main/java/org/jabref/gui/search/SearchResultsTableDataModel.java index b0b039f4a98..967c397b799 100644 --- a/src/main/java/org/jabref/gui/search/SearchResultsTableDataModel.java +++ b/src/main/java/org/jabref/gui/search/SearchResultsTableDataModel.java @@ -42,7 +42,7 @@ public SearchResultsTableDataModel(BibDatabaseContext bibDatabaseContext, Prefer } entriesFiltered = new FilteredList<>(entriesViewModel); - entriesFiltered.predicateProperty().bind(EasyBind.map(stateManager.activeSearchQueryProperty(), (query) -> entry -> isMatchedBySearch(query, entry))); + entriesFiltered.predicateProperty().bind(EasyBind.map(stateManager.activeSearchQueryProperty(), query -> entry -> isMatchedBySearch(query, entry))); // We need to wrap the list since otherwise sorting in the table does not work entriesSorted = new SortedList<>(entriesFiltered); diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java index 992ed0482b0..d6968521a17 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java @@ -63,7 +63,7 @@ public SharedDatabaseLoginDialogView(JabRefFrame frame) { Button btnConnect = (Button) this.getDialogPane().lookupButton(connectButton); // must be set here, because in initialize the button is still null btnConnect.disableProperty().bind(viewModel.formValidation().validProperty().not()); - btnConnect.textProperty().bind(EasyBind.map(viewModel.loadingProperty(), loading -> (loading) ? Localization.lang("Connecting...") : Localization.lang("Connect"))); + btnConnect.textProperty().bind(EasyBind.map(viewModel.loadingProperty(), loading -> loading ? Localization.lang("Connecting...") : Localization.lang("Connect"))); } @FXML diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java index 36411223cae..134d39b2895 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java @@ -263,8 +263,8 @@ private boolean isSharedDatabaseAlreadyPresent(DBMSConnectionProperties connecti return panels.parallelStream().anyMatch(panel -> { BibDatabaseContext context = panel.getBibDatabaseContext(); - return ((context.getLocation() == DatabaseLocation.SHARED) && - connectionProperties.equals(context.getDBMSSynchronizer().getConnectionProperties())); + return (context.getLocation() == DatabaseLocation.SHARED) && + connectionProperties.equals(context.getDBMSSynchronizer().getConnectionProperties()); }); } diff --git a/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionView.java b/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionView.java index db9e074a596..03eba518a39 100644 --- a/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionView.java +++ b/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionView.java @@ -124,7 +124,7 @@ public ManageStudyDefinitionView(Study study, Path studyDirectory) { } private void setupSaveSurveyButton(boolean isEdit) { - Button saveSurveyButton = ((Button) this.getDialogPane().lookupButton(saveSurveyButtonType)); + Button saveSurveyButton = (Button) this.getDialogPane().lookupButton(saveSurveyButtonType); if (!isEdit) { saveSurveyButton.setText(Localization.lang("Start survey")); diff --git a/src/main/java/org/jabref/gui/undo/CountingUndoManager.java b/src/main/java/org/jabref/gui/undo/CountingUndoManager.java index 9cb372a29b1..75a044a6a1f 100644 --- a/src/main/java/org/jabref/gui/undo/CountingUndoManager.java +++ b/src/main/java/org/jabref/gui/undo/CountingUndoManager.java @@ -44,7 +44,7 @@ public synchronized void markUnchanged() { } public synchronized boolean hasChanged() { - return (current != unchangedPoint); + return current != unchangedPoint; } public void registerListener(Object object) { diff --git a/src/main/java/org/jabref/gui/undo/UndoableStringChange.java b/src/main/java/org/jabref/gui/undo/UndoableStringChange.java index 684e5942b7d..883f1675750 100644 --- a/src/main/java/org/jabref/gui/undo/UndoableStringChange.java +++ b/src/main/java/org/jabref/gui/undo/UndoableStringChange.java @@ -20,10 +20,10 @@ public UndoableStringChange(BibtexString string, boolean nameChange, String oldV @Override public String getPresentationName() { - return (nameChange ? Localization.lang("change string name %0 to %1", StringUtil.boldHTML(oldValue), + return nameChange ? Localization.lang("change string name %0 to %1", StringUtil.boldHTML(oldValue), StringUtil.boldHTML(newValue)) : Localization.lang("change string content %0 to %1", - StringUtil.boldHTML(oldValue), StringUtil.boldHTML(newValue))); + StringUtil.boldHTML(oldValue), StringUtil.boldHTML(newValue)); } @Override diff --git a/src/main/java/org/jabref/logic/bst/BstVMVisitor.java b/src/main/java/org/jabref/logic/bst/BstVMVisitor.java index f552d1e729c..100279e35a3 100644 --- a/src/main/java/org/jabref/logic/bst/BstVMVisitor.java +++ b/src/main/java/org/jabref/logic/bst/BstVMVisitor.java @@ -253,7 +253,7 @@ public Integer visitStackitem(BstParser.StackitemContext ctx) { } } catch (BstVMException e) { bstVMContext.path().ifPresentOrElse( - (path) -> LOGGER.error("{} ({})", e.getMessage(), path), + path -> LOGGER.error("{} ({})", e.getMessage(), path), () -> LOGGER.error(e.getMessage())); throw e; } diff --git a/src/main/java/org/jabref/logic/bst/util/BstNameFormatter.java b/src/main/java/org/jabref/logic/bst/util/BstNameFormatter.java index c4986dc12dd..cd65735aa57 100644 --- a/src/main/java/org/jabref/logic/bst/util/BstNameFormatter.java +++ b/src/main/java/org/jabref/logic/bst/util/BstNameFormatter.java @@ -95,7 +95,7 @@ public static String formatName(Author author, String format) { continue; } - if ((control.length() > 2)) { + if (control.length() > 2) { LOGGER.warn("Format string in format.name$ may only be one or two character long on brace level 1 in group {}: {}", group, format); } @@ -216,7 +216,7 @@ public static String formatName(Author author, String format) { } i++; } - if ((braceLevel != 0)) { + if (braceLevel != 0) { LOGGER.warn("Unbalanced brace in format string for nameFormat: {}", format); } diff --git a/src/main/java/org/jabref/logic/bst/util/BstPurifier.java b/src/main/java/org/jabref/logic/bst/util/BstPurifier.java index 90818a0749f..2b0fce0b735 100644 --- a/src/main/java/org/jabref/logic/bst/util/BstPurifier.java +++ b/src/main/java/org/jabref/logic/bst/util/BstPurifier.java @@ -67,7 +67,7 @@ public static String purify(String toPurify) { } i++; } - if ((braceLevel != 0)) { + if (braceLevel != 0) { LOGGER.warn("Unbalanced brace in string for purify$: {}", toPurify); } diff --git a/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java index d0ce1d6d103..13fda45cedf 100644 --- a/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java @@ -521,7 +521,7 @@ public static String getFieldValue(BibEntry entry, String pattern, Character key */ private static AuthorList createAuthorList(String unparsedAuthors) { return AuthorList.parse(unparsedAuthors).getAuthors().stream() - .map((author) -> { + .map(author -> { // If the author is an institution, use an institution key instead of the full name String lastName = author.getLast() .map(lastPart -> isInstitution(author) ? @@ -1264,7 +1264,7 @@ private static String generateInstitutionKey(String content) { // If there are more than 3 parts, only keep the first character of each word final int[] codePoints = tokenParts.stream() .filter(Predicate.not(String::isBlank)) - .mapToInt((s) -> s.codePointAt(0)) + .mapToInt(s -> s.codePointAt(0)) .toArray(); rest = new String(codePoints, 0, codePoints.length); } else { diff --git a/src/main/java/org/jabref/logic/crawler/StudyFetcher.java b/src/main/java/org/jabref/logic/crawler/StudyFetcher.java index c39ba7efe52..97dd8b0d8a6 100644 --- a/src/main/java/org/jabref/logic/crawler/StudyFetcher.java +++ b/src/main/java/org/jabref/logic/crawler/StudyFetcher.java @@ -64,7 +64,7 @@ private FetchResult performSearchOnQueryForFetcher(String searchQuery, SearchBas try { List fetchResult = new ArrayList<>(); if (fetcher instanceof PagedSearchBasedFetcher) { - int pages = ((int) Math.ceil(((double) MAX_AMOUNT_OF_RESULTS_PER_FETCHER) / ((PagedSearchBasedFetcher) fetcher).getPageSize())); + int pages = (int) Math.ceil(((double) MAX_AMOUNT_OF_RESULTS_PER_FETCHER) / ((PagedSearchBasedFetcher) fetcher).getPageSize()); for (int page = 0; page < pages; page++) { fetchResult.addAll(((PagedSearchBasedFetcher) fetcher).performSearchPaged(searchQuery, page).getContent()); } diff --git a/src/main/java/org/jabref/logic/database/DuplicateCheck.java b/src/main/java/org/jabref/logic/database/DuplicateCheck.java index 46ef4f2e0bb..3090c9a8778 100644 --- a/src/main/java/org/jabref/logic/database/DuplicateCheck.java +++ b/src/main/java/org/jabref/logic/database/DuplicateCheck.java @@ -264,8 +264,8 @@ private static boolean isSingleFieldEqual(BibEntry one, BibEntry two, Field fiel if (stringOne.isEmpty() || stringTwo.isEmpty()) { return false; } - return (StringUtil.unifyLineBreaks(stringOne.get(), OS.NEWLINE).equals( - StringUtil.unifyLineBreaks(stringTwo.get(), OS.NEWLINE))); + return StringUtil.unifyLineBreaks(stringOne.get(), OS.NEWLINE).equals( + StringUtil.unifyLineBreaks(stringTwo.get(), OS.NEWLINE)); } /** diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ArXivFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/ArXivFetcher.java index 8ac63c4056c..6bb412e040c 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ArXivFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ArXivFetcher.java @@ -601,7 +601,7 @@ public Page performSearchPaged(QueryNode luceneQuery, int pageNumber) String transformedQuery = transformer.transformLuceneQuery(luceneQuery).orElse(""); List searchResult = searchForEntries(transformedQuery, pageNumber) .stream() - .map((arXivEntry) -> arXivEntry.toBibEntry(importFormatPreferences.bibEntryPreferences().getKeywordSeparator())) + .map(arXivEntry -> arXivEntry.toBibEntry(importFormatPreferences.bibEntryPreferences().getKeywordSeparator())) .collect(Collectors.toList()); return new Page<>(transformedQuery, pageNumber, filterYears(searchResult, transformer)); } @@ -628,7 +628,7 @@ protected CompletableFuture> asyncPerformSearchById(String id @Override public Optional performSearchById(String identifier) throws FetcherException { return searchForEntryById(identifier) - .map((arXivEntry) -> arXivEntry.toBibEntry(importFormatPreferences.bibEntryPreferences().getKeywordSeparator())); + .map(arXivEntry -> arXivEntry.toBibEntry(importFormatPreferences.bibEntryPreferences().getKeywordSeparator())); } @Override diff --git a/src/main/java/org/jabref/logic/importer/fetcher/BiodiversityLibrary.java b/src/main/java/org/jabref/logic/importer/fetcher/BiodiversityLibrary.java index 7a75a38675e..14449fc0f19 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/BiodiversityLibrary.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/BiodiversityLibrary.java @@ -162,7 +162,7 @@ private String toAuthors(JSONArray authors) { // input: list of { "Name": "Author name,"} return IntStream.range(0, authors.length()) .mapToObj(authors::getJSONObject) - .map((author) -> new Author( + .map(author -> new Author( author.optString("Name", ""), "", "", "", "")) .collect(AuthorList.collect()) .getAsFirstLastNamesWithAnd(); diff --git a/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java b/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java index 8a372d1678c..d8684039af0 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/CrossRef.java @@ -154,7 +154,7 @@ private String toAuthors(JSONArray authors) { // input: list of {"given":"A.","family":"Riel","affiliation":[]} return IntStream.range(0, authors.length()) .mapToObj(authors::getJSONObject) - .map((author) -> new Author( + .map(author -> new Author( author.optString("given", ""), "", "", author.optString("family", ""), "")) .collect(AuthorList.collect()) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/DOABFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/DOABFetcher.java index 1b744e16f04..ff10e62c69d 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/DOABFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/DOABFetcher.java @@ -169,7 +169,7 @@ private BibEntry jsonToBibEntry(JSONArray metadataArray, JSONArray bitstreamArra } private Author toAuthor(String author) { - return AuthorList.parse((author)).getAuthor(0); + return AuthorList.parse(author).getAuthor(0); } private String namePreprocessing(String name) { diff --git a/src/main/java/org/jabref/logic/importer/fetcher/Medra.java b/src/main/java/org/jabref/logic/importer/fetcher/Medra.java index ebf06f56e57..22d457e9c1c 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/Medra.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/Medra.java @@ -88,7 +88,7 @@ private String toAuthors(JSONArray authors) { // input: list of {"literal":"A."} return IntStream.range(0, authors.length()) .mapToObj(authors::getJSONObject) - .map((author) -> author.has("literal") ? // quickly route through the literal string + .map(author -> author.has("literal") ? // quickly route through the literal string new Author(author.getString("literal"), "", "", "", "") : new Author(author.optString("given", ""), "", "", author.optString("family", ""), "")) .collect(AuthorList.collect()) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ResearchGate.java b/src/main/java/org/jabref/logic/importer/fetcher/ResearchGate.java index ca856474158..6c041c68653 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ResearchGate.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ResearchGate.java @@ -243,7 +243,7 @@ public List performSearch(QueryNode luceneQuery) throws FetcherExcepti private BufferedReader getInputStream(String urlString) { try { - URL url = new URL((urlString)); + URL url = new URL(urlString); return new BufferedReader(new InputStreamReader(url.openStream())); } catch (IOException e) { LOGGER.debug("Wrong URL:", e); diff --git a/src/main/java/org/jabref/logic/importer/fetcher/SemanticScholar.java b/src/main/java/org/jabref/logic/importer/fetcher/SemanticScholar.java index 1fceba269d8..4d56eb7aa6d 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/SemanticScholar.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/SemanticScholar.java @@ -188,7 +188,7 @@ private BibEntry jsonItemToBibEntry(JSONObject item) throws ParseException { entry.setField(StandardField.AUTHOR, IntStream.range(0, item.optJSONArray("authors").length()) .mapToObj(item.optJSONArray("authors")::getJSONObject) - .map((author) -> author.has("name") ? author.getString("name") : "") + .map(author -> author.has("name") ? author.getString("name") : "") .collect(Collectors.joining(" and "))); JSONObject externalIds = item.optJSONObject("externalIds"); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/CffImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/CffImporter.java index 325d221ba76..a69d2c41991 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/CffImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/CffImporter.java @@ -111,8 +111,8 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { // Translate CFF author format to JabRef author format String authorStr = citation.authors.stream() - .map((author) -> author.values) - .map((vals) -> vals.get("name") != null ? + .map(author -> author.values) + .map(vals -> vals.get("name") != null ? new Author(vals.get("name"), "", "", "", "") : new Author(vals.get("given-names"), null, vals.get("name-particle"), vals.get("family-names"), vals.get("name-suffix"))) diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MarcXmlParser.java b/src/main/java/org/jabref/logic/importer/fileformat/MarcXmlParser.java index a75ccad2e94..da60ad1fdfa 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MarcXmlParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MarcXmlParser.java @@ -403,7 +403,7 @@ private String getSubfield(String a, Element datafield) { for (Element subfield : subfields) { if (subfield.getAttribute("code").equals(a)) { - return (subfield.getTextContent()); + return subfield.getTextContent(); } } return null; diff --git a/src/main/java/org/jabref/logic/importer/fileformat/PicaXmlParser.java b/src/main/java/org/jabref/logic/importer/fileformat/PicaXmlParser.java index d97bfd81ed3..ba488552613 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/PicaXmlParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/PicaXmlParser.java @@ -446,7 +446,7 @@ private String getSubfield(String a, Element datafield) { for (Element subfield : liste) { if (subfield.getAttribute("code").equals(a)) { - return (subfield.getTextContent()); + return subfield.getTextContent(); } } return null; diff --git a/src/main/java/org/jabref/logic/importer/util/GrobidService.java b/src/main/java/org/jabref/logic/importer/util/GrobidService.java index 675062a1ff7..d410295bf3b 100644 --- a/src/main/java/org/jabref/logic/importer/util/GrobidService.java +++ b/src/main/java/org/jabref/logic/importer/util/GrobidService.java @@ -91,7 +91,7 @@ public List processPDF(Path filePath, ImportFormatPreferences importFo BibtexParser parser = new BibtexParser(importFormatPreferences, new DummyFileUpdateMonitor()); List result = parser.parseEntries(httpResponse); - result.forEach((entry) -> entry.setCitationKey("")); + result.forEach(entry -> entry.setCitationKey("")); return result; } } diff --git a/src/main/java/org/jabref/logic/layout/format/RemoveLatexCommandsFormatter.java b/src/main/java/org/jabref/logic/layout/format/RemoveLatexCommandsFormatter.java index e9681c4d698..f84d21efca2 100644 --- a/src/main/java/org/jabref/logic/layout/format/RemoveLatexCommandsFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/RemoveLatexCommandsFormatter.java @@ -59,7 +59,7 @@ public String format(String field) { } if (incommand) { // eat up all whitespace characters - while ((currentFieldPosition + 1 < field.length() && Character.isWhitespace(field.charAt(currentFieldPosition + 1)))) { + while (currentFieldPosition + 1 < field.length() && Character.isWhitespace(field.charAt(currentFieldPosition + 1))) { currentFieldPosition++; } } diff --git a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java index 7ed8ea37382..c7dbfb44557 100644 --- a/src/main/java/org/jabref/logic/msbib/MSBibConverter.java +++ b/src/main/java/org/jabref/logic/msbib/MSBibConverter.java @@ -101,7 +101,7 @@ public static MSBibEntry convert(BibEntry entry) { } // TODO: currently this can never happen - if (("InternetSite".equals(msBibType) || "DocumentFromInternetSite".equals(msBibType))) { + if ("InternetSite".equals(msBibType) || "DocumentFromInternetSite".equals(msBibType)) { result.internetSiteTitle = entry.getLatexFreeField(StandardField.TITLE).orElse(null); } diff --git a/src/main/java/org/jabref/logic/openoffice/action/EditMerge.java b/src/main/java/org/jabref/logic/openoffice/action/EditMerge.java index eebdf65d4f5..c958d53e5d2 100644 --- a/src/main/java/org/jabref/logic/openoffice/action/EditMerge.java +++ b/src/main/java/org/jabref/logic/openoffice/action/EditMerge.java @@ -59,9 +59,9 @@ public static boolean mergeCitationGroups(XTextDocument doc, OOFrontend frontend for (JoinableGroupData joinableGroupData : joinableGroups) { List groups = joinableGroupData.group; - List newCitations = (groups.stream() + List newCitations = groups.stream() .flatMap(group -> group.citationsInStorageOrder.stream()) - .collect(Collectors.toList())); + .collect(Collectors.toList()); CitationType citationType = groups.get(0).citationType; List> pageInfos = frontend.backend.combinePageInfos(groups); @@ -179,7 +179,7 @@ private static boolean checkAddToGroup(ScanState state, CitationGroup group, XTe // Sanity check: the current range should start later than the previous. int textOrder = UnoTextRange.compareStarts(state.prevRange, currentRange); - if (textOrder != (-1)) { + if (textOrder != -1) { String msg = String.format("MergeCitationGroups:" + " \"%s\" supposed to be followed by \"%s\"," @@ -214,7 +214,7 @@ private static boolean checkAddToGroup(ScanState state, CitationGroup group, XTe XTextRange rangeStart = currentRange.getStart(); boolean couldExpand = true; XTextCursor thisCharCursor = - (currentRange.getText().createTextCursorByRange(state.cursorBetween.getEnd())); + currentRange.getText().createTextCursorByRange(state.cursorBetween.getEnd()); while (couldExpand && (UnoTextRange.compareEnds(state.cursorBetween, rangeStart) < 0)) { // @@ -264,8 +264,8 @@ private static void addToCurrentGroup(ScanState state, CitationGroup group, XTex // If new group, create currentGroupCursor if (isNewGroup) { - state.currentGroupCursor = (currentRange.getText() - .createTextCursorByRange(currentRange.getStart())); + state.currentGroupCursor = currentRange.getText() + .createTextCursorByRange(currentRange.getStart()); } // include currentRange in currentGroupCursor @@ -298,8 +298,8 @@ private static List scan(XTextDocument doc, OOFrontend fronte ScanState state = new ScanState(); for (CitationGroup group : groups) { - XTextRange currentRange = (frontend.getMarkRange(doc, group) - .orElseThrow(IllegalStateException::new)); + XTextRange currentRange = frontend.getMarkRange(doc, group) + .orElseThrow(IllegalStateException::new); /* * Decide if we add group to the group. False when the group is empty. @@ -311,7 +311,7 @@ private static List scan(XTextDocument doc, OOFrontend fronte * * Can it start a new group? */ - boolean canStartGroup = (group.citationType == CitationType.AUTHORYEAR_PAR); + boolean canStartGroup = group.citationType == CitationType.AUTHORYEAR_PAR; if (!addToGroup) { // close currentGroup diff --git a/src/main/java/org/jabref/logic/openoffice/action/EditSeparate.java b/src/main/java/org/jabref/logic/openoffice/action/EditSeparate.java index ffe6c59dc0c..5f087001d02 100644 --- a/src/main/java/org/jabref/logic/openoffice/action/EditSeparate.java +++ b/src/main/java/org/jabref/logic/openoffice/action/EditSeparate.java @@ -55,9 +55,9 @@ public static boolean separateCitations(XTextDocument doc, UnoScreenRefresh.lockControllers(doc); for (CitationGroup group : groups) { - XTextRange range1 = (frontend + XTextRange range1 = frontend .getMarkRange(doc, group) - .orElseThrow(IllegalStateException::new)); + .orElseThrow(IllegalStateException::new); XTextCursor textCursor = range1.getText().createTextCursorByRange(range1); List citations = group.citationsInStorageOrder; @@ -71,7 +71,7 @@ public static boolean separateCitations(XTextDocument doc, // Create a citation group for each citation. final int last = citations.size() - 1; for (int i = 0; i < citations.size(); i++) { - boolean insertSpaceAfter = (i != last); + boolean insertSpaceAfter = i != last; Citation citation = citations.get(i); UpdateCitationMarkers.createAndFillCitationGroup(frontend, diff --git a/src/main/java/org/jabref/logic/openoffice/backend/Backend52.java b/src/main/java/org/jabref/logic/openoffice/backend/Backend52.java index e433d18e72f..0769a7f9b5b 100644 --- a/src/main/java/org/jabref/logic/openoffice/backend/Backend52.java +++ b/src/main/java/org/jabref/logic/openoffice/backend/Backend52.java @@ -131,18 +131,18 @@ public CitationGroup readCitationGroupFromDocumentOrThrow(XTextDocument doc, Str Codec52.ParsedMarkName parsed = Codec52.parseMarkName(markName).orElseThrow(IllegalArgumentException::new); - List citations = (parsed.citationKeys.stream() + List citations = parsed.citationKeys.stream() .map(Citation::new) - .collect(Collectors.toList())); + .collect(Collectors.toList()); - Optional pageInfo = (UnoUserDefinedProperty.getStringValue(doc, markName) - .map(OOText::fromString)); + Optional pageInfo = UnoUserDefinedProperty.getStringValue(doc, markName) + .map(OOText::fromString); pageInfo = PageInfo.normalizePageInfo(pageInfo); setPageInfoInDataInitial(citations, pageInfo); - NamedRange namedRange = (citationStorageManager.getNamedRangeFromDocument(doc, markName) - .orElseThrow(IllegalArgumentException::new)); + NamedRange namedRange = citationStorageManager.getNamedRangeFromDocument(doc, markName) + .orElseThrow(IllegalArgumentException::new); CitationGroupId groupId = new CitationGroupId(markName); CitationGroup group = new CitationGroup(OODataModel.JabRef52, @@ -226,7 +226,7 @@ public CitationGroup createCitationGroup(XTextDocument doc, /* * Apply to document */ - boolean withoutBrackets = (citationType == CitationType.INVISIBLE_CIT); + boolean withoutBrackets = citationType == CitationType.INVISIBLE_CIT; NamedRange namedRange = this.citationStorageManager.createNamedRange(doc, markName, position, @@ -271,25 +271,25 @@ public CitationGroup createCitationGroup(XTextDocument doc, Backend52::getPageInfoFromData); // Try to do something of the pageInfos. - String singlePageInfo = (pageInfos.stream() + String singlePageInfo = pageInfos.stream() .filter(Optional::isPresent) .map(pi -> OOText.toString(pi.get())) .distinct() - .collect(Collectors.joining("; "))); + .collect(Collectors.joining("; ")); - int totalCitations = (joinableGroup.stream() + int totalCitations = joinableGroup.stream() .map(CitationGroup::numberOfCitations) - .mapToInt(Integer::intValue).sum()); + .mapToInt(Integer::intValue).sum(); if ("".equals(singlePageInfo)) { singlePageInfo = null; } return OODataModel.fakePageInfos(singlePageInfo, totalCitations); case JabRef60: - return (joinableGroup.stream() + return joinableGroup.stream() .flatMap(group -> (group.citationsInStorageOrder.stream() .map(Citation::getPageInfo))) - .collect(Collectors.toList())); + .collect(Collectors.toList()); default: throw new IllegalArgumentException("unhandled dataModel here"); } @@ -378,14 +378,14 @@ public List getCitationEntries(XTextDocument doc, CitationGroups List citations = new ArrayList<>(citationGroups.numberOfCitationGroups()); for (CitationGroup group : citationGroups.getCitationGroupsUnordered()) { String name = group.groupId.citationGroupIdAsString(); - XTextCursor cursor = (this + XTextCursor cursor = this .getRawCursorForCitationGroup(group, doc) - .orElseThrow(IllegalStateException::new)); + .orElseThrow(IllegalStateException::new); String context = GetContext.getCursorStringWithContext(cursor, 30, 30, true); - Optional pageInfo = (group.numberOfCitations() > 0 + Optional pageInfo = group.numberOfCitations() > 0 ? (getPageInfoFromData(group) .map(e -> OOText.toString(e))) - : Optional.empty()); + : Optional.empty(); CitationEntry entry = new CitationEntry(name, context, pageInfo); citations.add(entry); } diff --git a/src/main/java/org/jabref/logic/openoffice/backend/Codec52.java b/src/main/java/org/jabref/logic/openoffice/backend/Codec52.java index af131fa5300..5d567539799 100644 --- a/src/main/java/org/jabref/logic/openoffice/backend/Codec52.java +++ b/src/main/java/org/jabref/logic/openoffice/backend/Codec52.java @@ -114,14 +114,14 @@ public static Optional parseMarkName(String refMarkName) { String index = citeMatcher.group(1); int citTypeCode = Integer.parseInt(citeMatcher.group(2)); CitationType citationType = citationTypeFromInt(citTypeCode); - return (Optional.of(new Codec52.ParsedMarkName(index, citationType, keys))); + return Optional.of(new Codec52.ParsedMarkName(index, citationType, keys)); } /** * @return true if name matches the pattern used for JabRef reference mark names. */ public static boolean isJabRefReferenceMarkName(String name) { - return (CITE_PATTERN.matcher(name).find()); + return CITE_PATTERN.matcher(name).find(); } /** @@ -130,8 +130,8 @@ public static boolean isJabRefReferenceMarkName(String name) { * @param names The list to be filtered. */ public static List filterIsJabRefReferenceMarkName(List names) { - return (names.stream() + return names.stream() .filter(Codec52::isJabRefReferenceMarkName) - .collect(Collectors.toList())); + .collect(Collectors.toList()); } } diff --git a/src/main/java/org/jabref/logic/openoffice/backend/GetContext.java b/src/main/java/org/jabref/logic/openoffice/backend/GetContext.java index 548548294b0..cad4ca6a640 100644 --- a/src/main/java/org/jabref/logic/openoffice/backend/GetContext.java +++ b/src/main/java/org/jabref/logic/openoffice/backend/GetContext.java @@ -66,9 +66,9 @@ public static String getCursorStringWithContext(XTextCursor cursor, String result = cursor.getString(); if (htmlMarkup) { - result = (result.substring(0, addedBefore) + result = result.substring(0, addedBefore) + "" + citPart + "" - + result.substring(lengthWithBefore)); + + result.substring(lengthWithBefore); } return result.trim(); } diff --git a/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeManagerReferenceMark.java b/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeManagerReferenceMark.java index fead1169b8e..37ad5499da5 100644 --- a/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeManagerReferenceMark.java +++ b/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeManagerReferenceMark.java @@ -38,9 +38,9 @@ public Optional getNamedRangeFromDocument(XTextDocument doc, String throws NoDocumentException, WrappedTargetException { - return (NamedRangeReferenceMark + return NamedRangeReferenceMark .getFromDocument(doc, refMarkName) - .map(x -> x)); + .map(x -> x); } } diff --git a/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeReferenceMark.java b/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeReferenceMark.java index e816b3bfa97..377dd060805 100644 --- a/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeReferenceMark.java +++ b/src/main/java/org/jabref/logic/openoffice/backend/NamedRangeReferenceMark.java @@ -96,9 +96,9 @@ private static void createReprInDocument(XTextDocument doc, final String left = NamedRangeReferenceMark.REFERENCE_MARK_LEFT_BRACKET; final String right = NamedRangeReferenceMark.REFERENCE_MARK_RIGHT_BRACKET; - String bracketedContent = (withoutBrackets + String bracketedContent = withoutBrackets ? "" - : left + right); + : left + right; cursor.getText().insertString(cursor, bracketedContent, true); @@ -133,8 +133,8 @@ static Optional getFromDocument(XTextDocument doc, Stri throws NoDocumentException, WrappedTargetException { - return (UnoReferenceMark.getAnchor(doc, refMarkName) - .map(e -> new NamedRangeReferenceMark(refMarkName))); + return UnoReferenceMark.getAnchor(doc, refMarkName) + .map(e -> new NamedRangeReferenceMark(refMarkName)); } /** @@ -403,19 +403,19 @@ public void cleanFillCursor(XTextDocument doc) final int fullTextLength = fullText.length(); final short leftLength = (short) left.length(); final short rightLength = (short) right.length(); - final int contentLength = (fullTextLength - (leftLength + rightLength)); + final int contentLength = fullTextLength - (leftLength + rightLength); if (contentLength < 0) { String msg = String.format("cleanFillCursor: length(%s) < 0", name); throw new IllegalStateException(msg); } - boolean removeRight = ((contentLength >= 1) + boolean removeRight = (contentLength >= 1) || ((contentLength == 0) && removeBracketsFromEmpty) - || alwaysRemoveBrackets); + || alwaysRemoveBrackets; - boolean removeLeft = ((contentLength >= 2) + boolean removeLeft = (contentLength >= 2) || ((contentLength == 0) && removeBracketsFromEmpty) - || alwaysRemoveBrackets); + || alwaysRemoveBrackets; if (removeRight) { XTextCursor omega = full.getText().createTextCursorByRange(full); diff --git a/src/main/java/org/jabref/logic/openoffice/frontend/OOFrontend.java b/src/main/java/org/jabref/logic/openoffice/frontend/OOFrontend.java index e156b2816f0..7858e9230ad 100644 --- a/src/main/java/org/jabref/logic/openoffice/frontend/OOFrontend.java +++ b/src/main/java/org/jabref/logic/openoffice/frontend/OOFrontend.java @@ -107,9 +107,9 @@ private List> createVisualSortInput(XTextDocument d List> sortables = new ArrayList<>(); for (CitationGroup group : citationGroups.getCitationGroupsUnordered()) { - XTextRange range = (this + XTextRange range = this .getMarkRange(doc, group) - .orElseThrow(IllegalStateException::new)); + .orElseThrow(IllegalStateException::new); sortables.add(new RangeSortEntry<>(range, 0, group)); } @@ -167,9 +167,9 @@ private List getVisuallySortedCitationGroups(XTextDocument doc, List> sorted = RangeSortVisual.visualSort(sortables, doc, fcursor); - return (sorted.stream() + return sorted.stream() .map(RangeSortable::getContent) - .collect(Collectors.toList())); + .collect(Collectors.toList()); } /** @@ -187,7 +187,7 @@ private List getVisuallySortedCitationGroups(XTextDocument doc, List> sortables = createVisualSortInput(doc, mapFootnotesToFootnoteMarks); - return (sortables.stream().map(RangeSortable::getContent).collect(Collectors.toList())); + return sortables.stream().map(RangeSortable::getContent).collect(Collectors.toList()); } /** @@ -383,9 +383,9 @@ static String rangeOverlapsToMessage(List> overlap : overlaps) { - String listOfRanges = (overlap.valuesForOverlappingRanges.stream() + String listOfRanges = overlap.valuesForOverlappingRanges.stream() .map(v -> String.format("'%s'", v.format())) - .collect(Collectors.joining(", "))); + .collect(Collectors.joining(", ")); msg.append( switch (overlap.kind) { case EQUAL_RANGE -> Localization.lang("Found identical ranges"); diff --git a/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java b/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java index adee06dd75e..3993afdf9a0 100644 --- a/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java +++ b/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java @@ -45,7 +45,7 @@ public static void applyNewCitationMarkers(XTextDocument doc, OOFrontend fronten CitationGroups citationGroups = frontend.citationGroups; for (CitationGroup group : citationGroups.getCitationGroupsUnordered()) { - boolean withText = (group.citationType != CitationType.INVISIBLE_CIT); + boolean withText = group.citationType != CitationType.INVISIBLE_CIT; Optional marker = group.getCitationMarker(); if (marker.isEmpty()) { diff --git a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java index 1d14af0f6ea..6989f101113 100644 --- a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java @@ -918,8 +918,8 @@ public OOText getFormattedBibliographyTitle() { OOBibStyle style = this; OOText title = style.getReferenceHeaderText(); String parStyle = style.getReferenceHeaderParagraphFormat(); - return (parStyle == null + return parStyle == null ? OOFormat.paragraph(title) - : OOFormat.paragraph(title, parStyle)); + : OOFormat.paragraph(title, parStyle); } } diff --git a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetCitationMarker.java b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetCitationMarker.java index fdac81414dc..b3680b57b9b 100644 --- a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetCitationMarker.java +++ b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetCitationMarker.java @@ -55,9 +55,9 @@ private static String getAuthorLastName(AuthorList authorList, int number) { } private static String markupAuthorName(OOBibStyle style, String name) { - return (style.getAuthorNameMarkupBefore() + return style.getAuthorNameMarkupBefore() + name - + style.getAuthorNameMarkupAfter()); + + style.getAuthorNameMarkupAfter(); } /** @@ -139,13 +139,13 @@ private static String formatAuthorList(OOBibStyle style, } // emitAllAuthors == false means use "et al." - boolean emitAllAuthors = ((nAuthors <= maxAuthors) || (maxAuthors == -1)); + boolean emitAllAuthors = (nAuthors <= maxAuthors) || (maxAuthors == -1); - int nAuthorsToEmit = (emitAllAuthors + int nAuthorsToEmit = emitAllAuthors ? nAuthors // If we use "et al." maxAuthorsBeforeEtAl also limits the // number of authors emitted. - : Math.min(maxAuthorsBeforeEtAl, nAuthors)); + : Math.min(maxAuthorsBeforeEtAl, nAuthors); if (nAuthorsToEmit >= 1) { stringBuilder.append(style.getAuthorsPartMarkupBefore()); @@ -232,8 +232,8 @@ private static Optional getRawCitationMarkerField(BibEntry entr for (Field field : fields /* FieldFactory.parseOrFields(fields)*/) { Optional optionalContent = entry.getResolvedFieldOrAlias(field, database); - final boolean foundSomething = (optionalContent.isPresent() - && !optionalContent.get().trim().isEmpty()); + final boolean foundSomething = optionalContent.isPresent() + && !optionalContent.get().trim().isEmpty(); if (foundSomething) { return Optional.of(new FieldAndContent(field, optionalContent.get())); } @@ -317,9 +317,9 @@ private static int calculateNAuthorsToEmit(OOBibStyle style, CitationMarkerEntry return 0; } - int maxAuthors = (entry.getIsFirstAppearanceOfSource() + int maxAuthors = entry.getIsFirstAppearanceOfSource() ? style.getMaxAuthorsFirst() - : style.getMaxAuthors()); + : style.getMaxAuthors(); AuthorList authorList = getAuthorList(style, entry.getLookupResult().get()); int nAuthors = authorList.getNumberOfAuthors(); @@ -373,13 +373,13 @@ private static OOText getAuthorYearParenthesisMarker2(OOBibStyle style, boolean[] startsNewGroup, Optional maxAuthorsOverride) { - boolean inParenthesis = (purpose == AuthorYearMarkerPurpose.IN_PARENTHESIS - || purpose == AuthorYearMarkerPurpose.NORMALIZED); + boolean inParenthesis = purpose == AuthorYearMarkerPurpose.IN_PARENTHESIS + || purpose == AuthorYearMarkerPurpose.NORMALIZED; // The String to separate authors from year, e.g. "; ". - String yearSep = (inParenthesis + String yearSep = inParenthesis ? style.getYearSeparator() - : style.getYearSeparatorInText()); + : style.getYearSeparatorInText(); // The opening parenthesis. String startBrace = style.getBracketBefore(); @@ -394,9 +394,9 @@ private static OOText getAuthorYearParenthesisMarker2(OOBibStyle style, OrFields yearFieldNames = style.getYearFieldNames(); // The String to add between the two last author names, e.g. " & ". - String andString = (inParenthesis + String andString = inParenthesis ? style.getAuthorLastSeparator() - : style.getAuthorLastSeparatorInTextWithFallBack()); + : style.getAuthorLastSeparatorInTextWithFallBack(); String pageInfoSeparator = style.getPageInfoSeparator(); String uniquefierSeparator = style.getUniquefierSeparator(); @@ -451,9 +451,9 @@ private static OOText getAuthorYearParenthesisMarker2(OOBibStyle style, } else { CitationLookupResult db = entry.getLookupResult().get(); - int maxAuthors = (purpose == AuthorYearMarkerPurpose.NORMALIZED + int maxAuthors = purpose == AuthorYearMarkerPurpose.NORMALIZED ? style.getMaxAuthors() - : calculateNAuthorsToEmit(style, entry)); + : calculateNAuthorsToEmit(style, entry); if (maxAuthorsOverride.isPresent()) { maxAuthors = maxAuthorsOverride.get(); @@ -716,12 +716,12 @@ static OOText getNormalizedCitationMarker(OOBibStyle style, Optional ul2 = ce2.getUniqueLetter(); Optional ul1 = ce1.getUniqueLetter(); - final boolean uniqueLetterPresenceChanged = (ul2.isPresent() != ul1.isPresent()); + final boolean uniqueLetterPresenceChanged = ul2.isPresent() != ul1.isPresent(); final boolean uniqueLettersDiffer = !ul2.equals(ul1); - final boolean uniqueLetterDoesNotMakeUnique = (citationKeysDiffer + final boolean uniqueLetterDoesNotMakeUnique = citationKeysDiffer && !normalizedMarkersDiffer - && !uniqueLettersDiffer); + && !uniqueLettersDiffer; if (uniqueLetterDoesNotMakeUnique && nonUniqueCitationMarkerHandling == NonUniqueCitationMarker.THROWS) { @@ -729,25 +729,25 @@ static OOText getNormalizedCitationMarker(OOBibStyle style, + " but same normalizedMarker and uniqueLetter"); } - final boolean pageInfoInhibitsJoin = (bothPageInfosAreEmpty + final boolean pageInfoInhibitsJoin = bothPageInfosAreEmpty ? false - : (citationKeysDiffer || pageInfosDiffer)); + : (citationKeysDiffer || pageInfosDiffer); - startingNewGroup = (normalizedMarkersDiffer + startingNewGroup = normalizedMarkersDiffer || nAuthorsShownInhibitsJoin || pageInfoInhibitsJoin || uniqueLetterPresenceChanged - || uniqueLetterDoesNotMakeUnique); + || uniqueLetterDoesNotMakeUnique; if (!startingNewGroup) { // inherit from first of group. Used at next i. nAuthorsToEmitRevised[i] = nAuthorsToEmitRevised[i - 1]; } - sameAsPrev = (!startingNewGroup + sameAsPrev = !startingNewGroup && !uniqueLettersDiffer && !citationKeysDiffer - && !pageInfosDiffer); + && !pageInfosDiffer; } if (!sameAsPrev) { diff --git a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetNumCitationMarker.java b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetNumCitationMarker.java index 5f7ac121750..2d5aa14272b 100644 --- a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetNumCitationMarker.java +++ b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyleGetNumCitationMarker.java @@ -185,7 +185,7 @@ public static OOText getNumCitationMarker2(OOBibStyle style, List entries, int minGroupingCount) { - final boolean joinIsDisabled = (minGroupingCount <= 0); + final boolean joinIsDisabled = minGroupingCount <= 0; final int nCitations = entries.size(); final String bracketBefore = style.getBracketBefore(); diff --git a/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java b/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java index 5ae0f4be7be..d45eab65b7e 100644 --- a/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java +++ b/src/main/java/org/jabref/logic/openoffice/style/OOFormatBibliography.java @@ -179,7 +179,7 @@ private static OOText formatCitedOnPages(CitationGroups citationGroups, CitedKey filteredList.sort((a, b) -> { Integer aa = a.getIndexInGlobalOrder().orElseThrow(IllegalStateException::new); Integer bb = b.getIndexInGlobalOrder().orElseThrow(IllegalStateException::new); - return (aa.compareTo(bb)); + return aa.compareTo(bb); }); int index = 0; diff --git a/src/main/java/org/jabref/logic/openoffice/style/OOProcessAuthorYearMarkers.java b/src/main/java/org/jabref/logic/openoffice/style/OOProcessAuthorYearMarkers.java index fc27fa8865a..3e960e7e165 100644 --- a/src/main/java/org/jabref/logic/openoffice/style/OOProcessAuthorYearMarkers.java +++ b/src/main/java/org/jabref/logic/openoffice/style/OOProcessAuthorYearMarkers.java @@ -141,7 +141,7 @@ static void produceCitationMarkers(CitationGroups citationGroups, OOBibStyle sty setIsFirstAppearanceOfSourceInCitations(citationGroups); for (CitationGroup group : citationGroups.getCitationGroupsInGlobalOrder()) { - final boolean inParenthesis = (group.citationType == CitationType.AUTHORYEAR_PAR); + final boolean inParenthesis = group.citationType == CitationType.AUTHORYEAR_PAR; final NonUniqueCitationMarker strictlyUnique = NonUniqueCitationMarker.THROWS; List cits = group.getCitationsInLocalOrder(); diff --git a/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java b/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java index 831ca747cb1..f5dfac6c94f 100644 --- a/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java +++ b/src/main/java/org/jabref/logic/pdf/search/indexing/DocumentReader.java @@ -83,7 +83,7 @@ public Optional> readLinkedPdf(BibDatabaseContext databaseContext */ public List readLinkedPdfs(BibDatabaseContext databaseContext) { return entry.getFiles().stream() - .map((pdf) -> readLinkedPdf(databaseContext, pdf)) + .map(pdf -> readLinkedPdf(databaseContext, pdf)) .filter(Optional::isPresent) .map(Optional::get) .flatMap(List::stream) @@ -153,7 +153,7 @@ private void addContentIfNotEmpty(PDDocument pdfDocument, Document newDocument, newDocument.add(new TextField(CONTENT, mergeLines(pdfContent), Field.Store.YES)); } PDPage page = pdfDocument.getPage(pageNumber); - List annotations = page.getAnnotations().stream().filter((annotation) -> annotation.getContents() != null).map(PDAnnotation::getContents).collect(Collectors.toList()); + List annotations = page.getAnnotations().stream().filter(annotation -> annotation.getContents() != null).map(PDAnnotation::getContents).collect(Collectors.toList()); if (annotations.size() > 0) { newDocument.add(new TextField(ANNOTATIONS, annotations.stream().collect(Collectors.joining("\n")), Field.Store.YES)); } diff --git a/src/main/java/org/jabref/logic/shared/DBMSProcessor.java b/src/main/java/org/jabref/logic/shared/DBMSProcessor.java index 1946db7029a..83aa188d027 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSProcessor.java +++ b/src/main/java/org/jabref/logic/shared/DBMSProcessor.java @@ -224,7 +224,7 @@ private List getNotYetExistingEntries(List bibEntries) { List localIds = bibEntries.stream() .map(BibEntry::getSharedBibEntryData) .map(SharedBibEntryData::getSharedID) - .filter((id) -> id != -1) + .filter(id -> id != -1) .collect(Collectors.toList()); if (localIds.isEmpty()) { return bibEntries; @@ -243,7 +243,7 @@ private List getNotYetExistingEntries(List bibEntries) { } catch (SQLException e) { LOGGER.error("SQL Error: ", e); } - return bibEntries.stream().filter((entry) -> + return bibEntries.stream().filter(entry -> !remoteIds.contains(entry.getSharedBibEntryData().getSharedID())) .collect(Collectors.toList()); } diff --git a/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java b/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java index ac11b7b334d..3a3d6658877 100644 --- a/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java +++ b/src/main/java/org/jabref/logic/shared/DBMSSynchronizer.java @@ -373,7 +373,7 @@ public boolean checkCurrentConnection() { */ public boolean isEventSourceAccepted(EntriesEvent event) { EntriesEventSource eventSource = event.getEntriesEventSource(); - return ((eventSource == EntriesEventSource.LOCAL) || (eventSource == EntriesEventSource.UNDO)); + return (eventSource == EntriesEventSource.LOCAL) || (eventSource == EntriesEventSource.UNDO); } @Override diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index 8901d0369db..7746f0a3397 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -274,7 +274,7 @@ static void upgradeImportFileAndDirePatterns(JabRefPreferences prefs, Preference } private static void upgradeKeyBindingsToJavaFX(JabRefPreferences prefs) { - UnaryOperator replaceKeys = (str) -> { + UnaryOperator replaceKeys = str -> { String result = str.replace("ctrl ", "ctrl+"); result = result.replace("shift ", "shift+"); result = result.replace("alt ", "alt+"); diff --git a/src/main/java/org/jabref/model/TreeNode.java b/src/main/java/org/jabref/model/TreeNode.java index 634882d0f73..fcf0b8ab26e 100644 --- a/src/main/java/org/jabref/model/TreeNode.java +++ b/src/main/java/org/jabref/model/TreeNode.java @@ -342,7 +342,7 @@ public T getRoot() { * @return true if this node has no children */ public boolean isLeaf() { - return (getNumberOfChildren() == 0); + return getNumberOfChildren() == 0; } /** diff --git a/src/main/java/org/jabref/model/entry/AuthorList.java b/src/main/java/org/jabref/model/entry/AuthorList.java index e717fb09edb..bd56f560bf5 100644 --- a/src/main/java/org/jabref/model/entry/AuthorList.java +++ b/src/main/java/org/jabref/model/entry/AuthorList.java @@ -361,7 +361,7 @@ public String getAsLastNames(boolean oxfordComma) { * Oxford comma. */ public String getAsLastFirstNames(boolean abbreviate, boolean oxfordComma) { - return andCoordinatedConjunction(getAuthors(), (auth) -> auth.getLastFirst(abbreviate), oxfordComma); + return andCoordinatedConjunction(getAuthors(), auth -> auth.getLastFirst(abbreviate), oxfordComma); } @Override diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index 757af48d4f0..9fb07029cf1 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -260,7 +260,7 @@ private Optional getSourceField(Field targetField, EntryType targetEntry, } // for these fields, inheritance is not allowed for the specified entry types - if ((targetField == StandardField.SHORTTITLE)) { + if (targetField == StandardField.SHORTTITLE) { return Optional.empty(); } } @@ -281,7 +281,7 @@ private Optional getSourceField(Field targetField, EntryType targetEntry, } // for these fields, inheritance is not allowed for the specified entry types - if ((targetField == StandardField.SHORTTITLE)) { + if (targetField == StandardField.SHORTTITLE) { return Optional.empty(); } } diff --git a/src/main/java/org/jabref/model/entry/BibtexString.java b/src/main/java/org/jabref/model/entry/BibtexString.java index 323521ca2d0..d8e83fb6477 100644 --- a/src/main/java/org/jabref/model/entry/BibtexString.java +++ b/src/main/java/org/jabref/model/entry/BibtexString.java @@ -176,12 +176,11 @@ public boolean equals(Object o) { return false; } BibtexString that = (BibtexString) o; - return ( - Objects.equals(hasChanged, that.hasChanged) && + return Objects.equals(hasChanged, that.hasChanged) && Objects.equals(name, that.name) && Objects.equals(content, that.content) && Objects.equals(type, that.type) && - Objects.equals(parsedSerialization, that.parsedSerialization)); + Objects.equals(parsedSerialization, that.parsedSerialization); } @Override diff --git a/src/main/java/org/jabref/model/entry/identifier/ISBN.java b/src/main/java/org/jabref/model/entry/identifier/ISBN.java index 80d00470587..962f3459de7 100644 --- a/src/main/java/org/jabref/model/entry/identifier/ISBN.java +++ b/src/main/java/org/jabref/model/entry/identifier/ISBN.java @@ -62,13 +62,13 @@ private boolean isbn10check() { int sum = 0; for (int pos = 0; pos <= 8; pos++) { - sum += (isbnString.charAt(pos) - '0') * ((10 - pos)); + sum += (isbnString.charAt(pos) - '0') * (10 - pos); } char control = isbnString.charAt(9); if ((control == 'x') || (control == 'X')) { control = '9' + 1; } - sum += (control - '0'); + sum += control - '0'; return (sum % 11) == 0; } diff --git a/src/main/java/org/jabref/model/entry/identifier/ISSN.java b/src/main/java/org/jabref/model/entry/identifier/ISSN.java index e60e582cde5..5063536eda9 100644 --- a/src/main/java/org/jabref/model/entry/identifier/ISSN.java +++ b/src/main/java/org/jabref/model/entry/identifier/ISSN.java @@ -17,12 +17,12 @@ public ISSN(String issnString) { public boolean isValidFormat() { Matcher issnMatcher = ISSN_PATTERN.matcher(issnString); - return (issnMatcher.matches()); + return issnMatcher.matches(); } public boolean isCanBeCleaned() { Matcher issnNoDashMatcher = ISSN_PATTERN_NODASH.matcher(issnString); - return (issnNoDashMatcher.matches()); + return issnNoDashMatcher.matches(); } public String getCleanedISSN() { @@ -46,6 +46,6 @@ public boolean isValidChecksum() { if ((control == 'x') || (control == 'X')) { control = '9' + 1; } - return (((((sum % 11) + control) - '0') == 11) || ((sum % 11) == 0)); + return ((((sum % 11) + control) - '0') == 11) || ((sum % 11) == 0); } } diff --git a/src/main/java/org/jabref/model/openoffice/ootext/OOTextIntoOO.java b/src/main/java/org/jabref/model/openoffice/ootext/OOTextIntoOO.java index 9c6190553a5..eb34293fe60 100644 --- a/src/main/java/org/jabref/model/openoffice/ootext/OOTextIntoOO.java +++ b/src/main/java/org/jabref/model/openoffice/ootext/OOTextIntoOO.java @@ -688,13 +688,13 @@ private static List> setCharEscapement(Optional va boolean relative, MyPropertyStack formatStack) { List> settings = new ArrayList<>(); - Optional oldValue = (formatStack + Optional oldValue = formatStack .getPropertyValue(CHAR_ESCAPEMENT) - .map(e -> (short) e)); + .map(e -> (short) e); - Optional oldHeight = (formatStack + Optional oldHeight = formatStack .getPropertyValue(CHAR_ESCAPEMENT_HEIGHT) - .map(e -> (byte) e)); + .map(e -> (byte) e); if (relative && (value.isPresent() || height.isPresent())) { double oldHeightFloat = oldHeight.orElse(CHAR_ESCAPEMENT_HEIGHT_DEFAULT) * 0.01; diff --git a/src/main/java/org/jabref/model/openoffice/rangesort/FunctionalTextViewCursor.java b/src/main/java/org/jabref/model/openoffice/rangesort/FunctionalTextViewCursor.java index c3831d93f35..12c340376c3 100644 --- a/src/main/java/org/jabref/model/openoffice/rangesort/FunctionalTextViewCursor.java +++ b/src/main/java/org/jabref/model/openoffice/rangesort/FunctionalTextViewCursor.java @@ -87,7 +87,7 @@ public static OOResult get(XTextDocument doc) } if (initialSelection == null) { - String errorMessage = ("Selection is not available: cannot provide a functional view cursor"); + String errorMessage = "Selection is not available: cannot provide a functional view cursor"; return OOResult.error(errorMessage); } else if (Arrays.stream(initialSelection.getSupportedServiceNames()) .noneMatch("com.sun.star.text.TextRanges"::equals)) { diff --git a/src/main/java/org/jabref/model/openoffice/rangesort/RangeOverlapBetween.java b/src/main/java/org/jabref/model/openoffice/rangesort/RangeOverlapBetween.java index a5cb13fb4f0..8108befdbd3 100644 --- a/src/main/java/org/jabref/model/openoffice/rangesort/RangeOverlapBetween.java +++ b/src/main/java/org/jabref/model/openoffice/rangesort/RangeOverlapBetween.java @@ -76,14 +76,14 @@ List> findFirst(XTextDocument doc, } boolean equal = UnoTextRange.compareStartsThenEndsUnsafe(cmp, aRange, bRange) == 0; - boolean touching = (abEndToStart == 0 || baEndToStart == 0); + boolean touching = abEndToStart == 0 || baEndToStart == 0; // In case of two equal collapsed ranges there is an ambiguity : TOUCH or EQUAL_RANGE ? // // We return EQUAL_RANGE - RangeOverlapKind kind = (equal ? RangeOverlapKind.EQUAL_RANGE + RangeOverlapKind kind = equal ? RangeOverlapKind.EQUAL_RANGE : (touching ? RangeOverlapKind.TOUCH - : RangeOverlapKind.OVERLAP)); + : RangeOverlapKind.OVERLAP); List valuesForOverlappingRanges = new ArrayList<>(); valuesForOverlappingRanges.add(aHolder); diff --git a/src/main/java/org/jabref/model/openoffice/rangesort/RangeSort.java b/src/main/java/org/jabref/model/openoffice/rangesort/RangeSort.java index 77982a9a7db..9657f90a212 100644 --- a/src/main/java/org/jabref/model/openoffice/rangesort/RangeSort.java +++ b/src/main/java/org/jabref/model/openoffice/rangesort/RangeSort.java @@ -30,8 +30,8 @@ private static class HolderComparatorWithinPartition implements Comparator getBibEntry() { } public static Optional lookup(BibDatabase database, String key) { - return (database + return database .getEntryByCitationKey(key) - .map(bibEntry -> new CitationLookupResult(bibEntry, database))); + .map(bibEntry -> new CitationLookupResult(bibEntry, database)); } public static Optional lookup(List databases, String key) { - return (databases.stream() + return databases.stream() .map(database -> Citation.lookup(database, key)) .filter(Optional::isPresent) .map(Optional::get) - .findFirst()); + .findFirst(); } public void lookupInDatabases(List databases) { diff --git a/src/main/java/org/jabref/model/openoffice/style/CitationType.java b/src/main/java/org/jabref/model/openoffice/style/CitationType.java index 567996ec56e..55c1d7c50ed 100644 --- a/src/main/java/org/jabref/model/openoffice/style/CitationType.java +++ b/src/main/java/org/jabref/model/openoffice/style/CitationType.java @@ -17,7 +17,7 @@ public boolean inParenthesis() { } public boolean withText() { - return (this != INVISIBLE_CIT); + return this != INVISIBLE_CIT; } } diff --git a/src/main/java/org/jabref/model/openoffice/style/CompareCitedKey.java b/src/main/java/org/jabref/model/openoffice/style/CompareCitedKey.java index 7f6d3adfab0..e8a99e6980b 100644 --- a/src/main/java/org/jabref/model/openoffice/style/CompareCitedKey.java +++ b/src/main/java/org/jabref/model/openoffice/style/CompareCitedKey.java @@ -22,7 +22,7 @@ public class CompareCitedKey implements Comparator { public int compare(ComparableCitedKey a, ComparableCitedKey b) { Optional aBibEntry = a.getBibEntry(); Optional bBibEntry = b.getBibEntry(); - final int mul = unresolvedComesFirst ? (+1) : (-1); + final int mul = unresolvedComesFirst ? (+1) : -1; if (aBibEntry.isEmpty() && bBibEntry.isEmpty()) { // Both are unresolved: compare them by citation key. diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoBookmark.java b/src/main/java/org/jabref/model/openoffice/uno/UnoBookmark.java index f187527aeab..5f4f5ea40d7 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoBookmark.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoBookmark.java @@ -44,7 +44,7 @@ public static Optional getAnchor(XTextDocument doc, String name) NoDocumentException { XNameAccess nameAccess = getNameAccess(doc); - return (UnoNameAccess.getTextContentByName(nameAccess, name).map(XTextContent::getAnchor)); + return UnoNameAccess.getTextContentByName(nameAccess, name).map(XTextContent::getAnchor); } /** diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoCursor.java b/src/main/java/org/jabref/model/openoffice/uno/UnoCursor.java index da29ee84d92..2bca7a1ff19 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoCursor.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoCursor.java @@ -18,9 +18,9 @@ private UnoCursor() { * Get the cursor positioned by the user. */ public static Optional getViewCursor(XTextDocument doc) { - return (UnoTextDocument.getCurrentController(doc) + return UnoTextDocument.getCurrentController(doc) .flatMap(e -> UnoCast.cast(XTextViewCursorSupplier.class, e)) - .map(XTextViewCursorSupplier::getViewCursor)); + .map(XTextViewCursorSupplier::getViewCursor); } /** diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoNamed.java b/src/main/java/org/jabref/model/openoffice/uno/UnoNamed.java index b9f43e56f80..d3bf46668d1 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoNamed.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoNamed.java @@ -39,13 +39,13 @@ static XNamed insertNamedTextContent(XTextDocument doc, throw new CreationException(e.getMessage()); } - XNamed xNamed = (UnoCast.cast(XNamed.class, xObject) - .orElseThrow(() -> new IllegalArgumentException("Service is not an XNamed"))); + XNamed xNamed = UnoCast.cast(XNamed.class, xObject) + .orElseThrow(() -> new IllegalArgumentException("Service is not an XNamed")); xNamed.setName(name); // get XTextContent interface - XTextContent xTextContent = (UnoCast.cast(XTextContent.class, xObject) - .orElseThrow(() -> new IllegalArgumentException("Service is not an XTextContent"))); + XTextContent xTextContent = UnoCast.cast(XTextContent.class, xObject) + .orElseThrow(() -> new IllegalArgumentException("Service is not an XTextContent")); range.getText().insertTextContent(range, xTextContent, absorb); return xNamed; } diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoProperties.java b/src/main/java/org/jabref/model/openoffice/uno/UnoProperties.java index 80ea0c11c80..bca3d90ab6c 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoProperties.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoProperties.java @@ -27,8 +27,8 @@ public static Optional asPropertySet(XPropertyContainer propertyCo } public static Optional getPropertySetInfo(XPropertySet propertySet) { - return (Optional.ofNullable(propertySet) - .flatMap(e -> Optional.ofNullable(e.getPropertySetInfo()))); + return Optional.ofNullable(propertySet) + .flatMap(e -> Optional.ofNullable(e.getPropertySetInfo())); } public static Optional getPropertySetInfo(XPropertyContainer propertyContainer) { @@ -37,9 +37,9 @@ public static Optional getPropertySetInfo(XPropertyContainer p public static List getPropertyNames(Property[] properties) { Objects.requireNonNull(properties); - return (Arrays.stream(properties) + return Arrays.stream(properties) .map(p -> p.Name) - .collect(Collectors.toList())); + .collect(Collectors.toList()); } public static List getPropertyNames(XPropertySetInfo propertySetInfo) { @@ -51,9 +51,9 @@ public static List getPropertyNames(XPropertySet propertySet) { } public static List getPropertyNames(XPropertyContainer propertyContainer) { - return (asPropertySet(propertyContainer) + return asPropertySet(propertyContainer) .map(UnoProperties::getPropertyNames) - .orElse(new ArrayList<>())); + .orElse(new ArrayList<>()); } public static Optional getValueAsObject(XPropertySet propertySet, String property) diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoReferenceMark.java b/src/main/java/org/jabref/model/openoffice/uno/UnoReferenceMark.java index 062564b8156..12e36fae46a 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoReferenceMark.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoReferenceMark.java @@ -98,8 +98,8 @@ public static Optional getAnchor(XTextDocument doc, String name) throws NoDocumentException, WrappedTargetException { - return (UnoReferenceMark.getAsTextContent(doc, name) - .map(XTextContent::getAnchor)); + return UnoReferenceMark.getAsTextContent(doc, name) + .map(XTextContent::getAnchor); } /** diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoStyle.java b/src/main/java/org/jabref/model/openoffice/uno/UnoStyle.java index aa659919fab..5aba2010aac 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoStyle.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoStyle.java @@ -59,8 +59,8 @@ public static Optional getInternalNameOfStyle(XTextDocument doc, String String name) throws WrappedTargetException { - return (getStyleFromFamily(doc, familyName, name) - .map(XStyle::getName)); + return getStyleFromFamily(doc, familyName, name) + .map(XStyle::getName); } public static Optional getInternalNameOfParagraphStyle(XTextDocument doc, String name) diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoTextDocument.java b/src/main/java/org/jabref/model/openoffice/uno/UnoTextDocument.java index 6abe3959f29..200f7be55df 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoTextDocument.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoTextDocument.java @@ -78,9 +78,9 @@ public static Optional getFrameTitle(XTextDocument doc) { } static Optional getDocumentProperties(XTextDocument doc) { - return (Optional.ofNullable(doc) + return Optional.ofNullable(doc) .flatMap(e -> UnoCast.cast(XDocumentPropertiesSupplier.class, e)) - .map(XDocumentPropertiesSupplier::getDocumentProperties)); + .map(XDocumentPropertiesSupplier::getDocumentProperties); } } diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoTextRange.java b/src/main/java/org/jabref/model/openoffice/uno/UnoTextRange.java index 520878833e5..883ab8de1fc 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoTextRange.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoTextRange.java @@ -37,7 +37,7 @@ public static boolean comparables(XTextRange a, XTextRange b) { * 1 if (a > b); (-1) if (a < b) */ public static int compareStartsUnsafe(XTextRangeCompare compare, XTextRange a, XTextRange b) { - return (-1) * compare.compareRegionStarts(a, b); + return -1 * compare.compareRegionStarts(a, b); } public static int compareStarts(XTextRange a, XTextRange b) { @@ -57,7 +57,7 @@ public static int compareEnds(XTextRange a, XTextRange b) { throw new java.lang.IllegalArgumentException("compareEnds: got incomparable regions"); } final XTextRangeCompare compare = UnoCast.cast(XTextRangeCompare.class, a.getText()).get(); - return (-1) * compare.compareRegionEnds(a, b); + return -1 * compare.compareRegionEnds(a, b); } /* @@ -66,9 +66,9 @@ public static int compareEnds(XTextRange a, XTextRange b) { public static int compareStartsThenEndsUnsafe(XTextRangeCompare compare, XTextRange a, XTextRange b) { int res = compare.compareRegionStarts(a, b); if (res != 0) { - return (-1) * res; + return -1 * res; } - return (-1) * compare.compareRegionEnds(a, b); + return -1 * compare.compareRegionEnds(a, b); } public static int compareStartsThenEnds(XTextRange a, XTextRange b) { diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoTextSection.java b/src/main/java/org/jabref/model/openoffice/uno/UnoTextSection.java index 56293eee947..1717795cfa7 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoTextSection.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoTextSection.java @@ -58,7 +58,7 @@ public static Optional getAnchor(XTextDocument doc, String name) NoDocumentException { XNameAccess nameAccess = getNameAccess(doc); - return (UnoNameAccess.getTextContentByName(nameAccess, name).map(XTextContent::getAnchor)); + return UnoNameAccess.getTextContentByName(nameAccess, name).map(XTextContent::getAnchor); } /** diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoUndo.java b/src/main/java/org/jabref/model/openoffice/uno/UnoUndo.java index bd1f85e1690..9de5e149130 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoUndo.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoUndo.java @@ -17,8 +17,8 @@ private UnoUndo() { public static Optional getXUndoManager(XTextDocument doc) { // https://www.openoffice.org/api/docs/common/ref/com/sun/star/document/XUndoManager.html - return (UnoCast.cast(XUndoManagerSupplier.class, doc) - .map(XUndoManagerSupplier::getUndoManager)); + return UnoCast.cast(XUndoManagerSupplier.class, doc) + .map(XUndoManagerSupplier::getUndoManager); } /** diff --git a/src/main/java/org/jabref/model/openoffice/uno/UnoUserDefinedProperty.java b/src/main/java/org/jabref/model/openoffice/uno/UnoUserDefinedProperty.java index 85158db2d1c..3b6abb75b8e 100644 --- a/src/main/java/org/jabref/model/openoffice/uno/UnoUserDefinedProperty.java +++ b/src/main/java/org/jabref/model/openoffice/uno/UnoUserDefinedProperty.java @@ -39,9 +39,9 @@ public static Optional getPropertyContainer(XTextDocument do } public static List getListOfNames(XTextDocument doc) { - return (UnoUserDefinedProperty.getPropertyContainer(doc) + return UnoUserDefinedProperty.getPropertyContainer(doc) .map(UnoProperties::getPropertyNames) - .orElse(new ArrayList<>())); + .orElse(new ArrayList<>()); } /** @@ -52,8 +52,8 @@ public static List getListOfNames(XTextDocument doc) { public static Optional getStringValue(XTextDocument doc, String property) throws WrappedTargetException { - Optional propertySet = (UnoUserDefinedProperty.getPropertyContainer(doc) - .flatMap(UnoProperties::asPropertySet)); + Optional propertySet = UnoUserDefinedProperty.getPropertyContainer(doc) + .flatMap(UnoProperties::asPropertySet); if (propertySet.isEmpty()) { throw new java.lang.IllegalArgumentException("getting UserDefinedProperties as XPropertySet failed"); } diff --git a/src/main/java/org/jabref/model/strings/StringUtil.java b/src/main/java/org/jabref/model/strings/StringUtil.java index f46edafba0a..c85521a5f71 100644 --- a/src/main/java/org/jabref/model/strings/StringUtil.java +++ b/src/main/java/org/jabref/model/strings/StringUtil.java @@ -50,9 +50,9 @@ public static String quote(String toQuote, String specials, char quoteChar) { for (int i = 0; i < toQuote.length(); ++i) { c = toQuote.charAt(i); - isSpecial = (c == quoteChar); + isSpecial = c == quoteChar; // If non-null specials performs logic-or with specials.indexOf(c) >= 0 - isSpecial |= ((specials != null) && (specials.indexOf(c) >= 0)); + isSpecial |= (specials != null) && (specials.indexOf(c) >= 0); if (isSpecial) { result.append(quoteChar); @@ -604,7 +604,7 @@ public static String repeat(int n, char c) { } public static boolean isNullOrEmpty(String toTest) { - return ((toTest == null) || toTest.isEmpty()); + return (toTest == null) || toTest.isEmpty(); } public static boolean isBlank(String string) { diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index fb9a98a535c..1cd33612545 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -2239,7 +2239,7 @@ private SaveOrder loadTableSaveOrder() { List criteria = new ArrayList<>(); for (var column : sortOrder) { - boolean descending = (column.getSortType() == SortType.DESCENDING); + boolean descending = column.getSortType() == SortType.DESCENDING; criteria.add(new SaveOrder.SortCriterion( FieldFactory.parseField(column.getQualifier()), descending)); diff --git a/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java b/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java index 3c6816d6464..7b641e987dd 100644 --- a/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java @@ -27,7 +27,7 @@ void setUp() throws Exception { @Test void completeWithoutAddingAnythingReturnsNothing() { - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -36,7 +36,7 @@ void completeAfterAddingEmptyEntryReturnsNothing() { BibEntry entry = new BibEntry(); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -46,7 +46,7 @@ void completeKeyReturnsKey() { entry.setCitationKey("testKey"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("testKey"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testKey")); assertEquals(Collections.singletonList(entry), result); } @@ -56,7 +56,7 @@ void completeBeginningOfKeyReturnsKey() { entry.setCitationKey("testKey"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.singletonList(entry), result); } @@ -66,7 +66,7 @@ void completeLowercaseKeyReturnsKey() { entry.setCitationKey("testKey"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("testkey"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testkey")); assertEquals(Collections.singletonList(entry), result); } @@ -76,7 +76,7 @@ void completeNullThrowsException() { entry.setCitationKey("testKey"); database.insertEntry(entry); - assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest((null)))); + assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest(null))); } @Test @@ -85,7 +85,7 @@ void completeEmptyStringReturnsNothing() { entry.setCitationKey("testKey"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest((""))); + Collection result = autoCompleter.provideSuggestions(getRequest("")); assertEquals(Collections.emptyList(), result); } @@ -98,7 +98,7 @@ void completeReturnsMultipleResults() { entryTwo.setCitationKey("testKeyTwo"); database.insertEntry(entryTwo); - Collection result = autoCompleter.provideSuggestions(getRequest(("testKey"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testKey")); assertEquals(Arrays.asList(entryTwo, entryOne), result); } @@ -108,7 +108,7 @@ void completeShortKeyReturnsKey() { entry.setCitationKey("key"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("k"))); + Collection result = autoCompleter.provideSuggestions(getRequest("k")); assertEquals(Collections.singletonList(entry), result); } } diff --git a/src/test/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProviderTest.java b/src/test/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProviderTest.java index e0ded4056e8..efa4139f4e3 100644 --- a/src/test/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProviderTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/ContentSelectorSuggestionProviderTest.java @@ -24,7 +24,7 @@ void completeWithoutAddingAnythingReturnsNothing() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Collections.emptyList()); Collection expected = Collections.emptyList(); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(expected, result); } @@ -35,7 +35,7 @@ void completeKeywordReturnsKeyword() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Collections.singletonList("test")); Collection expected = Collections.singletonList("test"); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(expected, result); } @@ -46,7 +46,7 @@ void completeBeginningOfKeywordReturnsKeyword() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Collections.singletonList("test")); Collection expected = Collections.singletonList("test"); - Collection result = autoCompleter.provideSuggestions(getRequest(("te"))); + Collection result = autoCompleter.provideSuggestions(getRequest("te")); assertEquals(expected, result); } @@ -62,7 +62,7 @@ void completeKeywordReturnsKeywordFromDatabase() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Collections.emptyList()); Collection expected = Collections.singletonList("test"); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(expected, result); } @@ -73,14 +73,14 @@ void completeUppercaseBeginningOfNameReturnsName() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Collections.singletonList("test")); Collection expected = Collections.singletonList("test"); - Collection result = autoCompleter.provideSuggestions(getRequest(("TE"))); + Collection result = autoCompleter.provideSuggestions(getRequest("TE")); assertEquals(expected, result); } @Test void completeNullThrowsException() { - assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest((null)))); + assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest(null))); } @Test @@ -89,7 +89,7 @@ void completeEmptyStringReturnsNothing() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Collections.singletonList("test")); Collection expected = Collections.emptyList(); - Collection result = autoCompleter.provideSuggestions(getRequest((""))); + Collection result = autoCompleter.provideSuggestions(getRequest("")); assertEquals(expected, result); } @@ -105,7 +105,7 @@ void completeReturnsMultipleResults() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Collections.singletonList("testb")); Collection expected = Arrays.asList("testa", "testb"); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(expected, result); } @@ -122,7 +122,7 @@ void completeReturnsKeywordsInAlphabeticalOrder() { autoCompleter = new ContentSelectorSuggestionProvider(suggestionProvider, Arrays.asList("testb", "testa")); Collection expected = Arrays.asList("testa", "testb", "testc", "testd"); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(expected, result); } diff --git a/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java b/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java index 8d833b199aa..767eff82374 100644 --- a/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java @@ -33,7 +33,7 @@ void initAutoCompleterWithNullFieldThrowsException() { @Test void completeWithoutAddingAnythingReturnsNothing() { - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -42,7 +42,7 @@ void completeAfterAddingEmptyEntryReturnsNothing() { BibEntry entry = new BibEntry(); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -52,7 +52,7 @@ void completeAfterAddingEntryWithoutFieldReturnsNothing() { entry.setField(StandardField.AUTHOR, "testAuthor"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -62,7 +62,7 @@ void completeValueReturnsValue() { entry.setField(StandardField.TITLE, "testValue"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("testValue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testValue")); assertEquals(Arrays.asList("testValue"), result); } @@ -72,7 +72,7 @@ void completeBeginningOfValueReturnsValue() { entry.setField(StandardField.TITLE, "testValue"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Arrays.asList("testValue"), result); } @@ -82,7 +82,7 @@ void completeLowercaseValueReturnsValue() { entry.setField(StandardField.TITLE, "testValue"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("testvalue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testvalue")); assertEquals(Arrays.asList("testValue"), result); } @@ -92,7 +92,7 @@ void completeNullThrowsException() { entry.setField(StandardField.TITLE, "testKey"); database.insertEntry(entry); - assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest((null)))); + assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest(null))); } @Test @@ -101,7 +101,7 @@ void completeEmptyStringReturnsNothing() { entry.setField(StandardField.TITLE, "testKey"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest((""))); + Collection result = autoCompleter.provideSuggestions(getRequest("")); assertEquals(Collections.emptyList(), result); } @@ -114,7 +114,7 @@ void completeReturnsMultipleResults() { entryTwo.setField(StandardField.TITLE, "testValueTwo"); database.insertEntry(entryTwo); - Collection result = autoCompleter.provideSuggestions(getRequest(("testValue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testValue")); assertEquals(Arrays.asList("testValueOne", "testValueTwo"), result); } @@ -124,7 +124,7 @@ void completeShortStringReturnsValue() { entry.setField(StandardField.TITLE, "val"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("va"))); + Collection result = autoCompleter.provideSuggestions(getRequest("va")); assertEquals(Collections.singletonList("val"), result); } @@ -134,7 +134,7 @@ void completeBeginnigOfSecondWordReturnsWord() { entry.setField(StandardField.TITLE, "test value"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("val"))); + Collection result = autoCompleter.provideSuggestions(getRequest("val")); assertEquals(Collections.singletonList("value"), result); } @@ -144,7 +144,7 @@ void completePartOfWordReturnsValue() { entry.setField(StandardField.TITLE, "test value"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("lue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("lue")); assertEquals(Collections.singletonList("value"), result); } } diff --git a/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java b/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java index 15c2bde30e4..e4baeeb3405 100644 --- a/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java @@ -40,7 +40,7 @@ void initAutoCompleterWithNullFieldThrowsException() { @Test void completeWithoutAddingAnythingReturnsNothing() { - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -49,7 +49,7 @@ void completeAfterAddingEmptyEntryReturnsNothing() { BibEntry entry = new BibEntry(); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -59,7 +59,7 @@ void completeAfterAddingEntryWithoutFieldReturnsNothing() { entry.setField(StandardField.AUTHOR, "testAuthor"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -76,7 +76,7 @@ void completeOnIgnoredFieldReturnsNothing() { entry.setField(StandardField.TITLE, "testValue"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("testValue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testValue")); assertEquals(Collections.emptyList(), result); } @@ -86,7 +86,7 @@ void completeValueReturnsValue() { entry.setField(StandardField.TITLE, "testValue"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("testValue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testValue")); assertEquals(List.of("testValue"), result); } @@ -96,7 +96,7 @@ void completeBeginnigOfValueReturnsValue() { entry.setField(StandardField.TITLE, "testValue"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(List.of("testValue"), result); } @@ -106,7 +106,7 @@ void completeLowercaseValueReturnsValue() { entry.setField(StandardField.TITLE, "testValue"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("testvalue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testvalue")); assertEquals(List.of("testValue"), result); } @@ -125,7 +125,7 @@ void completeEmptyStringReturnsNothing() { entry.setField(StandardField.TITLE, "testKey"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest((""))); + Collection result = autoCompleter.provideSuggestions(getRequest("")); assertEquals(Collections.emptyList(), result); } @@ -138,7 +138,7 @@ void completeReturnsMultipleResults() { entryTwo.setField(StandardField.TITLE, "testValueTwo"); database.insertEntry(entryTwo); - Collection result = autoCompleter.provideSuggestions(getRequest(("testValue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("testValue")); assertEquals(Arrays.asList("testValueOne", "testValueTwo"), result); } @@ -148,7 +148,7 @@ void completeShortStringReturnsFieldValue() { entry.setField(StandardField.TITLE, "val"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("va"))); + Collection result = autoCompleter.provideSuggestions(getRequest("va")); assertEquals(Collections.singletonList("val"), result); } @@ -158,7 +158,7 @@ void completeBeginnigOfSecondWordReturnsWholeFieldValue() { entry.setField(StandardField.TITLE, "test value"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("val"))); + Collection result = autoCompleter.provideSuggestions(getRequest("val")); assertEquals(Collections.singletonList("test value"), result); } @@ -168,7 +168,7 @@ void completePartOfWordReturnsWholeFieldValue() { entry.setField(StandardField.TITLE, "test value"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("lue"))); + Collection result = autoCompleter.provideSuggestions(getRequest("lue")); assertEquals(Collections.singletonList("test value"), result); } @@ -178,7 +178,7 @@ void completeReturnsWholeFieldValue() { entry.setField(StandardField.TITLE, "test value"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("te"))); + Collection result = autoCompleter.provideSuggestions(getRequest("te")); assertEquals(Collections.singletonList("test value"), result); } } diff --git a/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java b/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java index 1c3f344f5da..980868f7306 100644 --- a/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java @@ -40,7 +40,7 @@ void initAutoCompleterWithNullFieldThrowsException() { @Test void completeWithoutAddingAnythingReturnsNothing() { - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -49,7 +49,7 @@ void completeAfterAddingEmptyEntryReturnsNothing() { BibEntry entry = new BibEntry(); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -59,7 +59,7 @@ void completeAfterAddingEntryWithoutFieldReturnsNothing() { entry.setField(StandardField.TITLE, "testTitle"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("test"))); + Collection result = autoCompleter.provideSuggestions(getRequest("test")); assertEquals(Collections.emptyList(), result); } @@ -67,7 +67,7 @@ void completeAfterAddingEntryWithoutFieldReturnsNothing() { void completeNameReturnsName() { database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("Kostakos"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Kostakos")); assertEquals(Collections.singletonList(vassilisKostakos), result); } @@ -75,7 +75,7 @@ void completeNameReturnsName() { void completeBeginningOfNameReturnsName() { database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("Kosta"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Kosta")); assertEquals(Collections.singletonList(vassilisKostakos), result); } @@ -83,20 +83,20 @@ void completeBeginningOfNameReturnsName() { void completeLowercaseBeginningOfNameReturnsName() { database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("kosta"))); + Collection result = autoCompleter.provideSuggestions(getRequest("kosta")); assertEquals(Collections.singletonList(vassilisKostakos), result); } @Test void completeNullThrowsException() { - assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest((null)))); + assertThrows(NullPointerException.class, () -> autoCompleter.provideSuggestions(getRequest(null))); } @Test void completeEmptyStringReturnsNothing() { database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest((""))); + Collection result = autoCompleter.provideSuggestions(getRequest("")); assertEquals(Collections.emptyList(), result); } @@ -108,7 +108,7 @@ void completeReturnsMultipleResults() { database.insertEntry(entryTwo); Author authorTwo = new Author("", "", "", "Kosta", ""); - Collection result = autoCompleter.provideSuggestions(getRequest(("Ko"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Ko")); assertEquals(Arrays.asList(authorTwo, vassilisKostakos), result); } @@ -116,7 +116,7 @@ void completeReturnsMultipleResults() { void completePartOfNameReturnsName() { database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("osta"))); + Collection result = autoCompleter.provideSuggestions(getRequest("osta")); assertEquals(Collections.singletonList(vassilisKostakos), result); } @@ -124,7 +124,7 @@ void completePartOfNameReturnsName() { void completeBeginningOfFirstNameReturnsName() { database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("Vas"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Vas")); assertEquals(Collections.singletonList(vassilisKostakos), result); } @@ -135,7 +135,7 @@ void completeBeginningOfFirstNameReturnsNameWithJr() { database.insertEntry(entry); Author author = new Author("Joseph M.", "J. M.", "", "Reagle", "Jr."); - Collection result = autoCompleter.provideSuggestions(getRequest(("Jos"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Jos")); assertEquals(Collections.singletonList(author), result); } @@ -146,7 +146,7 @@ void completeBeginningOfFirstNameReturnsNameWithVon() { database.insertEntry(entry); Author author = new Author("Eric", "E.", "von", "Hippel", ""); - Collection result = autoCompleter.provideSuggestions(getRequest(("Eric"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Eric")); assertEquals(Collections.singletonList(author), result); } @@ -157,7 +157,7 @@ void completeBeginningOfLastNameReturnsNameWithUmlauts() { database.insertEntry(entry); Author author = new Author("Honig", "H.", "", "Bär", ""); - Collection result = autoCompleter.provideSuggestions(getRequest(("Bä"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Bä")); assertEquals(Collections.singletonList(author), result); } @@ -168,7 +168,7 @@ void completeVonReturnsName() { database.insertEntry(entry); Author author = new Author("Eric", "E.", "von", "Hippel", ""); - Collection result = autoCompleter.provideSuggestions(getRequest(("von"))); + Collection result = autoCompleter.provideSuggestions(getRequest("von")); assertEquals(Collections.singletonList(author), result); } @@ -178,7 +178,7 @@ void completeBeginningOfFullNameReturnsName() { entry.setField(StandardField.AUTHOR, "Vassilis Kostakos"); database.insertEntry(entry); - Collection result = autoCompleter.provideSuggestions(getRequest(("Kostakos, Va"))); + Collection result = autoCompleter.provideSuggestions(getRequest("Kostakos, Va")); assertEquals(Collections.singletonList(vassilisKostakos), result); } } diff --git a/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java b/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java index 47308002d0b..a8aa3b7628d 100644 --- a/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java +++ b/src/test/java/org/jabref/logic/importer/FulltextFetchersTest.java @@ -25,7 +25,7 @@ public class FulltextFetchersTest { @Test public void acceptPdfUrls() throws MalformedURLException { URL pdfUrl = new URL("http://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.pdf"); - FulltextFetcher finder = (e) -> Optional.of(pdfUrl); + FulltextFetcher finder = e -> Optional.of(pdfUrl); FulltextFetchers fetcher = new FulltextFetchers(Set.of(finder)); assertEquals(Optional.of(pdfUrl), fetcher.findFullTextPDF(entry)); } @@ -33,7 +33,7 @@ public void acceptPdfUrls() throws MalformedURLException { @Test public void rejectNonPdfUrls() throws MalformedURLException { URL pdfUrl = new URL("https://github.com/JabRef/jabref/blob/master/README.md"); - FulltextFetcher finder = (e) -> Optional.of(pdfUrl); + FulltextFetcher finder = e -> Optional.of(pdfUrl); FulltextFetchers fetcher = new FulltextFetchers(Set.of(finder)); assertEquals(Optional.empty(), fetcher.findFullTextPDF(entry)); @@ -42,7 +42,7 @@ public void rejectNonPdfUrls() throws MalformedURLException { @Test public void noTrustLevel() throws MalformedURLException { URL pdfUrl = new URL("http://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.pdf"); - FulltextFetcher finder = (e) -> Optional.of(pdfUrl); + FulltextFetcher finder = e -> Optional.of(pdfUrl); FulltextFetchers fetcher = new FulltextFetchers(Set.of(finder)); assertEquals(Optional.of(pdfUrl), fetcher.findFullTextPDF(entry)); diff --git a/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java b/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java index 4ab0c6ef5d3..e681b00753b 100644 --- a/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java +++ b/src/test/java/org/jabref/logic/openoffice/style/OOBibStyleTestHelper.java @@ -38,9 +38,9 @@ static class CitationMarkerNumericEntryImpl implements CitationMarkerNumericEntr public CitationMarkerNumericEntryImpl(String citationKey, int num, Optional pageInfo) { this.citationKey = citationKey; - this.num = (num == UNRESOLVED_ENTRY_NUMBER + this.num = num == UNRESOLVED_ENTRY_NUMBER ? Optional.empty() - : Optional.of(num)); + : Optional.of(num); this.pageInfo = PageInfo.normalizePageInfo(pageInfo); } diff --git a/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java b/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java index 9ae014f50e6..313b5f907dd 100644 --- a/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java +++ b/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java @@ -90,7 +90,7 @@ void testInsertEntry() throws SQLException { } } - Map expectedFieldMap = expectedEntry.getFieldMap().entrySet().stream().collect(Collectors.toMap((entry) -> entry.getKey().getName(), Map.Entry::getValue)); + Map expectedFieldMap = expectedEntry.getFieldMap().entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().getName(), Map.Entry::getValue)); assertEquals(expectedFieldMap, actualFieldMap); } @@ -417,8 +417,8 @@ void testInsertMultipleEntries() throws SQLException { } Map> expectedFieldMap = entries.stream() .collect(Collectors.toMap(bibEntry -> bibEntry.getSharedBibEntryData().getSharedID(), - (bibEntry) -> bibEntry.getFieldMap().entrySet().stream() - .collect(Collectors.toMap((entry) -> entry.getKey().getName(), Map.Entry::getValue)))); + bibEntry -> bibEntry.getFieldMap().entrySet().stream() + .collect(Collectors.toMap(entry -> entry.getKey().getName(), Map.Entry::getValue)))); assertEquals(expectedFieldMap, actualFieldMap); } diff --git a/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java b/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java index 20f3eb6906d..d13a76001dc 100644 --- a/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java +++ b/src/test/java/org/jabref/logic/xmp/XmpUtilWriterTest.java @@ -72,7 +72,7 @@ class XmpUtilWriterTest { .withField(StandardField.LANGUAGE, "English, Japanese") .withDate(new Date(2000, 5)) .withField(new UnknownField(DC_COVERAGE), "coverageField") - .withField(new UnknownField((DC_SOURCE)), "JabRef") + .withField(new UnknownField(DC_SOURCE), "JabRef") .withField(new UnknownField(DC_RIGHTS), "Right To X"); private XmpPreferences xmpPreferences;