diff --git a/src/main/java/org/jabref/model/entry/identifier/MathSciNetId.java b/src/main/java/org/jabref/model/entry/identifier/MathSciNetId.java index b85c500347d..255c701978b 100644 --- a/src/main/java/org/jabref/model/entry/identifier/MathSciNetId.java +++ b/src/main/java/org/jabref/model/entry/identifier/MathSciNetId.java @@ -21,7 +21,21 @@ public MathSciNetId(String identifier) { public static Optional parse(String mrNumberRaw) { // Take everything before whitespace or open bracket, so something like `619693 (82j:58046)` gets parsed correctly - return Optional.of(new MathSciNetId(StringUtil.tokenizeToList(mrNumberRaw, " (").get(0))); + String identifier = StringUtil.tokenizeToList(mrNumberRaw, " (").get(0).trim(); + return Optional.of(new MathSciNetId(identifier)); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MathSciNetId that = (MathSciNetId) o; + return Objects.equals(identifier, that.identifier); + } + + @Override + public int hashCode() { + return Objects.hash(identifier); } @Override diff --git a/src/test/java/org/jabref/model/entry/identifier/MathSciNetIdTest.java b/src/test/java/org/jabref/model/entry/identifier/MathSciNetIdTest.java new file mode 100644 index 00000000000..4d4cd6c63f5 --- /dev/null +++ b/src/test/java/org/jabref/model/entry/identifier/MathSciNetIdTest.java @@ -0,0 +1,16 @@ +package org.jabref.model.entry.identifier; + +import java.util.Optional; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class MathSciNetIdTest { + + @Test + public void parseRemovesNewLineCharacterAtEnd() throws Exception { + Optional id = MathSciNetId.parse("3014184\n"); + assertEquals(Optional.of(new MathSciNetId("3014184")), id); + } +}