Skip to content

Commit 8732e40

Browse files
kopporcalixtus
andauthored
minor-code-updates-2 (#13494)
* Refine JavaDoc comment * Use _ * Streamline ++ usage * Use _ * Update jablib/src/main/java/org/jabref/model/entry/BibEntry.java Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> * Refine loop --------- Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com>
1 parent 53dd75c commit 8732e40

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

jabgui/src/main/java/org/jabref/gui/util/UiTaskExecutor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public static <V> Task<V> getJavaFXTask(BackgroundTask<V> task) {
182182
cancel();
183183
}
184184
});
185-
setOnCancelled(event -> task.cancel());
185+
setOnCancelled(_ -> task.cancel());
186186
}
187187

188188
@Override
@@ -193,10 +193,10 @@ protected V call() throws Exception {
193193
};
194194
Runnable onRunning = task.getOnRunning();
195195
if (onRunning != null) {
196-
javaTask.setOnRunning(event -> onRunning.run());
196+
javaTask.setOnRunning(_ -> onRunning.run());
197197
}
198198
Consumer<V> onSuccess = task.getOnSuccess();
199-
javaTask.setOnSucceeded(event -> {
199+
javaTask.setOnSucceeded(_ -> {
200200
// Set to 100% completed on completion
201201
task.updateProgress(1, 1);
202202

@@ -206,7 +206,7 @@ protected V call() throws Exception {
206206
});
207207
Consumer<Exception> onException = task.getOnException();
208208
if (onException != null) {
209-
javaTask.setOnFailed(event -> onException.accept(convertToException(javaTask.getException())));
209+
javaTask.setOnFailed(_ -> onException.accept(convertToException(javaTask.getException())));
210210
}
211211
return javaTask;
212212
}

jablib/src/main/java/org/jabref/logic/search/IndexManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public IndexManager(BibDatabaseContext databaseContext,
5959
this.taskExecutor = executor;
6060
this.databaseContext = databaseContext;
6161
this.shouldIndexLinkedFiles = preferences.getFilePreferences().fulltextIndexLinkedFilesProperty();
62-
this.preferencesListener = (observable, oldValue, newValue) -> bindToPreferences(newValue);
62+
this.preferencesListener = (_, _, newValue) -> bindToPreferences(newValue);
6363
this.shouldIndexLinkedFiles.addListener(preferencesListener);
6464

6565
bibFieldsIndexer = new BibFieldsIndexer(preferences.getBibEntryPreferences(), databaseContext, postgreServer.getConnection());

jablib/src/main/java/org/jabref/logic/search/indexing/BibFieldsIndexer.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.sql.SQLException;
66
import java.util.Arrays;
77
import java.util.Collection;
8+
import java.util.List;
89
import java.util.Map;
910
import java.util.Optional;
1011
import java.util.Set;
@@ -164,25 +165,25 @@ public void updateOnStart(BackgroundTask<?> task) {
164165
addToIndex(databaseContext.getDatabase().getEntries(), task);
165166
}
166167

167-
public void addToIndex(Collection<BibEntry> entries, BackgroundTask<?> task) {
168-
if (entries.size() > 1) {
168+
public void addToIndex(List<BibEntry> entries, BackgroundTask<?> task) {
169+
int count = entries.size();
170+
if (count > 1) {
169171
task.showToUser(true);
170172
task.setTitle(Localization.lang("Indexing bib fields for %0", libraryName));
171173
}
172-
int i = 1;
173174
long startTime = System.currentTimeMillis();
174-
LOGGER.debug("Adding {} entries to index", entries.size());
175-
for (BibEntry entry : entries) {
175+
LOGGER.debug("Adding {} entries to index", count);
176+
for (int i = 0; i < count; i++) {
176177
if (task.isCancelled()) {
177178
LOGGER.debug("Indexing canceled");
178179
return;
179180
}
181+
BibEntry entry = entries.get(i);
180182
addToIndex(entry);
181-
task.updateProgress(i, entries.size());
182-
task.updateMessage(Localization.lang("%0 of %1 entries added to the index.", i, entries.size()));
183-
i++;
183+
task.updateProgress(i, count);
184+
task.updateMessage(Localization.lang("%0 of %1 entries added to the index.", i, count));
184185
}
185-
LOGGER.debug("Added {} entries to index in {} ms", entries.size(), System.currentTimeMillis() - startTime);
186+
LOGGER.debug("Added {} entries to index in {} ms", count, System.currentTimeMillis() - startTime);
186187
}
187188

188189
private void addToIndex(BibEntry bibEntry) {

jablib/src/main/java/org/jabref/model/entry/BibEntry.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,12 @@ private Optional<String> genericGetResolvedFieldOrAlias(Field field, @Nullable B
349349
Optional.of(database.resolveForStrings(result.get()));
350350
}
351351

352-
/**
353-
* Returns this entry's ID. It is used internally to distinguish different BibTeX entries.
354-
* <p>
355-
* It is <em>not</em> the citation key (which is stored in the {@link InternalField#KEY_FIELD} and also known as BibTeX key).
356-
*/
352+
/// Returns this entry's ID. It is used internally to distinguish different BibTeX entries.
353+
// It is **not** the citation key (which is stored in the {@link InternalField#KEY_FIELD} and also known as BibTeX key).
354+
///
355+
/// This id changes on each run of JabRef (because it is currently generated as increasing number).
356+
///
357+
/// For more stable ids, check {@link org.jabref.model.entry.SharedBibEntryData#getSharedID}
357358
public String getId() {
358359
return id;
359360
}

0 commit comments

Comments
 (0)