avoid NPEs in Vocabulary.getTermBySynonym

This commit is contained in:
Claudio Atzori 2023-12-03 13:33:20 +01:00
parent 2a233a89aa
commit e6086efc53
1 changed files with 4 additions and 1 deletions

View File

@ -63,7 +63,10 @@ public class Vocabulary implements Serializable {
}
public VocabularyTerm getTermBySynonym(final String syn) {
return getTerm(synonyms.get(syn.toLowerCase()));
return Optional
.ofNullable(syn)
.map(s -> getTerm(synonyms.get(s.toLowerCase())))
.orElse(null);
}
public Qualifier getTermAsQualifier(final String termId) {