From 7d480508632b4619cb662d4b9f5a1078990da827 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 13 Oct 2024 20:26:39 +0200 Subject: [PATCH] Replace "maybenull" by annotation (#11947) --- .../java/org/jabref/model/database/BibDatabase.java | 7 ++++--- src/main/java/org/jabref/model/entry/BibEntry.java | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jabref/model/database/BibDatabase.java b/src/main/java/org/jabref/model/database/BibDatabase.java index a5d1d461851..cf08b3ca27d 100644 --- a/src/main/java/org/jabref/model/database/BibDatabase.java +++ b/src/main/java/org/jabref/model/database/BibDatabase.java @@ -38,6 +38,7 @@ import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -87,13 +88,13 @@ public BibDatabase() { /** * Returns a text with references resolved according to an optionally given database. * - * @param toResolve maybenull The text to resolve. - * @param database maybenull The database to use for resolving the text. + * @param toResolve The text to resolve. + * @param database The database to use for resolving the text. * @return The resolved text or the original text if either the text or the database are null * @deprecated use {@link BibDatabase#resolveForStrings(String)} */ @Deprecated - public static String getText(String toResolve, BibDatabase database) { + public static String getText(@Nullable String toResolve, @Nullable BibDatabase database) { if ((toResolve != null) && (database != null)) { return database.resolveForStrings(toResolve); } diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index f0d2d43689e..9f59c00e99d 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -50,6 +50,7 @@ import com.google.common.eventbus.EventBus; import com.tobiasdiez.easybind.EasyBind; import com.tobiasdiez.easybind.optional.OptionalBinding; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -309,22 +310,21 @@ private Optional getSourceField(Field targetField, EntryType targetEntry, * If a database is given, this function will try to resolve any string * references in the field-value. * Also, if a database is given, this function will try to find values for - * unset fields in the entry linked by the "crossref" field, if any. + * unset fields in the entry linked by the "crossref" ({@link StandardField#CROSSREF} field, if any. * * @param field The field to return the value of. - * @param database maybenull - * The database of the bibtex entry. + * @param database The database of the bibtex entry. * @return The resolved field value or null if not found. */ - public Optional getResolvedFieldOrAlias(Field field, BibDatabase database) { + public Optional getResolvedFieldOrAlias(Field field, @Nullable BibDatabase database) { return genericGetResolvedFieldOrAlias(field, database, BibEntry::getFieldOrAlias); } - public Optional getResolvedFieldOrAliasLatexFree(Field field, BibDatabase database) { + public Optional getResolvedFieldOrAliasLatexFree(Field field, @Nullable BibDatabase database) { return genericGetResolvedFieldOrAlias(field, database, BibEntry::getFieldOrAliasLatexFree); } - private Optional genericGetResolvedFieldOrAlias(Field field, BibDatabase database, BiFunction> getFieldOrAlias) { + private Optional genericGetResolvedFieldOrAlias(Field field, @Nullable BibDatabase database, BiFunction> getFieldOrAlias) { if ((InternalField.TYPE_HEADER == field) || (InternalField.OBSOLETE_TYPE_HEADER == field)) { return Optional.of(type.get().getDisplayName()); }