All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.polaris.core.msg.MessageResources Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package io.polaris.core.msg;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Qt
 * @since 1.8
 */
public class MessageResources {

	public final static String DEFAULT_MESSAGE_BASE_NAME = "msg,i18n,error,ValidationMessages";
	private final static Map resources = new ConcurrentHashMap<>();
	private static MessageResource defaultMessageResource = getMessageResource(DEFAULT_MESSAGE_BASE_NAME);

	public static MessageResource getMessageResource(String baseName) {
		return resources.computeIfAbsent(baseName, k -> new MessageResource(baseName));
	}

	public static MessageResource getDefaultMessageResource() {
		return defaultMessageResource;
	}

	public static void setDefaultMessageResource(MessageResource defaultMessageResource) {
		if (defaultMessageResource == null) {
			throw new IllegalArgumentException();
		}
		MessageResources.defaultMessageResource = defaultMessageResource;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy