@Singleton @Indexed(value=MessageSource.class) public interface MessageSource
Modifier and Type | Interface and Description |
---|---|
static interface |
MessageSource.MessageContext
The context to use.
|
Modifier and Type | Field and Description |
---|---|
static MessageSource |
EMPTY
An empty message source.
|
Modifier and Type | Method and Description |
---|---|
default java.util.Optional<java.lang.String> |
getMessage(java.lang.String code,
MessageSource.MessageContext context)
Resolve a message for the given code and context.
|
default java.lang.String |
getMessage(java.lang.String code,
MessageSource.MessageContext context,
java.lang.String defaultMessage)
Resolve a message for the given code and context.
|
java.util.Optional<java.lang.String> |
getRawMessage(java.lang.String code,
MessageSource.MessageContext context)
Resolve a message for the given code and context.
|
default java.lang.String |
getRawMessage(java.lang.String code,
MessageSource.MessageContext context,
java.lang.String defaultMessage)
Resolve a message for the given code and context.
|
default java.lang.String |
getRequiredMessage(java.lang.String code,
MessageSource.MessageContext context)
Resolve a message for the given code and context or throw an exception.
|
default java.lang.String |
getRequiredRawMessage(java.lang.String code,
MessageSource.MessageContext context)
Resolve a message for the given code and context or throw an exception.
|
java.lang.String |
interpolate(java.lang.String template,
MessageSource.MessageContext context)
Interpolate the given message template.
|
static final MessageSource EMPTY
@NonNull default java.util.Optional<java.lang.String> getMessage(@NonNull java.lang.String code, @NonNull MessageSource.MessageContext context)
code
- The codecontext
- The context@NonNull default java.lang.String getMessage(@NonNull java.lang.String code, @NonNull MessageSource.MessageContext context, @NonNull java.lang.String defaultMessage)
code
- The codecontext
- The contextdefaultMessage
- The default message to use if no other message is found@NonNull java.util.Optional<java.lang.String> getRawMessage(@NonNull java.lang.String code, @NonNull MessageSource.MessageContext context)
code
- The codecontext
- The context@NonNull default java.lang.String getRawMessage(@NonNull java.lang.String code, @NonNull MessageSource.MessageContext context, @NonNull java.lang.String defaultMessage)
code
- The codecontext
- The contextdefaultMessage
- The default message to use if no other message is found@NonNull java.lang.String interpolate(@NonNull java.lang.String template, @NonNull MessageSource.MessageContext context)
template
- The templatecontext
- The context to use.java.lang.IllegalArgumentException
- If any argument specified is null@NonNull default java.lang.String getRequiredMessage(@NonNull java.lang.String code, @NonNull MessageSource.MessageContext context)
code
- The codecontext
- The contextNoSuchMessageException
- if the message is not found@NonNull default java.lang.String getRequiredRawMessage(@NonNull java.lang.String code, @NonNull MessageSource.MessageContext context)
code
- The codecontext
- The contextNoSuchMessageException
- if the message is not found