V
- The type of value to be convertedpublic interface Converter<V> extends Validation<V>
Converter
instances should be registered and obtained from
ConverterFactory
.ConverterFactory
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends arguments to be substituted into the error message template.
|
<T> V |
decode(String value,
ValidationContext<T> context)
Converts string representation of value into object.
|
<T> String |
encode(V value,
ValidationContext<T> context)
Converts value into string representation.
|
String |
getMessageTemplate(ValidationContext<?> context)
Returns localized error message template.
|
Class<V> |
getType()
Returns the type of value to be converted.
|
Class<V> getType()
getType
in interface Validation<V>
String getMessageTemplate(ValidationContext<?> context)
This method may return null
if converter never generates
MalformedValueException
.
getMessageTemplate
in interface Validation<V>
context
- Validation context.boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
appendMessageArguments
in interface Validation<V>
context
- Validation context.arguments
- Arguments to be substituted into the error message
template.true
if error message template needs to be rendered;
false
otherwise.<T> V decode(String value, ValidationContext<T> context)
The method ValidationContext.isLocalizedConvert()
determines
if converter should take locale into account. Locale can be obtained
through the method ValidationContext.getMessageLocale()
.
T
- The type of validated entity.value
- String representation of value.context
- Validation context.MalformedValueException
- if conversion fails.<T> String encode(V value, ValidationContext<T> context)
The method ValidationContext.isLocalizedConvert()
determines
if converter should take locale into account. Locale can be obtained
through the method ValidationContext.getMessageLocale()
.
T
- The type of validated entity.value
- Value to be encoded.context
- Validation context.Copyright © 2011–2020 FoxLabs. All rights reserved.