Interface GroupValidator
- All Known Subinterfaces:
AndGroupValidator
- All Known Implementing Classes:
AbstractGroupValidator
,AndGroupValidatorImpl
,GroupValidatorView
Base interface for the Group Validators (validators containing other validators of any kind).
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.validate.api.validators.Validator
Validator.MergeMode
-
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.@Nullable Validator
Finds a child validator, either a direct child or somewhere down the hierarchy, with the given name path.Returns a list with the validators in this group.boolean
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 interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface ch.tocco.nice2.validate.api.validators.Validator
canMergeConstraints, clone, doContinueOnFailure, doNegate, getLevel, getName, getRunOn, getType, hasName, mergeConstraints, setContinue, setLevel, setName, setNegate, setRunOn, validate
-
Method Details
-
hasValidators
boolean hasValidators()- Returns:
- Tells if this group has any validators.
-
getValidators
Returns a list with the validators in this group.- Returns:
- list may be empty
-
findChild
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". -
addValidator
Adds a validator to the group.- Parameters:
validator
- validator, non-null- Throws:
IllegalStateException
- If validator is there already.
-
removeValidator
Remove a validator to the group.- Parameters:
validator
- validator, non-null- Throws:
IllegalStateException
- If validator cannot be found.
-
addValidator
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.
- Throws:
IllegalStateException
- If validator is there already.
-
mergeInValidatorByType
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.- Parameters:
validator
- The validator to merge in.mode
- .- Returns:
- true if it was merged, false if it was added
-