Package io.micronaut.context
Class StaticMessageSource
java.lang.Object
io.micronaut.context.AbstractMessageSource
io.micronaut.context.StaticMessageSource
- All Implemented Interfaces:
MessageSource
,Ordered
A static mutable message source.
- Since:
- 1.2
- Author:
- graemerocher
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.context.AbstractMessageSource
AbstractMessageSource.MessageKey
Nested classes/interfaces inherited from interface io.micronaut.context.MessageSource
MessageSource.MessageContext
-
Field Summary
Fields inherited from interface io.micronaut.context.MessageSource
EMPTY
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddMessage
(@NonNull String code, @NonNull String message) Adds a message to the default locale.Adds a message to the default locale.getRawMessage
(@NonNull String code, @NonNull MessageSource.MessageContext context) Resolve a message for the given code and context.Methods inherited from class io.micronaut.context.AbstractMessageSource
interpolate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.context.MessageSource
getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getRawMessage, getRequiredMessage, getRequiredRawMessage
-
Constructor Details
-
StaticMessageSource
public StaticMessageSource()
-
-
Method Details
-
addMessage
@NonNull public @NonNull StaticMessageSource addMessage(@NonNull @NonNull String code, @NonNull @NonNull String message) Adds a message to the default locale.- Parameters:
code
- The codemessage
- The message- Returns:
- This message source
-
addMessage
@NonNull public @NonNull StaticMessageSource addMessage(@NonNull @NonNull Locale locale, @NonNull @NonNull String code, @NonNull @NonNull String message) Adds a message to the default locale.- Parameters:
locale
- The localecode
- The codemessage
- The message- Returns:
- This message source
-
getRawMessage
@NonNull public @NonNull Optional<String> getRawMessage(@NonNull @NonNull String code, @NonNull @NonNull MessageSource.MessageContext context) Description copied from interface:MessageSource
Resolve a message for the given code and context.- Parameters:
code
- The codecontext
- The context- Returns:
- A message if present
-