From edfdcbcb652aa50c9f349e043ce735c548dc5f93 Mon Sep 17 00:00:00 2001 From: morganteg Date: Mon, 27 Mar 2023 20:09:37 +0200 Subject: [PATCH] Fixes #626 Move StringUtils.removeEndIgnoreCase to StringUtil class --- .../java/org/jabref/logic/importer/AuthorListParser.java | 4 ++-- src/main/java/org/jabref/model/strings/StringUtil.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/AuthorListParser.java b/src/main/java/org/jabref/logic/importer/AuthorListParser.java index 0f4cdc85023b..f83d12afcff8 100644 --- a/src/main/java/org/jabref/logic/importer/AuthorListParser.java +++ b/src/main/java/org/jabref/logic/importer/AuthorListParser.java @@ -10,9 +10,9 @@ import java.util.Optional; import java.util.Set; -import org.apache.commons.lang3.StringUtils; import org.jabref.model.entry.Author; import org.jabref.model.entry.AuthorList; +import org.jabref.model.strings.StringUtil; public class AuthorListParser { @@ -98,7 +98,7 @@ public AuthorList parse(String listOfNames) { Objects.requireNonNull(listOfNames); // Handle the statement "and others" at the end, removing it - listOfNames = StringUtils.removeEndIgnoreCase(listOfNames.trim(), " AND OTHERS"); + listOfNames = StringUtil.removeStringAtTheEnd(listOfNames.trim(), " and others"); // Handle case names in order lastname, firstname and separated by "," // E.g., Ali Babar, M., Dingsøyr, T., Lago, P., van der Vliet, H. diff --git a/src/main/java/org/jabref/model/strings/StringUtil.java b/src/main/java/org/jabref/model/strings/StringUtil.java index 2a443306e4d1..a9a9d5db2505 100644 --- a/src/main/java/org/jabref/model/strings/StringUtil.java +++ b/src/main/java/org/jabref/model/strings/StringUtil.java @@ -761,4 +761,9 @@ public static String quoteStringIfSpaceIsContained(String string) { public static boolean containsWhitespace(String s) { return s.chars().anyMatch(Character::isWhitespace); } + + @ApacheCommonsLang3Allowed("No Guava equivalent existing - see https://stackoverflow.com/a/23825984") + public static String removeStringAtTheEnd(String string, String stringToBeRemoved) { + return StringUtils.removeEndIgnoreCase(string, stringToBeRemoved); + } }