Class Validator<T>

    • Constructor Detail

      • Validator

        public Validator()
    • Method Detail

      • validate

        public final T validate​(T argument)
        Validates an argument.
        Parameters:
        argument - argument to validate
        Returns:
        the argument, if validation passes
        Throws:
        IllegalArgumentException - if validation fails
      • invalidMessage

        public String invalidMessage​(T argument)
        Formulates an exception message for invalid values.
        Parameters:
        argument - argument that failed validation
        Returns:
        exception message
      • and

        public final Validator<T> and​(Validator<T> other)
        Creates a new validator that is the conjunction of this one and the given one. An argument passed to the returned validator is valid only if it passes both validators.
        Parameters:
        other - other validator
        Returns:
        combined validator
      • or

        public final Validator<T> or​(Validator<T> other)
        Creates a new validator that is the disjunction of this one and the given one. An argument passed to the returned validator is valid only if it passes at least one of the validators.
        Parameters:
        other - other validator
        Returns:
        combined validator
      • not

        public final Validator<T> not()
        Creates a new validator that is the negation of this one. An argument passed to the returned validator is valid only if it fails this one.
        Returns:
        negated validator