Interface GroupValidator

All Superinterfaces:
Cloneable, Iterable<Validator>, Validator
All Known Subinterfaces:
AndGroupValidator
All Known Implementing Classes:
AbstractGroupValidator, AndGroupValidatorImpl, GroupValidatorView

public interface GroupValidator extends Validator, Iterable<Validator>
Base interface for the Group Validators (validators containing other validators of any kind).
  • Method Details

    • hasValidators

      boolean hasValidators()
      Returns:
      Tells if this group has any validators.
    • getValidators

      List<Validator> getValidators()
      Returns a list with the validators in this group.
      Returns:
      list may be empty
    • findChild

      @Nullable @Nullable Validator findChild(String name)
      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

      void addValidator(Validator validator)
      Adds a validator to the group.
      Parameters:
      validator - validator, non-null
      Throws:
      IllegalStateException - If validator is there already.
    • removeValidator

      void removeValidator(Validator validator)
      Remove a validator to the group.
      Parameters:
      validator - validator, non-null
      Throws:
      IllegalStateException - If validator cannot be found.
    • addValidator

      void addValidator(Validator validator, boolean respectLevelOrder)
      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

      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.
      Parameters:
      validator - The validator to merge in.
      mode - .
      Returns:
      true if it was merged, false if it was added