V
- The type of value to be validatedpublic final class RangeConstraint<V> extends CheckConstraint<V>
CheckConstraint
implementation that checks
whether a value is within allowed minimum and maximum range.Range
,
Min
,
Max
,
ConstraintFactory.range(Comparable, Comparable)
,
ConstraintFactory.range(Object, Object, Comparator)
,
ConstraintFactory.min(Comparable)
,
ConstraintFactory.min(Object, Comparator)
,
ConstraintFactory.max(Comparable)
,
ConstraintFactory.max(Object, Comparator)
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends
min and max arguments that contain
minimum and maximum value respectively. |
protected <T> boolean |
check(V value,
ValidationContext<T> context)
Checks whether the specified value is within allowed minimum and maximum
range.
|
Comparator<V> |
getComparator()
Returns comparator to be used for range checking.
|
V |
getMax()
Returns maximum value or
null if there is no maximum. |
String |
getMessageTemplate(ValidationContext<?> context)
Returns localized error message template.
|
V |
getMin()
Returns minimum value or
null if there is no minimum. |
Class<?> |
getType()
Returns the type of value to be validated.
|
validate
public Class<?> getType()
public V getMin()
null
if there is no minimum.null
if there is no minimum.public V getMax()
null
if there is no maximum.null
if there is no maximum.public Comparator<V> getComparator()
public String getMessageTemplate(ValidationContext<?> context)
getMessageTemplate
in interface Constraint<V>
getMessageTemplate
in interface Validation<V>
getMessageTemplate
in class AbstractValidation<V>
context
- Validation context.public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
min
and max
arguments that contain
minimum and maximum value respectively.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
.protected <T> boolean check(V value, ValidationContext<T> context)
check
in class CheckConstraint<V>
T
- The type of validated entity.value
- Value to be checked.context
- Validation context.true
if the specified value is within allowed
minimum and maximum range; false
otherwise.Copyright © 2011–2020 FoxLabs. All rights reserved.