Class MessageService
java.lang.Object
com.luchersol.core.util.MessageService
Message provides utility methods for retrieving and formatting localized messages from a properties file.
It supports colored output using Jansi and handles missing format arguments gracefully.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetProperty(String key) Retrieves the message text for the given key using the default locale.static StringgetProperty(String key, Locale locale) Retrieves the message text for the given key using the specified locale.static MessagesendMessage(String init, String function) Sends a formatted message for the given initial key and function, with no arguments.static MessagesendMessage(String init, String function, Object... args) Sends a formatted message for the given initial key, function, and arguments.
-
Method Details
-
getProperty
Retrieves the message text for the given key using the default locale.If the key is not found in the resource bundle, a default colored warning message is returned.
- Parameters:
key- the key of the message to retrieve- Returns:
- the message string for the given key, or a default colored message if not found
-
getProperty
Retrieves the message text for the given key using the specified locale.If the key is not found in the resource bundle for the given locale, a default colored warning message is returned.
- Parameters:
key- the key of the message to retrievelocale- the locale to use for message retrieval- Returns:
- the message string for the given key and locale, or a default colored message if not found
-
sendMessage
-
sendMessage
Sends a formatted message for the given initial key, function, and arguments. Handles missing format arguments gracefully with a colored error message.- Parameters:
init- the initial part of the message keyfunction- the function or message typeargs- the arguments to format the message- Returns:
- the formatted message string, or a colored error message if formatting fails
-