V
- The type of value to be convertedpublic abstract class AbstractConverter<V> extends AbstractValidation<V> implements Converter<V>
Converter
interface.Constructor and Description |
---|
AbstractConverter() |
Modifier and Type | Method and Description |
---|---|
<T> V |
decode(String value,
ValidationContext<T> context)
Converts string representation of value into object.
|
protected <T> V |
doDecode(String value,
ValidationContext<T> context)
Converts non-empty string representation of value into object.
|
protected <T> String |
doEncode(V value,
ValidationContext<T> context)
Converts null-safe value into string representation.
|
<T> String |
encode(V value,
ValidationContext<T> context)
Converts value into string representation.
|
appendMessageArguments, getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendMessageArguments, getMessageTemplate, getType
public <T> V decode(String value, ValidationContext<T> context)
Invokes doDecode(String, ValidationContext)
if value is not
null
or empty; returns null
otherwise.
decode
in interface Converter<V>
T
- The type of validated entity.value
- String representation of value.context
- Validation context.MalformedValueException
- if conversion fails.doDecode(String, ValidationContext)
protected <T> V doDecode(String value, ValidationContext<T> context)
This method always throws MalformedValueException
and
should be overriden in subclasses.
T
- The type of validated entity.value
- Non-empty string representation of value.context
- Validation context.MalformedValueException
- always.public <T> String encode(V value, ValidationContext<T> context)
Invokes doEncode(Object, ValidationContext)
if value is not
null
; returns empty string otherwise.
encode
in interface Converter<V>
T
- The type of validated entity.value
- Value to be encoded.context
- Validation context.doEncode(Object, ValidationContext)
protected <T> String doEncode(V value, ValidationContext<T> context)
This method simply returns value.toString()
and could
be overriden in subclasses.
T
- The type of validated entity.value
- Null-safe value to be encoded.context
- Validation context.Copyright © 2011–2020 FoxLabs. All rights reserved.