public class DefaultMessageSourceResolvable extends Object implements MessageSourceResolvable, Serializable
MessageSourceResolvable
interface.
Offers an easy way to store all the necessary values needed to resolve
a message via a MessageSource
.MessageSource.getMessage(MessageSourceResolvable, java.util.Locale)
,
Serialized FormConstructor and Description |
---|
DefaultMessageSourceResolvable(MessageSourceResolvable resolvable)
Copy constructor: Create a new instance from another resolvable.
|
DefaultMessageSourceResolvable(String code)
Create a new DefaultMessageSourceResolvable.
|
DefaultMessageSourceResolvable(String[] codes)
Create a new DefaultMessageSourceResolvable.
|
DefaultMessageSourceResolvable(String[] codes,
Object[] arguments)
Create a new DefaultMessageSourceResolvable.
|
DefaultMessageSourceResolvable(String[] codes,
Object[] arguments,
String defaultMessage)
Create a new DefaultMessageSourceResolvable.
|
DefaultMessageSourceResolvable(String[] codes,
String defaultMessage)
Create a new DefaultMessageSourceResolvable.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
Object[] |
getArguments()
Return the array of arguments to be used to resolve this message.
|
String |
getCode()
Return the default code of this resolvable, that is,
the last one in the codes array.
|
String[] |
getCodes()
Return the codes to be used to resolve this message, in the order that
they should get tried.
|
String |
getDefaultMessage()
Return the default message to be used to resolve this message.
|
int |
hashCode() |
protected String |
resolvableToString()
Build a default String representation for this MessageSourceResolvable:
including codes, arguments, and default message.
|
boolean |
shouldRenderDefaultMessage()
Indicate whether the specified default message needs to be rendered for
substituting placeholders and/or
MessageFormat escaping. |
String |
toString()
The default implementation exposes the attributes of this MessageSourceResolvable.
|
public DefaultMessageSourceResolvable(String code)
code
- the code to be used to resolve this messagepublic DefaultMessageSourceResolvable(String[] codes)
codes
- the codes to be used to resolve this messagepublic DefaultMessageSourceResolvable(String[] codes, String defaultMessage)
codes
- the codes to be used to resolve this messagedefaultMessage
- the default message to be used to resolve this messagepublic DefaultMessageSourceResolvable(String[] codes, Object[] arguments)
codes
- the codes to be used to resolve this messagearguments
- the array of arguments to be used to resolve this messagepublic DefaultMessageSourceResolvable(@Nullable String[] codes, @Nullable Object[] arguments, @Nullable String defaultMessage)
codes
- the codes to be used to resolve this messagearguments
- the array of arguments to be used to resolve this messagedefaultMessage
- the default message to be used to resolve this messagepublic DefaultMessageSourceResolvable(MessageSourceResolvable resolvable)
resolvable
- the resolvable to copy from@Nullable public String getCode()
@Nullable public String[] getCodes()
MessageSourceResolvable
getCodes
in interface MessageSourceResolvable
@Nullable public Object[] getArguments()
MessageSourceResolvable
The default implementation simply returns null
.
getArguments
in interface MessageSourceResolvable
MessageFormat
@Nullable public String getDefaultMessage()
MessageSourceResolvable
The default implementation simply returns null
.
Note that the default message may be identical to the primary
message code (MessageSourceResolvable.getCodes()
), which effectively enforces
AbstractMessageSource.setUseCodeAsDefaultMessage(boolean)
for this particular message.
getDefaultMessage
in interface MessageSourceResolvable
null
if no defaultpublic boolean shouldRenderDefaultMessage()
MessageFormat
escaping.true
if the default message may contain argument placeholders;
false
if it definitely does not contain placeholders or custom escaping
and can therefore be simply exposed as-isgetDefaultMessage()
,
getArguments()
,
MessageSourceSupport.renderDefaultMessage(java.lang.String, java.lang.Object[], java.util.Locale)
protected final String resolvableToString()
public String toString()
To be overridden in more specific subclasses, potentially including the
resolvable content through resolvableToString()
.
toString
in class Object
resolvableToString()