Package io.micronaut.context
Interface MessageSource
- All Superinterfaces:
Ordered
- All Known Implementing Classes:
AbstractMessageSource,CompositeMessageSource,ResourceBundleMessageSource,StaticMessageSource
Interface for resolving messages from some source.
- Since:
- 1.2
- Author:
- graemerocher
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe context to use. -
Field Summary
FieldsFields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Method Summary
Modifier and TypeMethodDescriptiongetMessage(String code, MessageSource.MessageContext context) Resolve a message for the given code and context.default StringgetMessage(String code, MessageSource.MessageContext context, String defaultMessage) Resolve a message for the given code and context.default StringgetMessage(String code, String defaultMessage, Locale locale) Resolve a message for the given code and context.default StringgetMessage(String code, String defaultMessage, Locale locale, Object... variables) Resolve a message for the given code and context.default StringResolve a message for the given code and context.getMessage(String code, Locale locale) Resolve a message for the given code and context.getMessage(String code, Locale locale, Object... variables) Resolve a message for the given code and context.Resolve a message for the given code and context.getRawMessage(String code, MessageSource.MessageContext context) Resolve a message for the given code and context.default StringgetRawMessage(String code, MessageSource.MessageContext context, String defaultMessage) Resolve a message for the given code and context.default StringgetRequiredMessage(String code, MessageSource.MessageContext context) Resolve a message for the given code and context or throw an exception.default StringgetRequiredRawMessage(String code, MessageSource.MessageContext context) Resolve a message for the given code and context or throw an exception.interpolate(String template, MessageSource.MessageContext context) Interpolate the given message template.
-
Field Details
-
EMPTY
An empty message source.
-
-
Method Details
-
getMessage
Resolve a message for the given code and context.- Parameters:
code- The codelocale- The locale to use to resolve messages.- Returns:
- A message if present
-
getMessage
Resolve a message for the given code and context.- Parameters:
code- The codelocale- The locale to use to resolve messages.variables- The variables to use resolve message placeholders- Returns:
- A message if present
-
getMessage
Resolve a message for the given code and context.- Parameters:
code- The codelocale- The locale to use to resolve messages.variables- The variables to use resolve message placeholders- Returns:
- A message if present
-
getMessage
Resolve a message for the given code and context.- Parameters:
code- The codecontext- The context- Returns:
- A message if present
-
getMessage
Resolve a message for the given code and context.- Parameters:
code- The codedefaultMessage- The default message to use if no other message is foundlocale- The locale to use to resolve messages.- Returns:
- A message if present
-
getMessage
default String getMessage(String code, String defaultMessage, Locale locale, Map<String, Object> variables) Resolve a message for the given code and context.- Parameters:
code- The codedefaultMessage- The default message to use if no other message is foundlocale- The locale to use to resolve messages.variables- The variables to use resolve message placeholders- Returns:
- A message if present
-
getMessage
Resolve a message for the given code and context.- Parameters:
code- The codedefaultMessage- The default message to use if no other message is foundlocale- The locale to use to resolve messages.variables- The variables to use resolve message placeholders- Returns:
- A message if present
-
getMessage
Resolve a message for the given code and context.- Parameters:
code- The codecontext- The contextdefaultMessage- The default message to use if no other message is found- Returns:
- A message if present
-
getRawMessage
Resolve a message for the given code and context.- Parameters:
code- The codecontext- The context- Returns:
- A message if present
-
getRawMessage
default String getRawMessage(String code, MessageSource.MessageContext context, String defaultMessage) Resolve a message for the given code and context.- Parameters:
code- The codecontext- The contextdefaultMessage- The default message to use if no other message is found- Returns:
- A message if present
-
interpolate
Interpolate the given message template.- Parameters:
template- The templatecontext- The context to use.- Returns:
- The interpolated message.
- Throws:
IllegalArgumentException- If any argument specified is null
-
getRequiredMessage
Resolve a message for the given code and context or throw an exception.- Parameters:
code- The codecontext- The context- Returns:
- The message
- Throws:
NoSuchMessageException- if the message is not found
-
getRequiredRawMessage
Resolve a message for the given code and context or throw an exception.- Parameters:
code- The codecontext- The context- Returns:
- The message
- Throws:
NoSuchMessageException- if the message is not found
-