diff --git a/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java b/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java index 6c5af2b26c6..51f55a6a62c 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java +++ b/src/main/java/org/opentripplanner/openstreetmap/model/OSMWithTags.java @@ -241,6 +241,7 @@ public boolean isOneOfTags(String key, Set oneOfTags) { * Returns a name-like value for an entity (if one exists). The otp: namespaced tags are created * by {@link OsmModule} */ + @Nullable public I18NString getAssumedName() { if (tags == null) { return null; @@ -273,10 +274,6 @@ public I18NString getAssumedName() { * other language found in OSM tag. */ public Map generateI18NForPattern(String pattern) { - if (pattern == null) { - return null; - } - Map i18n = new HashMap<>(); i18n.put(null, new StringBuffer()); Matcher matcher = Pattern.compile("\\{(.*?)}").matcher(pattern); @@ -290,17 +287,15 @@ public Map generateI18NForPattern(String pattern) { String defKey = matcher.group(1); // scan all translated tags Map i18nTags = getTagsByPrefix(defKey); - if (i18nTags != null) { - for (Map.Entry kv : i18nTags.entrySet()) { - if (!kv.getKey().equals(defKey)) { - String lang = kv.getKey().substring(defKey.length() + 1); - if (!i18n.containsKey(lang)) i18n.put(lang, new StringBuffer(i18n.get(null))); - } + for (Map.Entry kv : i18nTags.entrySet()) { + if (!kv.getKey().equals(defKey)) { + String lang = kv.getKey().substring(defKey.length() + 1); + if (!i18n.containsKey(lang)) i18n.put(lang, new StringBuffer(i18n.get(null))); } } // get the simple value (eg: description=...) String defTag = getTag(defKey); - if (defTag == null && i18nTags != null && i18nTags.size() != 0) { + if (defTag == null && !i18nTags.isEmpty()) { defTag = i18nTags.values().iterator().next(); } // get the translated value, if exists @@ -318,7 +313,7 @@ public Map generateI18NForPattern(String pattern) { return out; } - public Map getTagsByPrefix(String prefix) { + private Map getTagsByPrefix(String prefix) { Map out = new HashMap<>(); for (Map.Entry entry : tags.entrySet()) { String k = entry.getKey(); @@ -326,9 +321,6 @@ public Map getTagsByPrefix(String prefix) { out.put(k, entry.getValue()); } } - if (out.isEmpty()) { - return null; - } return out; } @@ -502,6 +494,7 @@ public void setCreativeName(I18NString creativeName) { this.creativeName = creativeName; } + @Nullable public String url() { return null; } diff --git a/src/main/java/org/opentripplanner/openstreetmap/wayproperty/NoteProperties.java b/src/main/java/org/opentripplanner/openstreetmap/wayproperty/NoteProperties.java index dc5affc1e61..1ad8e7c0da6 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/wayproperty/NoteProperties.java +++ b/src/main/java/org/opentripplanner/openstreetmap/wayproperty/NoteProperties.java @@ -13,9 +13,9 @@ public class NoteProperties { private static final Pattern patternMatcher = Pattern.compile("\\{(.*?)}"); - public String notePattern; + private final String notePattern; - public StreetNoteMatcher noteMatcher; + private final StreetNoteMatcher noteMatcher; public NoteProperties(String notePattern, StreetNoteMatcher noteMatcher) { this.notePattern = notePattern; diff --git a/src/test/java/org/opentripplanner/openstreetmap/model/OSMWithTagsTest.java b/src/test/java/org/opentripplanner/openstreetmap/model/OSMWithTagsTest.java index 3b50d0bff0d..efc9897bea7 100644 --- a/src/test/java/org/opentripplanner/openstreetmap/model/OSMWithTagsTest.java +++ b/src/test/java/org/opentripplanner/openstreetmap/model/OSMWithTagsTest.java @@ -227,7 +227,6 @@ void testGenerateI18NForPattern() { osmTags.addTag("wheelchair:description", "Wheelchair description EN"); osmTags.addTag("wheelchair:description:fr", "Wheelchair description FR"); - assertNull(osmTags.generateI18NForPattern(null)); Map expected = new HashMap<>(); expected.put(null, "");