Package io.micronaut.context
Interface LocalizedMessageSource
- All Known Implementing Classes:
AbstractLocalizedMessageSource
,HttpLocalizedMessageSource
public interface LocalizedMessageSource
Retrieve messages for the resolved locale.
- Since:
- 3.4.0
- Author:
- Sergio del Amo
-
Method Summary
Modifier and TypeMethodDescriptiongetMessage
(@NonNull String code) Resolve a message for the given code.getMessage
(@NonNull String code, Object... variables) Resolve a message for the given code and variables for the messages.Resolve a message for the given code and variables for the messages.getMessageOrDefault
(@NonNull String code, @NonNull String defaultMessage) Resolve a message for the given code.Resolve a message for the given code.getMessageOrDefault
(@NonNull String code, @NonNull String defaultMessage, Map<String, Object> variables) Resolve a message for the given code.
-
Method Details
-
getMessage
Resolve a message for the given code.- Parameters:
code
- The code- Returns:
- A message if present
-
getMessage
Resolve a message for the given code and variables for the messages.- Parameters:
code
- The codevariables
- to be used to interpolate the message- Returns:
- A message if present
-
getMessage
@NonNull @NonNull Optional<String> getMessage(@NonNull @NonNull String code, Map<String, Object> variables) Resolve a message for the given code and variables for the messages.- Parameters:
code
- The codevariables
- to be used to interpolate the message- Returns:
- A message if present
-
getMessageOrDefault
@NonNull default @NonNull String getMessageOrDefault(@NonNull @NonNull String code, @NonNull @NonNull String defaultMessage) Resolve a message for the given code. If the message is not present then default message is returned.- Parameters:
code
- The codedefaultMessage
- The default message to use if no other message is found- Returns:
- A message if present. If the message is not present then default message supplied is returned.
-
getMessageOrDefault
@NonNull default @NonNull String getMessageOrDefault(@NonNull @NonNull String code, @NonNull @NonNull String defaultMessage, Object... variables) Resolve a message for the given code. If the message is not present then default message is returned.- Parameters:
code
- The codedefaultMessage
- The default message to use if no other message is foundvariables
- to be used to interpolate the message- Returns:
- A message if present. If the message is not present then default message supplied is returned.
-
getMessageOrDefault
@NonNull default @NonNull String getMessageOrDefault(@NonNull @NonNull String code, @NonNull @NonNull String defaultMessage, Map<String, Object> variables) Resolve a message for the given code. If the message is not present then default message is returned.- Parameters:
code
- The codedefaultMessage
- The default message to use if no other message is foundvariables
- to be used to interpolate the message- Returns:
- A message if present. If the message is not present then default message supplied is returned.
-