Skip to content

Commit

Permalink
Refactor to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
t2gran committed Jan 25, 2019
1 parent b794a89 commit d1a8ecc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/main/java/org/opentripplanner/util/TranslatedString.java
Expand Up @@ -55,13 +55,14 @@ public static I18NString getI18NString(Map<String, String> translations) {
else {
I18NString ret;
// Check if we only have one name, even under multiple languages
if (new HashSet<>(translations.values()).size() < 2) {
Iterator it = translations.values().iterator();
if (!it.hasNext()) {
throw new IllegalArgumentException("Map of languages and translations is empty.");
}
long numberOfUniqValues = translations.values().stream().distinct().count();
if(numberOfUniqValues == 0) {
throw new IllegalArgumentException("Map of languages and translations is empty.");
}
else if(numberOfUniqValues == 1) {
ret = new NonLocalizedString(translations.values().iterator().next());
} else {
}
else {
ret = new TranslatedString(translations);
}
intern.put(translations, ret);
Expand Down

0 comments on commit d1a8ecc

Please sign in to comment.