V
- The type of value to be validatedpublic abstract class ConstraintAggregation<V> extends AbstractValidation<V> implements Constraint<V>
Constraint
that
encapsulates other constraints to validate a value.Modifier and Type | Field and Description |
---|---|
protected Constraint<? super V>[] |
constraints
Array of constraints to be used for validation of a value.
|
protected Class<?> |
type
The type of value to be validated.
|
Modifier | Constructor and Description |
---|---|
protected |
ConstraintAggregation(Class<?> type,
Constraint<? super V>... constraints)
Constructs a new
ConstraintAggregation with the specified
value type and array of other constraints. |
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends
constraints argument that contains encapsulated
constraints. |
Constraint<? super V>[] |
getConstraints()
Returns array of constraints to be used for validation of a value.
|
Class<?> |
getType()
Returns the type of value to be validated.
|
<T> V |
validate(V value,
ValidationContext<T> context)
Checks whether the specified value conforms to all of the encapsulated
constraints.
|
getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessageTemplate
protected final Class<?> type
protected final Constraint<? super V>[] constraints
@SafeVarargs protected ConstraintAggregation(Class<?> type, Constraint<? super V>... constraints)
ConstraintAggregation
with the specified
value type and array of other constraints.type
- The type of value to be validated.constraints
- Array of constraints to be used for validation of a
value.IllegalArgumentException
- if the specified type is
null
or the specified array of constraints is
null
or empty or contains null
elements.public final Class<?> getType()
getType
in interface Constraint<V>
getType
in interface Validation<V>
public final Constraint<? super V>[] getConstraints()
public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
constraints
argument that contains encapsulated
constraints.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 value, ValidationContext<T> context)
validate
in interface Constraint<V>
T
- The type of validated entity.value
- Value to be validated.context
- Validation context.ConstraintViolationException
- if the specified value not
conforms at least one of the encapsulated constraint.Copyright © 2011–2020 FoxLabs. All rights reserved.