V
- The type of value to be validatedpublic abstract class ConstraintWrapper<V> extends Object implements Constraint<V>
Constraint
that can be subclassed to wrap another constraint.Modifier and Type | Field and Description |
---|---|
protected Constraint<V> |
constraint
Wrapped constraint.
|
Constructor and Description |
---|
ConstraintWrapper(Constraint<V> constraint)
Constructs a new
ConstraintWrapper with the specified
constraint. |
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
The default behavior of this method is to return
Constraint.appendMessageArguments(ValidationContext, Map) on the
wrapped constraint. |
Constraint<V> |
getConstraint()
Returns wrapped constraint.
|
String |
getMessageTemplate(ValidationContext<?> context)
The default behavior of this method is to return
Constraint.getMessageTemplate(ValidationContext) on the wrapped
constraint. |
Class<?> |
getType()
The default behavior of this method is to return
Constraint.getType() on the wrapped constraint. |
<T> V |
validate(V value,
ValidationContext<T> context)
The default behavior of this method is to return
Constraint.validate(Object, ValidationContext) on the wrapped
constraint. |
protected final Constraint<V> constraint
public ConstraintWrapper(Constraint<V> constraint)
ConstraintWrapper
with the specified
constraint.constraint
- Constraint to be wrapped.IllegalArgumentException
- if the specified constraint is
null
.public final Constraint<V> getConstraint()
public Class<?> getType()
Constraint.getType()
on the wrapped constraint.getType
in interface Constraint<V>
getType
in interface Validation<V>
Constraint.getType()
public String getMessageTemplate(ValidationContext<?> context)
Constraint.getMessageTemplate(ValidationContext)
on the wrapped
constraint.getMessageTemplate
in interface Constraint<V>
getMessageTemplate
in interface Validation<V>
context
- Validation context.Constraint.getMessageTemplate(ValidationContext)
public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
Constraint.appendMessageArguments(ValidationContext, Map)
on the
wrapped constraint.appendMessageArguments
in interface Constraint<V>
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.Constraint.appendMessageArguments(ValidationContext, Map)
public <T> V validate(V value, ValidationContext<T> context)
Constraint.validate(Object, ValidationContext)
on the wrapped
constraint.validate
in interface Constraint<V>
T
- The type of validated entity.value
- Value to be validated.context
- Validation context.Constraint.validate(Object, ValidationContext)
Copyright © 2011–2020 FoxLabs. All rights reserved.