Package io.github.mmm.validation.main
Class ValidatorCompare<V extends Comparable<V>>
- java.lang.Object
-
- io.github.mmm.validation.AbstractValidator<V>
-
- io.github.mmm.validation.AbstractValueValidator<V>
-
- io.github.mmm.validation.main.ValidatorCompare<V>
-
- Type Parameters:
V
- is the generic type of the value tovalidate
.
- All Implemented Interfaces:
Composable<Validator<?>>
,Validator<V>
,Iterable<Validator<?>>
public class ValidatorCompare<V extends Comparable<V>> extends AbstractValueValidator<V>
Validator
validating
that a valuesatisfies
a givenCompareOperator
-operation for given value to compare to.- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from interface io.github.mmm.validation.Validator
ID_MANDATORY
-
-
Constructor Summary
Constructors Constructor Description ValidatorCompare(CompareOperator comparator, Supplier<V> valueSource)
The constructor.ValidatorCompare(CompareOperator comparator, V value)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
int
hashCode()
boolean
isDynamic()
This method determines if thisValidator
is dynamic.protected NlsMessage
validateNotNull(V value)
This method performs the validation in casevalue
is NOTnull
.-
Methods inherited from class io.github.mmm.validation.AbstractValueValidator
validate, validateNull
-
Methods inherited from class io.github.mmm.validation.AbstractValidator
getId, source2string, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.base.lang.Composable
getChild, getChildCount, iterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface io.github.mmm.validation.Validator
append, append, containsId, getMax, getMin, isMandatory, validate
-
-
-
-
Constructor Detail
-
ValidatorCompare
public ValidatorCompare(CompareOperator comparator, Supplier<V> valueSource)
The constructor.- Parameters:
comparator
- is thecomparison operator
used to compare thevalue to validate
(first argument) with the value of the givenvalueSource
.valueSource
- is a reference to something thatprovides a value
and will be evaluateddynamically
on everyvalidation
.
-
ValidatorCompare
public ValidatorCompare(CompareOperator comparator, V value)
The constructor.- Parameters:
comparator
- is thecomparison operator
used to compare thevalue to validate
(first argument) with the value of the givenvalue
.value
- is the fixed value to compare to.
-
-
Method Detail
-
isDynamic
public boolean isDynamic()
Description copied from class:AbstractValidator
This method determines if thisValidator
is dynamic. Here dynamic means that the validation of the same input may not always return the same validation result (e.g. it holds references to instances that have dynamic impact on the validation).- Overrides:
isDynamic
in classAbstractValidator<V extends Comparable<V>>
- Returns:
true
if thisValidator
is dynamic,false
otherwise.
-
validateNotNull
protected NlsMessage validateNotNull(V value)
Description copied from class:AbstractValueValidator
This method performs the validation in casevalue
is NOTnull
. This method contains the actual custom logic for the validation. It is therefore designed in a way that makes it most simple to implement custom validators.- Specified by:
validateNotNull
in classAbstractValueValidator<V extends Comparable<V>>
- Parameters:
value
- the value to validate.- Returns:
- the
failure message
ornull
if the the givenvalue
is valid.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractValidator<V extends Comparable<V>>
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classAbstractValidator<V extends Comparable<V>>
-
-