Skip to content

Commit

Permalink
No effective change, format style only on ResourceBundleManager
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-bygrave committed Oct 16, 2023
1 parent 4f2577c commit e04a40d
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.avaje.validation.core;

import static java.lang.System.Logger.Level.ERROR;
import static java.util.ResourceBundle.getBundle;

import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -15,8 +15,7 @@
import io.avaje.lang.Nullable;

final class ResourceBundleManager {
private static final System.Logger logger =
AppLog.getLogger(ResourceBundleManager.class);
private static final System.Logger logger = AppLog.getLogger(ResourceBundleManager.class);
private final Map<Locale, List<ResourceBundle>> map = new HashMap<>();
private static final List<ResourceBundle> EMPTY = List.of();
private static final String DEFAULT_BUNDLE = "io.avaje.validation.Messages";
Expand All @@ -34,19 +33,16 @@ final class ResourceBundleManager {
}
// since default is added last, it will be the last place messages will be resolved
addBundle(DEFAULT_BUNDLE, localeResolver.defaultLocale());

for (final Locale locale : localeResolver.otherLocales()) {
addBundle(DEFAULT_BUNDLE, locale);
}
}

private void addBundle(final String name, final Locale locale) {

try {
map.computeIfAbsent(locale, key -> new ArrayList<>()).add(getBundle(name, locale));

} catch (MissingResourceException e) {
logger.log(Level.ERROR, "failed to load " + name + " with locale " + locale);
logger.log(ERROR, "failed to load " + name + " with locale " + locale);
}
}

Expand Down

0 comments on commit e04a40d

Please sign in to comment.