Skip to content

Commit

Permalink
Replace "maybenull" by annotation (JabRef#11947)
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor authored Oct 13, 2024
1 parent 09e2585 commit 7d48050
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/jabref/model/database/BibDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -309,22 +310,21 @@ private Optional<Field> 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<String> getResolvedFieldOrAlias(Field field, BibDatabase database) {
public Optional<String> getResolvedFieldOrAlias(Field field, @Nullable BibDatabase database) {
return genericGetResolvedFieldOrAlias(field, database, BibEntry::getFieldOrAlias);
}

public Optional<String> getResolvedFieldOrAliasLatexFree(Field field, BibDatabase database) {
public Optional<String> getResolvedFieldOrAliasLatexFree(Field field, @Nullable BibDatabase database) {
return genericGetResolvedFieldOrAlias(field, database, BibEntry::getFieldOrAliasLatexFree);
}

private Optional<String> genericGetResolvedFieldOrAlias(Field field, BibDatabase database, BiFunction<BibEntry, Field, Optional<String>> getFieldOrAlias) {
private Optional<String> genericGetResolvedFieldOrAlias(Field field, @Nullable BibDatabase database, BiFunction<BibEntry, Field, Optional<String>> getFieldOrAlias) {
if ((InternalField.TYPE_HEADER == field) || (InternalField.OBSOLETE_TYPE_HEADER == field)) {
return Optional.of(type.get().getDisplayName());
}
Expand Down

0 comments on commit 7d48050

Please sign in to comment.