See: Description
Interface | Description |
---|---|
ParameterConverter<I> |
A converter for a specific parameter type.
|
Class | Description |
---|---|
Messages |
A factory class to produce message bundle implementations.
|
Enum | Description |
---|---|
Message.Format |
The possible format types.
|
Annotation Type | Description |
---|---|
Cause |
Mark a parameter as being the "exception cause" parameter rather than a positional format parameter.
|
Field |
Indicate that a method parameter value should be applied to a field on the resultant exception object.
|
Formatter |
Indicate that the given parameter should be wrapped with a formatting object of the given class.
|
Locale |
Specifies a Locale for a typed logger.
|
Message |
Assigns a message string to a resource method.
|
MessageBundle |
Signify that an interface is a message bundle interface.
|
Param |
Identifies a parameter is to be used for constructing an exception and excluded from the formatting of the message.
|
Property |
Indicate that a method parameter value should be applied to a property (with a setter method) on the resultant exception object.
|
Often times you need to access a localized message. For example, you need to localize an exception message. Solder let's you retrieve this message from a typed message logger to avoid having to use hard-coded string messages.
First, declare the message bundle as an annotated interface with methods configured as message accessors. You can configured the messages to use printf-style interpolations of parameters (%s).
@MessageBundle public interface TrainMessages { @Message("No trains spotted due to %s") String noTrainsSpotted(String cause); }
Now inject the interface:
@Inject @MessageBundle TrainMessages messages;
And use it:
throw new BadDayException(messages.noTrainsSpotted("leaves on the line"));
Message
,
MessageBundle
,
Locale
Copyright © 2012 Seam Framework. All Rights Reserved.