Skip to content

Commit 51fc6d6

Browse files
committed
Use map.computeIfAbsent() rather than compute()
1 parent 7c45e47 commit 51fc6d6

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

validator/src/main/java/io/avaje/validation/core/DResourceBundleManager.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,7 @@ final class DResourceBundleManager {
2626
}
2727

2828
for (final var bundle : providedBundles) {
29-
map.compute(
30-
bundle.getLocale(),
31-
(local, list) -> {
32-
if (list == null) {
33-
list = new ArrayList<>();
34-
}
35-
list.add(bundle);
36-
return list;
37-
});
29+
map.computeIfAbsent(bundle.getLocale(), key -> new ArrayList<>()).add(bundle);
3830
}
3931
// since default is added last, it will be the last place messages will be resolved
4032
addBundle(DEFAULT_BUNDLE, localeResolver.defaultLocale());
@@ -45,15 +37,7 @@ final class DResourceBundleManager {
4537
}
4638

4739
private void addBundle(final String name, final Locale locale) {
48-
map.compute(
49-
locale,
50-
(local, list) -> {
51-
if (list == null) {
52-
list = new ArrayList<>();
53-
}
54-
list.add(getBundle(name, local));
55-
return list;
56-
});
40+
map.computeIfAbsent(locale, key -> new ArrayList<>()).add(getBundle(name, locale));
5741
}
5842

5943
@Nullable

0 commit comments

Comments
 (0)