refactor: 优化

This commit is contained in:
zhouhao
2024-12-20 12:21:45 +08:00
parent 737e387df9
commit 280eeba824
3 changed files with 35 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ import java.util.Map;
*
* @author zhouhao
* @since 4.0.18
* @see SingleI18nSupportEntity
* @see MultipleI18nSupportEntity
*/
public interface I18nSupportEntity {

View File

@@ -0,0 +1,20 @@
package org.hswebframework.web.i18n;
import org.apache.commons.collections4.MapUtils;
import java.util.Collections;
import java.util.Map;
public interface MultipleI18nSupportEntity extends I18nSupportEntity {
Map<String, Map<String, String>> getI18nMessages();
@Override
default Map<String, String> getI18nMessages(String key) {
Map<String, Map<String, String>> source = getI18nMessages();
if (MapUtils.isNotEmpty(source)) {
return Collections.emptyMap();
}
return source.get(key);
}
}

View File

@@ -0,0 +1,13 @@
package org.hswebframework.web.i18n;
import java.util.Map;
public interface SingleI18nSupportEntity extends I18nSupportEntity {
Map<String, String> getI18nMessages();
default Map<String, String> getI18nMessages(String key) {
return getI18nMessages();
}
}