com.ksoot.common.spring.util.MessageProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-commons Show documentation
Show all versions of spring-boot-commons Show documentation
Commons Spring boot components and Utilities
The newest version!
package com.ksoot.common.spring.util;
import java.util.Locale;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.lang.NonNull;
/**
* @author Rajveer Singh
*/
public class MessageProvider {
private static MessageSource messageSource;
public MessageProvider(@NonNull final MessageSource messageSource) {
MessageProvider.messageSource = messageSource;
}
public static String getMessage(final String messageCode, final String defaultMessage) {
return messageSource.getMessage(messageCode, null, defaultMessage, Locale.getDefault());
}
public static String getMessage(
final String messageCode, final String defaultMessage, final Object... params) {
return messageSource.getMessage(messageCode, params, defaultMessage, Locale.getDefault());
}
public static String getMessage(final MessageResolver messageResolver) {
return messageSource.getMessage(
messageResolver.messageCode(), null, messageResolver.defaultMessage(), Locale.getDefault());
}
public static String getMessage(final MessageResolver messageResolver, final Object... params) {
return messageSource.getMessage(
messageResolver.messageCode(),
params,
messageResolver.defaultMessage(),
Locale.getDefault());
}
public static String getMessage(final MessageSourceResolvable resolvable) {
return messageSource.getMessage(resolvable, Locale.getDefault());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy