Skip to content

Commit

Permalink
Add possibility to add supplier for enum
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcsakany committed Aug 23, 2024
1 parent 59e6489 commit f9a9c29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package hu.blackbelt.osgi.i18n.api;

import java.util.Locale;
import java.util.function.Supplier;

public interface EnumI18nService {

/**
Expand All @@ -9,6 +12,15 @@ public interface EnumI18nService {
*/
void register(Class<? extends Enum> clazz);

/**
* Register an Enum i18N message.
*
* @param clazz
* @param localeSupplier
*/
void register(Class<? extends Enum> clazz, Supplier<Locale> localeSupplier);


/**
* Unregister an Enm i18n message.
* @param clazz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ void activate(Config config) {
}

public void register(Class<? extends Enum> clazz) {
register(clazz, this.localeSupplier);
}

@Override
public void register(Class<? extends Enum> clazz, Supplier<Locale> localeSupplier) {
MessageStreamLoader messageStreamLoader = new ClassLoaderBasedMessageStreamLoader(clazz.getClassLoader());
ClassAndRequestContextLocaleBasedMessageResolver messageResolver =
new ClassAndRequestContextLocaleBasedMessageResolver(localeSupplier, clazz, messageStreamLoader, null);
Expand Down

0 comments on commit f9a9c29

Please sign in to comment.