Class AbstractGroupValidator
- All Implemented Interfaces:
GroupValidator
,Validator
,Cloneable
,Iterable<Validator>
- Direct Known Subclasses:
AndGroupValidatorImpl
-
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addValidator
(Validator validator) Adds a validator to the group.void
addValidator
(Validator validator, boolean respectLevelOrder) Adds a validator to the group in the right position.boolean
Tells if the constraint data of this validator can be merged with another instance.clone()
@Nullable Validator
Finds a child validator, either a direct child or somewhere down the hierarchy, with the given name path.getType()
Returns a list with the validators in this group.boolean
protected boolean
isEmptySoIgnore
(Object value) Subclasses may override this to define what is considered empty, and thus disables the validator.iterator()
boolean
mergeInValidatorByType
(Validator validator, Validator.MergeMode mode) Tells an existing validator of that type (with same level and no conditions) to merge in the attributes of the given one, or adds the passed validator if no such is here yet.void
removeValidator
(Validator validator) Remove a validator to the group.Methods inherited from class ch.tocco.nice2.validate.api.validators.AbstractValidator
_validate, doContinueOnFailure, doNegate, getErrorStatusByLevel, getLevel, getName, getRunOn, hasName, iNegateMyself, mergeConstraints, negateResultIfNeeded, setContinue, setLevel, setName, setNegate, setRunOn, validate
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface ch.tocco.nice2.validate.api.validators.Validator
doContinueOnFailure, doNegate, getLevel, getName, getRunOn, hasName, mergeConstraints, setContinue, setLevel, setName, setNegate, setRunOn, validate
-
Field Details
-
validators
Validators and Groups.Mostly in the order that ERROR level validators come before WARN come before INFO. It seems easier atm to work with just one simple list.
-
-
Constructor Details
-
AbstractGroupValidator
public AbstractGroupValidator()
-
-
Method Details
-
addValidator
Description copied from interface:GroupValidator
Adds a validator to the group.- Specified by:
addValidator
in interfaceGroupValidator
- Parameters:
validator
- validator, non-null
-
removeValidator
Description copied from interface:GroupValidator
Remove a validator to the group.- Specified by:
removeValidator
in interfaceGroupValidator
- Parameters:
validator
- validator, non-null
-
addValidator
Description copied from interface:GroupValidator
Adds a validator to the group in the right position.Validators of error level ERROR need to come before WARN need to come before INFO. The xml model reader makes sure the validators are given in the right order. But once manual customization, as well as merging comes in, this is required.
- Specified by:
addValidator
in interfaceGroupValidator
-
mergeInValidatorByType
Description copied from interface:GroupValidator
Tells an existing validator of that type (with same level and no conditions) to merge in the attributes of the given one, or adds the passed validator if no such is here yet.- Specified by:
mergeInValidatorByType
in interfaceGroupValidator
- Parameters:
validator
- The validator to merge in.mode
- .- Returns:
- true if it was merged, false if it was added
-
hasValidators
public boolean hasValidators()- Specified by:
hasValidators
in interfaceGroupValidator
- Returns:
- Tells if this group has any validators.
-
getValidators
Description copied from interface:GroupValidator
Returns a list with the validators in this group.- Specified by:
getValidators
in interfaceGroupValidator
- Returns:
- list may be empty
-
findChild
Description copied from interface:GroupValidator
Finds a child validator, either a direct child or somewhere down the hierarchy, with the given name path.If you are looking for a direct child then specify the name, eg "myLengthValidator".
If you're looking for one down in a group then use the path, eg "myAndGroup.myLengthConditionalGroup.myLengthValidator".- Specified by:
findChild
in interfaceGroupValidator
-
canMergeConstraints
public boolean canMergeConstraints()Description copied from interface:Validator
Tells 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:
canMergeConstraints
in interfaceValidator
- See Also:
-
getType
-
iterator
-
clone
- Specified by:
clone
in interfaceValidator
- Overrides:
clone
in classAbstractValidator
- Throws:
CloneNotSupportedException
-
isEmptySoIgnore
Description copied from class:AbstractValidator
Subclasses may override this to define what is considered empty, and thus disables the validator.An example is the string field: an empty input string means "no value given".
Imagine a zipcode field that may be empty (if unknown). A length validator (let's say 4 to 10 characters) must be ignored if no input (empty string) was given.
- Overrides:
isEmptySoIgnore
in classAbstractValidator
- Parameters:
value
- The object value as given to validate.- Returns:
- True to disable the validator, false to go on.
-