public class DefaultMessageBuilder extends AbstractMessageBuilder
MessageBuilder
implementation.
The following rules are applied to error message templates:
\
character is considered as escape character.{}
characters is considered as
optional argument.null
then it will be
replaced with empty string; if value is not defined then no
replacement will occur.<>
characters is considered as
required argument.null
then
whole template will be rendered as null
.()
characters is considered as
subtemplate.null
then it will be replaced with
empty string.\{}<>()
characters.DEFAULT
Modifier | Constructor and Description |
---|---|
protected |
DefaultMessageBuilder()
Constructs default
DefaultMessageBuilder . |
Modifier and Type | Method and Description |
---|---|
protected String |
renderArgument(Object value,
ValidationContext<?> context)
Renders the specified message argument.
|
protected String |
renderComponents(Validation<?>[] components,
ValidationContext<?> context)
Renders the specified array of validation components.
|
protected String |
renderContext(ValidationContext<?> context)
Renders the specified validation context.
|
protected String |
renderTemplate(String template,
Map<String,Object> arguments,
ValidationContext<?> context)
Renders the specified message template using the specified arguments.
|
protected String |
renderValue(Object value,
ValidationContext<?> context)
Renders the specified null-safe value.
|
buildMessage
protected DefaultMessageBuilder()
DefaultMessageBuilder
.protected String renderTemplate(String template, Map<String,Object> arguments, ValidationContext<?> context)
renderTemplate
in class AbstractMessageBuilder
template
- Message template.arguments
- Arguments to be substituted into the message template.context
- Validation context.protected String renderArgument(Object value, ValidationContext<?> context)
value
- Message argument to be rendered.context
- Validation context.protected String renderValue(Object value, ValidationContext<?> context)
value
- Value to be rendered.context
- Validation context.protected String renderComponents(Validation<?>[] components, ValidationContext<?> context)
null
if there are no messages available.components
- Array of validation components to be rendered.context
- Validation context.protected String renderContext(ValidationContext<?> context)
context.toString()
.context
- Validation context to be rendered.Copyright © 2011–2020 FoxLabs. All rights reserved.