Skip to content

Commit 9089c58

Browse files
elPeirettijavier-godoy
authored andcommitted
refactor: simplify getFlagCode method
1 parent 9b317d3 commit 9089c58

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/main/java/com/flowingcode/vaadin/addons/localecombobox/LocaleComboBox.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,8 @@ private Locale getLocaleForDisplay() {
157157

158158
private String getFlagCode(Locale locale) {
159159
String countryCode = locale.getCountry();
160-
Optional<String> isoCode = LocaleCountryConverter.convertToISO3166Code(countryCode);
161-
162-
if (isoCode.isPresent())
163-
return isoCode.get().toLowerCase();
164-
165-
return DEFAULT_FLAG_CODE;
160+
return LocaleCountryConverter.convertToISO3166Code(countryCode).map(String::toLowerCase)
161+
.orElse(DEFAULT_FLAG_CODE);
166162
}
167163

168164
private void onValueChange(ComponentValueChangeEvent<ComboBox<Locale>, Locale> event) {

0 commit comments

Comments
 (0)