From 9089c5814271325518f031e2f018482f779e7c1b Mon Sep 17 00:00:00 2001 From: Tomas Peiretti Date: Thu, 22 Aug 2024 08:52:43 -0300 Subject: [PATCH] refactor: simplify getFlagCode method --- .../vaadin/addons/localecombobox/LocaleComboBox.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/flowingcode/vaadin/addons/localecombobox/LocaleComboBox.java b/src/main/java/com/flowingcode/vaadin/addons/localecombobox/LocaleComboBox.java index 1688d44..527747f 100644 --- a/src/main/java/com/flowingcode/vaadin/addons/localecombobox/LocaleComboBox.java +++ b/src/main/java/com/flowingcode/vaadin/addons/localecombobox/LocaleComboBox.java @@ -157,12 +157,8 @@ private Locale getLocaleForDisplay() { private String getFlagCode(Locale locale) { String countryCode = locale.getCountry(); - Optional isoCode = LocaleCountryConverter.convertToISO3166Code(countryCode); - - if (isoCode.isPresent()) - return isoCode.get().toLowerCase(); - - return DEFAULT_FLAG_CODE; + return LocaleCountryConverter.convertToISO3166Code(countryCode).map(String::toLowerCase) + .orElse(DEFAULT_FLAG_CODE); } private void onValueChange(ComponentValueChangeEvent, Locale> event) {