![JAR search and dependency download from the Maven repository](/logo.png)
com.github.anonymousmister.springtool.MessageUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boot-fast-tool Show documentation
Show all versions of boot-fast-tool Show documentation
Parent pom providing dependency and plugin management for applications
built with Maven
package com.github.anonymousmister.springtool;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.lang.Nullable;
import java.util.Locale;
/**
* @author mister
*/
public class MessageUtil {
private static MessageSource messageSource;
private static Object lock = new Object();
private MessageUtil() {
}
private static void initMessageSource() {
if (messageSource == null) {
synchronized (lock) {
if (messageSource == null) {
messageSource = SpringBeanUtil.getBean(MessageSource.class);
}
}
}
}
public static String codLi18n(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) {
initMessageSource();
return messageSource.getMessage(code, args, defaultMessage, locale);
}
public static String codLi18n(String code) {
return codLi18n(code, null, null, LocaleContextHolder.getLocale());
}
public static String codLi18n(String code, String defaultMessage) {
return codLi18n(code, null, defaultMessage, LocaleContextHolder.getLocale());
}
public static String codLi18n(String code, Object[] args, String defaultMessage) {
return codLi18n(code, args, defaultMessage, LocaleContextHolder.getLocale());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy