Class NumberRangeValidatorImpl
java.lang.Object
ch.tocco.nice2.validate.api.validators.AbstractValidator
ch.tocco.nice2.validate.api.validators.NumberRangeValidatorImpl
- All Implemented Interfaces:
NumberRangeValidator,Validator,ValueValidator,Cloneable
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.validate.api.validators.Validator
Validator.MergeMode -
Field Summary
Fields inherited from class ch.tocco.nice2.validate.api.validators.AbstractValidator
doContinue, level, name, negate, runOn -
Constructor Summary
ConstructorsConstructorDescriptionNumberRangeValidatorImpl(@Nullable Double fromIncluding, @Nullable Double toIncluding) -
Method Summary
Modifier and TypeMethodDescriptionprotected FieldValidationResultvoidcalculateAndSetLowerBound(BiPredicate<Double, Double> comparator, @Nullable Number bound, boolean newIsInclusive) voidcalculateAndSetUpperBound(BiPredicate<Double, Double> comparator, @Nullable Number bound, boolean newIsInclusive) booleanTells if the constraint data of this validator can be merged with another instance.clone()Returns the number range's min value, or null if none specified.Class<? extends ValueValidator> getType()Returns the number range's max value, or null if none specified.protected booleanIf subclass overwrites and returns true then the validate() method won't do it anymore.booleanbooleanbooleanmergeConstraints(Validator validator, Validator.MergeMode mode) Default implementation so that subclasses are only forced to override canMergeConstraints().voidsetup(@Nullable Double lowerBound, boolean includeLowerBound, @Nullable Double upperBound, boolean includeUpperBound) Methods inherited from class ch.tocco.nice2.validate.api.validators.AbstractValidator
doContinueOnFailure, doNegate, getErrorStatusByLevel, getLevel, getName, getRunOn, hasName, isEmptySoIgnore, negateResultIfNeeded, setContinue, setLevel, setName, setNegate, setRunOn, validate
-
Constructor Details
-
NumberRangeValidatorImpl
public NumberRangeValidatorImpl() -
NumberRangeValidatorImpl
-
-
Method Details
-
setup
public void setup(@Nullable @Nullable Double lowerBound, boolean includeLowerBound, @Nullable @Nullable Double upperBound, boolean includeUpperBound) - Specified by:
setupin interfaceNumberRangeValidator
-
getLowerBound
Description copied from interface:NumberRangeValidatorReturns the number range's min value, or null if none specified.- Specified by:
getLowerBoundin interfaceNumberRangeValidator
-
isIncludeLowerBound
public boolean isIncludeLowerBound() -
getUpperBound
Description copied from interface:NumberRangeValidatorReturns the number range's max value, or null if none specified.- Specified by:
getUpperBoundin interfaceNumberRangeValidator
-
isIncludeUpperBound
public boolean isIncludeUpperBound() -
_validate
protected FieldValidationResult _validate(Object value, Map<String, Object> fields) throws IllegalArgumentException- Specified by:
_validatein classAbstractValidator- Throws:
IllegalArgumentException
-
iNegateMyself
protected boolean iNegateMyself()Description copied from class:AbstractValidatorIf subclass overwrites and returns true then the validate() method won't do it anymore. That's preferred for implementing validators (not groups).- Overrides:
iNegateMyselfin classAbstractValidator- See Also:
-
canMergeConstraints
public boolean canMergeConstraints()Description copied from interface:ValidatorTells if the constraint data of this validator can be merged with another instance.This is validator-type specific. For example a date range validator can, a regex validator obviously cannot.
- Specified by:
canMergeConstraintsin interfaceValidator- See Also:
-
mergeConstraints
Description copied from class:AbstractValidatorDefault implementation so that subclasses are only forced to override canMergeConstraints().- Specified by:
mergeConstraintsin interfaceValidator- Overrides:
mergeConstraintsin classAbstractValidator- Parameters:
validator- The validator to merge in.mode- How to merge.- Returns:
trueif it was done. This should only fail if canMergeConstraints() says false.- See Also:
-
calculateAndSetLowerBound
public void calculateAndSetLowerBound(BiPredicate<Double, Double> comparator, @Nullable @Nullable Number bound, boolean newIsInclusive) -
calculateAndSetUpperBound
public void calculateAndSetUpperBound(BiPredicate<Double, Double> comparator, @Nullable @Nullable Number bound, boolean newIsInclusive) -
getType
-
clone
- Specified by:
clonein interfaceValidator- Overrides:
clonein classAbstractValidator- Throws:
CloneNotSupportedException
-