Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No effective change, format style only on ResourceBundleManager #165

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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