-
- All Superinterfaces:
LocalizableObject
- All Known Subinterfaces:
NlsMessage,ValidationResult
- All Known Implementing Classes:
AbstractValidationResult,ApplicationException,CliArgumentMandatoryException,CliDuplicateOptionAliasException,CliDuplicateOptionsException,CliException,CliInvalidUsageException,CliNoArgumentsException,CliTypeNotExtendingException,ComposedValidationFailure,DuplicateObjectException,ObjectMismatchException,ObjectNotFoundException,ObjectNotFoundUserException,ReadOnlyException,RuntimeIoException,TechnicalErrorUserException,ValidationFailure,ValidationResultValid
public interface Localizable extends LocalizableObject
Interface for an object that can betranslatedto a givenLocale. It is the API to abstract fromNlsMessageprovided bymmm-nls. To minimize dependencies you can mock it withofStatic(String)wrapping a regularString. For real native language support (NLS) addmmm-nlsas dependency and require moduleio.github.mmm.nls.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static StringcreateBundleName(Class<?> type)default ObjectgetArgument(String key)This method gets the language independent argument value for the givenkey.default StringgetLocalizedMessage()default StringgetLocalizedMessage(Locale locale)This method gets the resolved and localized message.voidgetLocalizedMessage(Locale locale, Appendable buffer)This method writes thelocalized messageto the givenAppendable.default StringgetMessage()ATTENTION:
In most cases you wand to usegetLocalizedMessage(Locale)instead of this method.static LocalizableofStatic(String message)default LocalizabletoLocalizable()This method is the equivalent toObject.toString()with native language support.
-
-
-
Method Detail
-
getMessage
default String getMessage()
ATTENTION:
In most cases you wand to usegetLocalizedMessage(Locale)instead of this method.- Returns:
- the untranslated message with arguments filled in. This results in the message in its original language that should typically be English.
- See Also:
getLocalizedMessage()
-
getLocalizedMessage
default String getLocalizedMessage()
This method tries to get thelocalized messageasStringusing thedefault locale. ATTENTION:
If possible try to avoid using this method and usegetLocalizedMessage(Locale)instead (e.g. using springLocaleContextHolderto get the users locale).- Returns:
- the localized message.
-
getLocalizedMessage
default String getLocalizedMessage(Locale locale)
This method gets the resolved and localized message.- Parameters:
locale- is the locale to translate to.- Returns:
- the localized message.
-
getLocalizedMessage
void getLocalizedMessage(Locale locale, Appendable buffer)
- Parameters:
locale- theLocaleto translate to.buffer- theAppendablewhere towritethe message to.- See Also:
getLocalizedMessage(Locale)
-
toLocalizable
default Localizable toLocalizable()
Description copied from interface:LocalizableObjectThis method is the equivalent toObject.toString()with native language support.- Specified by:
toLocalizablein interfaceLocalizableObject- Returns:
- an
Localizablerepresenting this object.
-
getArgument
default Object getArgument(String key)
This method gets the language independent argument value for the givenkey.- Parameters:
key- is the name of the requested argument.- Returns:
- the argument value for the given key or
nullif NOT defined.
-
ofStatic
static Localizable ofStatic(String message)
- Parameters:
message- themessage.- Returns:
- a dummy implementation of
Localizablefor the givenmessagethat does not support localization and simply ignores any givenLocale.
-
-