V
- The type of operandspublic abstract class PropertyComparisonConstraint<V> extends CheckConstraint<V>
CheckConstraint
that applies binary comparison operator to a value and other property.Modifier and Type | Class and Description |
---|---|
static class |
PropertyComparisonConstraint.EqualToOp<V>
This class provides
PropertyComparisonConstraint
implementation that applies == operator to a value and
other property. |
static class |
PropertyComparisonConstraint.GreaterThanEqualOp<V>
This class provides
PropertyComparisonConstraint
implementation that applies >= operator to a value and
other property. |
static class |
PropertyComparisonConstraint.GreaterThanOp<V>
This class provides
PropertyComparisonConstraint
implementation that applies > operator to a value and
other property. |
static class |
PropertyComparisonConstraint.LessThanEqualOp<V>
This class provides
PropertyComparisonConstraint
implementation that applies <= operator to a value and
other property. |
static class |
PropertyComparisonConstraint.LessThanOp<V>
This class provides
PropertyComparisonConstraint
implementation that applies < operator to a value and
other property. |
static class |
PropertyComparisonConstraint.NotEqualToOp<V>
This class provides
PropertyComparisonConstraint
implementation that applies != operator to a value and
other property. |
Modifier and Type | Field and Description |
---|---|
protected Comparator<V> |
comparator
Comparator to be used for operands comparison.
|
protected String |
propertyName
Property name of the second operand.
|
protected Class<?> |
type
Type of the operands.
|
Modifier | Constructor and Description |
---|---|
protected |
PropertyComparisonConstraint(Class<?> type,
String propertyName,
Comparator<V> comparator)
Constructs a new
PropertyComparisonConstraint with the
specified type of the operands, property name and comparator. |
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends
property argument that contains property name of
the second operand. |
protected <T> boolean |
check(V value1,
ValidationContext<T> context)
Applies binary comparison operator to the specified value and other
property.
|
protected abstract boolean |
compare(V value1,
V value2)
Applies binary comparison operator between two values.
|
Comparator<V> |
getComparator()
Returns comparator to be used for operands comparison.
|
String |
getMessageTemplate(ValidationContext<?> context)
Returns localized error message template.
|
String |
getPropertyName()
Returns property name of the second operand.
|
Class<?> |
getType()
Returns type of the operands.
|
validate
protected final Class<?> type
protected final String propertyName
protected final Comparator<V> comparator
protected PropertyComparisonConstraint(Class<?> type, String propertyName, Comparator<V> comparator)
PropertyComparisonConstraint
with the
specified type of the operands, property name and comparator.type
- Type of the operands.propertyName
- Property name of the second operand.comparator
- Comparator to be used for operands comparison.NullPointerException
- if the specified type or propertyName or
comparator is null
.public final String getPropertyName()
public final Comparator<V> getComparator()
public final Class<?> getType()
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)
property
argument that contains property name of
the second operand.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 value1, ValidationContext<T> context)
check
in class CheckConstraint<V>
T
- The type of validated entity.value1
- First operand.context
- Validation context.true
if comparison was performed successfully;
false
otherwise.Copyright © 2011–2020 FoxLabs. All rights reserved.