public abstract class SequenceConverter<V> extends AbstractValidation<V> implements Converter<V>
Converter
implementation for
converters of elements sequence.Tokenizer
Modifier and Type | Field and Description |
---|---|
protected Tokenizer |
tokenizer
Tokenizer of elements sequence.
|
Modifier | Constructor and Description |
---|---|
protected |
SequenceConverter(Tokenizer tokenizer)
Constructs a new
SequenceConverter with the specified
tokenizer of elements sequence. |
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends
tokenizer argument that contains tokenizer of
elements sequence. |
<T> V |
decode(String value,
ValidationContext<T> context)
Converts string representation of elements sequence into object.
|
protected abstract <T> V |
doDecode(String[] tokens,
ValidationContext<T> context,
List<MalformedValueException> violations)
Converts string representations of elements into elements sequence.
|
protected <T> String[] |
tokenize(String value,
ValidationContext<T> context)
Returns array of tokens extracted from the source string.
|
getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
encode, getMessageTemplate, getType
protected final Tokenizer tokenizer
protected SequenceConverter(Tokenizer tokenizer)
SequenceConverter
with the specified
tokenizer of elements sequence.tokenizer
- Tokenizer of elements sequence.IllegalArgumentException
- if the specified tokenizer is
null
.public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
tokenizer
argument that contains tokenizer of
elements sequence.appendMessageArguments
in interface Converter<V>
appendMessageArguments
in interface Validation<V>
appendMessageArguments
in class AbstractValidation<V>
context
- Validation context.arguments
- Arguments to be substituted into the error message
template.true
.public <T> V decode(String value, ValidationContext<T> context)
decode
in interface Converter<V>
T
- The type of validated entity.value
- String representation of elements sequence.context
- Validation context.MalformedValueException
- if conversion fails.protected <T> String[] tokenize(String value, ValidationContext<T> context)
T
- The type of validated entity.value
- Source string to be tokenized.context
- Validation context.MalformedValueException
- if conversion fails.Tokenizer.decode(String, ValidationContext)
protected abstract <T> V doDecode(String[] tokens, ValidationContext<T> context, List<MalformedValueException> violations)
MalformedValueException
and
all violations should be stored in the specified list of violations.T
- The type of validated entity.tokens
- String representations of elements.context
- Validation context.violations
- List of violations.Copyright © 2011–2020 FoxLabs. All rights reserved.