V
- The type of sequence to be validatedE
- The type of elementspublic abstract class SequenceElementConstraint<V,E> extends AbstractValidation<V> implements Constraint<V>
Constraint
that
uses another constraint to validate elements of a sequence.Modifier and Type | Field and Description |
---|---|
protected Constraint<E> |
constraint
Constraint to be used to validate elements of a sequence.
|
Modifier | Constructor and Description |
---|---|
protected |
SequenceElementConstraint(Constraint<E> constraint)
Constructs a new
SequenceElementConstraint with the
specified constraint of elements. |
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends
constraint argument that contains constraint of
sequence elements. |
protected abstract <T> V |
doValidate(V sequence,
ValidationContext<T> context,
List<ConstraintViolationException> violations)
Checks whether all elements of the specified sequence conforms to the
constraint of sequence elements.
|
Constraint<E> |
getConstraint()
Returns constraint to be used to validate elements of a sequence.
|
<T> V |
validate(V sequence,
ValidationContext<T> context)
Checks whether all elements of the specified sequence conforms to the
constraint of sequence elements.
|
getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessageTemplate, getType
protected final Constraint<E> constraint
protected SequenceElementConstraint(Constraint<E> constraint)
SequenceElementConstraint
with the
specified constraint of elements.constraint
- Constraint to be used to validate elements of a
sequence.NullPointerException
- if the specified constraint is
null
.public final Constraint<E> getConstraint()
public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
constraint
argument that contains constraint of
sequence elements.appendMessageArguments
in interface Constraint<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 validate(V sequence, ValidationContext<T> context)
validate
in interface Constraint<V>
T
- The type of validated entity.sequence
- Sequence whose elements to be checked.context
- Validation context.ConstraintViolationException
- if validation of sequence elements
fails.doValidate(Object, ValidationContext, List)
protected abstract <T> V doValidate(V sequence, ValidationContext<T> context, List<ConstraintViolationException> violations)
ConstraintViolationException
and all violations should be
stored in the specified list of violations.T
- The type of validated entity.sequence
- Sequence whose elements to be checked.context
- Validation context.violations
- List of violations.Copyright © 2011–2020 FoxLabs. All rights reserved.