diff --git a/jollyday-core/src/main/java/de/focus_shift/jollyday/core/CalendarHierarchy.java b/jollyday-core/src/main/java/de/focus_shift/jollyday/core/CalendarHierarchy.java index fad511919..1b75d32fc 100644 --- a/jollyday-core/src/main/java/de/focus_shift/jollyday/core/CalendarHierarchy.java +++ b/jollyday-core/src/main/java/de/focus_shift/jollyday/core/CalendarHierarchy.java @@ -1,11 +1,12 @@ package de.focus_shift.jollyday.core; -import de.focus_shift.jollyday.core.util.ResourceUtil; - import java.util.HashMap; import java.util.Locale; import java.util.Map; +import static de.focus_shift.jollyday.core.util.ResourceUtil.UNDEFINED; +import static de.focus_shift.jollyday.core.util.ResourceUtil.getCountryDescription; + /** * Bean class for describing the configuration hierarchy. */ @@ -45,21 +46,17 @@ public String getId() { * @return the description */ public String getDescription() { - return getDescription(Locale.getDefault()); + return receiveFallbackDescription(getCountryDescription(getPropertiesKey())); } /** * Returns the hierarchies description text from the resource bundle. * - * @param l Locale to return the description text for. + * @param locale Locale to return the description text for. * @return Description text */ - public String getDescription(Locale l) { - String descr = ResourceUtil.getCountryDescription(l, getPropertiesKey()); - if (ResourceUtil.UNDEFINED.equals(descr) && fallbackDescription != null) { - descr = fallbackDescription; - } - return descr; + public String getDescription(Locale locale) { + return receiveFallbackDescription(getCountryDescription(locale, getPropertiesKey())); } /** @@ -81,7 +78,7 @@ private String getPropertiesKey() { * Compares Hierarchies by id. */ @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj instanceof CalendarHierarchy) { return ((CalendarHierarchy) obj).getId().equals(this.getId()); } @@ -118,8 +115,14 @@ public Map getChildren() { /** * @param description the fallback description */ - public void setFallbackDescription(String description) { + public void setFallbackDescription(final String description) { this.fallbackDescription = description; } + private String receiveFallbackDescription(final String description) { + if (UNDEFINED.equals(description) && fallbackDescription != null) { + return fallbackDescription; + } + return description; + } } diff --git a/jollyday-core/src/main/java/de/focus_shift/jollyday/core/Holiday.java b/jollyday-core/src/main/java/de/focus_shift/jollyday/core/Holiday.java index 197cf06a0..b558553f2 100644 --- a/jollyday-core/src/main/java/de/focus_shift/jollyday/core/Holiday.java +++ b/jollyday-core/src/main/java/de/focus_shift/jollyday/core/Holiday.java @@ -1,12 +1,12 @@ package de.focus_shift.jollyday.core; -import de.focus_shift.jollyday.core.util.ResourceUtil; - import java.time.LocalDate; import java.util.Locale; import java.util.Objects; import java.util.Optional; +import static de.focus_shift.jollyday.core.util.ResourceUtil.getHolidayDescription; + /** * Represents the holiday and contains the actual date and an localized * description. @@ -118,7 +118,7 @@ public String getPropertiesKey() { * @return Description for this holiday */ public String getDescription() { - return ResourceUtil.getHolidayDescription(Locale.getDefault(), getPropertiesKey()); + return getHolidayDescription(getPropertiesKey()); } /** @@ -128,7 +128,7 @@ public String getDescription() { * @return Description for this holiday */ public String getDescription(Locale locale) { - return ResourceUtil.getHolidayDescription(locale, getPropertiesKey()); + return getHolidayDescription(locale, getPropertiesKey()); } @Override diff --git a/jollyday-core/src/main/java/de/focus_shift/jollyday/core/util/ResourceUtil.java b/jollyday-core/src/main/java/de/focus_shift/jollyday/core/util/ResourceUtil.java index e23baf92e..4091c70ff 100644 --- a/jollyday-core/src/main/java/de/focus_shift/jollyday/core/util/ResourceUtil.java +++ b/jollyday-core/src/main/java/de/focus_shift/jollyday/core/util/ResourceUtil.java @@ -91,7 +91,7 @@ public static String getCountryDescription(final Locale locale, final String key if (key != null) { return getDescription(COUNTRY_PROPERTY_PREFIX + "." + key.toLowerCase(), getCountryDescriptions(locale)); } - return ResourceUtil.UNDEFINED; + return UNDEFINED; } /**