Skip to content

Commit 2570ef2

Browse files
javier-godoypaodb
authored andcommitted
style: apply code formatter
1 parent 579495d commit 2570ef2

File tree

5 files changed

+41
-48
lines changed

5 files changed

+41
-48
lines changed

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

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
/**
3333
* Vaadin ComboBox extension that allows to choose between multiple locales.
34-
*
34+
*
3535
* @author Tomas Peiretti / Flowing Code
3636
*/
3737
@SuppressWarnings("serial")
@@ -46,47 +46,43 @@ public class LocaleComboBox extends ComboBox<Locale> {
4646

4747
/**
4848
* Represents the built-in display modes for locale names in the {@link LocaleComboBox} component.
49-
* <p>
50-
* These enums can be used in {@link #setDisplayMode(DisplayMode)} to easily switch between the
49+
*
50+
* <p>These enums can be used in {@link #setDisplayMode(DisplayMode)} to easily switch between the
5151
* built-in display modes.
5252
*/
5353
public enum DisplayMode {
5454

5555
/**
5656
* Default display mode.
57-
* <p>
58-
* In this mode, the Locale names are displayed using the default locale's display format.
57+
*
58+
* <p>In this mode, the Locale names are displayed using the default locale's display format.
5959
*/
6060
DEFAULT,
6161

6262
/**
6363
* Selected display mode.
64-
* <p>
65-
* In this mode, the Locale names are displayed using the formatting of the currently selected
66-
* locale.
64+
*
65+
* <p>In this mode, the Locale names are displayed using the formatting of the currently
66+
* selected locale.
6767
*/
6868
SELECTED,
6969

7070
/**
7171
* Custom display mode.
72-
* <p>
73-
* In this mode, the Locale names are displayed using the formatting of the specific locale set
74-
* by {@link #setDisplayLocale(Locale)}.
72+
*
73+
* <p>In this mode, the Locale names are displayed using the formatting of the specific locale
74+
* set by {@link #setDisplayLocale(Locale)}.
7575
*/
7676
CUSTOM;
7777
}
7878

7979
private DisplayMode displayMode = DisplayMode.DEFAULT;
8080
private Locale customDisplayLocale;
8181

82-
/**
83-
* Indicates whether the flags should be displayed alongside the locale names.
84-
*/
82+
/** Indicates whether the flags should be displayed alongside the locale names. */
8583
private boolean hasFlags = true;
8684

87-
/**
88-
* Creates a new instance of {@code LocaleComboBox}.
89-
*/
85+
/** Creates a new instance of {@code LocaleComboBox}. */
9086
public LocaleComboBox() {
9187
setItemLabelGenerator(item -> item.getDisplayName(getLocaleForDisplay()));
9288
setRenderer(getLocaleRenderer());
@@ -95,7 +91,7 @@ public LocaleComboBox() {
9591

9692
/**
9793
* Creates a new instance of {@code LocaleComboBox} with the desired locales
98-
*
94+
*
9995
* @param locales the {@code Collection} of {@code Locale} to include in the combobox
10096
*/
10197
public LocaleComboBox(Collection<Locale> locales) {
@@ -105,9 +101,8 @@ public LocaleComboBox(Collection<Locale> locales) {
105101

106102
/**
107103
* Sets the display mode of the LocaleComboBox.
108-
*
104+
*
109105
* @param displayMode the display mode to use
110-
*
111106
* @see DisplayMode
112107
*/
113108
public void setDisplayMode(DisplayMode displayMode) {
@@ -117,11 +112,11 @@ public void setDisplayMode(DisplayMode displayMode) {
117112
/**
118113
* Sets the locale used for formatting Locale names when {@link DisplayMode#CUSTOM} mode is
119114
* active.
120-
* <p>
121-
* This locale determines how Locale names are formatted when {@link DisplayMode#CUSTOM} is
115+
*
116+
* <p>This locale determines how Locale names are formatted when {@link DisplayMode#CUSTOM} is
122117
* selected as the display mode. If the display mode is any other than {@link DisplayMode#CUSTOM},
123118
* this setting is ignored.
124-
*
119+
*
125120
* @param displayLocale the {@code Locale} to use for formatting.
126121
*/
127122
public void setDisplayLocale(Locale displayLocale) {
@@ -139,10 +134,10 @@ public boolean hasFlags() {
139134

140135
/**
141136
* Sets whether flags should be displayed alongside locale names.
142-
* <p>
143-
* This method updates the internal state to reflect whether flags should be displayed and updates
144-
* the rendering based on the new state.
145-
*
137+
*
138+
* <p>This method updates the internal state to reflect whether flags should be displayed and
139+
* updates the rendering based on the new state.
140+
*
146141
* @param hasFlags A {@code boolean} indicating whether flags should be displayed or not.
147142
*/
148143
public void setHasFlags(boolean hasFlags) {
@@ -152,8 +147,7 @@ public void setHasFlags(boolean hasFlags) {
152147
}
153148

154149
private LitRenderer<Locale> getLocaleRenderer() {
155-
return LitRenderer
156-
.<Locale>of(
150+
return LitRenderer.<Locale>of(
157151
"""
158152
<vaadin-horizontal-layout class="${item.layoutClass}">
159153
<span class="fi fi-${item.countryCode} ${item.flagClass} alt="${item.countryName}'s flag"></span>
@@ -167,17 +161,18 @@ private LitRenderer<Locale> getLocaleRenderer() {
167161
}
168162

169163
private LitRenderer<Locale> getLocaleRendererWithoutFlags() {
170-
return LitRenderer.<Locale>of("""
164+
return LitRenderer.<Locale>of(
165+
"""
171166
<vaadin-horizontal-layout class="${item.layoutClass}">
172167
<span>${item.displayName}</span>
173-
</vaadin-horizontal-layout>""").withProperty("layoutClass", loc -> ITEM_LAYOUT_CLASS_NAME)
168+
</vaadin-horizontal-layout>""")
169+
.withProperty("layoutClass", loc -> ITEM_LAYOUT_CLASS_NAME)
174170
.withProperty("displayName", loc -> loc.getDisplayName(getLocaleForDisplay()));
175171
}
176172

177173
private Locale getLocaleForDisplay() {
178174

179175
switch (displayMode) {
180-
181176
case CUSTOM:
182177
return Optional.ofNullable(customDisplayLocale).orElseGet(this::getLocale);
183178

@@ -191,7 +186,8 @@ private Locale getLocaleForDisplay() {
191186

192187
private String getFlagCode(Locale locale) {
193188
String countryCode = locale.getCountry();
194-
return LocaleCountryConverter.convertToISO3166Code(countryCode).map(String::toLowerCase)
189+
return LocaleCountryConverter.convertToISO3166Code(countryCode)
190+
.map(String::toLowerCase)
195191
.orElse(DEFAULT_FLAG_CODE);
196192
}
197193

@@ -215,5 +211,4 @@ private void setPrefixFlag(Locale locale) {
215211
flagIcon.addClassNames("fi", "fi-" + this.getFlagCode(locale));
216212
setPrefixComponent(flagIcon);
217213
}
218-
219214
}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
package com.flowingcode.vaadin.addons.localecombobox;
2121

2222
import java.util.HashMap;
23-
import java.util.List;
2423
import java.util.Map;
2524
import java.util.Optional;
2625

2726
/**
2827
* Utility class for converting between different formats of country codes.
2928
*
30-
* <p>
31-
* The {@code LocaleCountryConverter} class provides methods to convert country codes from ISO
29+
* <p>The {@code LocaleCountryConverter} class provides methods to convert country codes from ISO
3230
* 3166-1 alpha-2, alpha-3, and numeric-3 formats to the 3166-1 alpha-2 format. The class uses
3331
* static methods, so no instances are needed.
3432
*
@@ -307,13 +305,11 @@ private static void add(String alpha2, String alpha3, int numeric) {
307305
* Converts a country code to its corresponding ISO 3166-1 alpha-2 code.
308306
*
309307
* @param countryCode The country code to be converted. This can be in ISO 3166-1 alpha-2 format
310-
* (e.g., "AR"), ISO 3166-1 alpha-3 format (e.g., "ARG"), or numeric-3 format (e.g.,
311-
* "032").
308+
* (e.g., "AR"), ISO 3166-1 alpha-3 format (e.g., "ARG"), or numeric-3 format (e.g., "032").
312309
* @return An {@code Optional} containing the ISO 3166-1 alpha-2 code if the conversion is
313-
* successful.
310+
* successful.
314311
*/
315312
public static Optional<String> convertToISO3166Code(String countryCode) {
316313
return Optional.ofNullable(conversions.get(countryCode.toUpperCase()));
317314
}
318-
319315
}

src/test/java/com/flowingcode/vaadin/addons/localecombobox/BaseLocaleComboBoxDemo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import com.vaadin.flow.component.Text;
2424
import com.vaadin.flow.component.html.Div;
2525
import com.vaadin.flow.component.html.Span;
26-
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
2726
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
2827
import com.vaadin.flow.component.orderedlayout.FlexComponent.JustifyContentMode;
28+
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
2929

3030
@SuppressWarnings("serial")
3131
public class BaseLocaleComboBoxDemo extends Div {
@@ -45,5 +45,4 @@ protected HorizontalLayout createHorizontalContainer(Component component, Locale
4545
container.expand(combo);
4646
return container;
4747
}
48-
4948
}

src/test/java/com/flowingcode/vaadin/addons/localecombobox/DisplayModeDemo.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ public class DisplayModeDemo extends BaseLocaleComboBoxDemo {
3636
public DisplayModeDemo() {
3737

3838
List<Locale> localeList =
39-
Arrays.stream(Locale.getAvailableLocales()).filter(loc -> !loc.getDisplayName().isBlank())
40-
.sorted((l1, l2) -> l1.getDisplayName().compareTo(l2.getDisplayName())).toList();
39+
Arrays.stream(Locale.getAvailableLocales())
40+
.filter(loc -> !loc.getDisplayName().isBlank())
41+
.sorted((l1, l2) -> l1.getDisplayName().compareTo(l2.getDisplayName()))
42+
.toList();
4143

4244
LocaleComboBox defaultDisplayLocale = new LocaleComboBox(localeList);
4345
LocaleComboBox koreanLocaleCombo = new LocaleComboBox();
@@ -63,5 +65,4 @@ public DisplayModeDemo() {
6365
// show-source add(koreanLocaleCombo);
6466
// show-source add(selectedLocaleCombo);
6567
}
66-
6768
}

src/test/java/com/flowingcode/vaadin/addons/localecombobox/RenderingDemo.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public class RenderingDemo extends BaseLocaleComboBoxDemo {
3535
public RenderingDemo() {
3636

3737
List<Locale> localeList =
38-
Arrays.stream(Locale.getAvailableLocales()).filter(loc -> !loc.getDisplayName().isBlank())
39-
.sorted((l1, l2) -> l1.getDisplayName().compareTo(l2.getDisplayName())).toList();
38+
Arrays.stream(Locale.getAvailableLocales())
39+
.filter(loc -> !loc.getDisplayName().isBlank())
40+
.sorted((l1, l2) -> l1.getDisplayName().compareTo(l2.getDisplayName()))
41+
.toList();
4042

4143
LocaleComboBox defaultLocaleCombo = new LocaleComboBox(localeList);
4244
LocaleComboBox flagsLocaleCombo = new LocaleComboBox(localeList);

0 commit comments

Comments
 (0)