001package Torello.Java.Function;
002
003/**
004 * Function-Pointer
005 * <SPAN CLASS=TJF>Input:</SPAN> {@code A, B, C, D, E}
006 * <SPAN CLASS=TJF>Output:</SPAN> {@code boolean}.
007 * 
008 * <BR /><BR />
009 * <EMBED CLASS='external-html' DATA-FILE-ID=BIG_PREDICATE>
010 * <EMBED CLASS="globalDefs" DATA-Name='Quint Predicate' DATA-Number=five>
011 * 
012 * @param <A> The type of the first input-parameter.
013 * @param <B> The type of the second input-parameter.
014 * @param <C> The type of the third input-parameter.
015 * @param <D> The type of the fourth input-parameter.
016 * @param <E> The type of the last input-parameter.
017 */
018@FunctionalInterface
019public interface QuintPredicate<A, B, C, D, E>
020{
021    /**
022     * Evaluates {@code "this"} predicate on the given arguments.
023     * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=FUNC_INTER_METH>
024     *
025     * @param a the first input argument
026     * @param b the second input argument
027     * @param c the third input argument
028     * @param d the fourth input argument
029     * @param e the fifth input argument
030     * @return {@code TRUE} if the input arguments match the predicate, otherwise <B>FALSE</B>
031     */
032    public boolean test(A a, B b, C c, D d, E e);
033
034    /**
035     * <EMBED CLASS='external-html' DATA-FILE-ID=PRED_AND_METHOD>
036     * @param other A predicate that will be logically-AND'ed with this predicate
037     * @return <EMBED CLASS='external-html' DATA-FILE-ID=PRED_AND_RETURN>
038     * @throws NullPointerException if parameter {@code 'other'} is null.
039     */
040    default QuintPredicate<A, B, C, D, E> and
041        (QuintPredicate<? super A, ? super B, ? super C, ? super D, ? super E> other)
042    {
043        if (other == null)
044            throw new NullPointerException("null has been passed to parameter 'other");
045
046        return (A a, B b, C c, D d, E e) -> 
047            this.test(a, b, c, d, e) && other.test(a, b, c, d, e);
048    }
049
050    /**
051     * <EMBED CLASS='external-html' DATA-FILE-ID=PRED_NEGATE_METHOD>
052     * @return <EMBED CLASS='external-html' DATA-FILE-ID=PRED_NEGATE_RETURN>
053     */
054    default QuintPredicate<A, B, C, D, E> negate()
055    { return (A a, B b, C c, D d, E e) -> ! this.test(a, b, c, d, e); }
056
057    /**
058     * <EMBED CLASS='external-html' DATA-FILE-ID=PRED_OR_METHOD>
059     * @param other a predicate that will be logically-ORed with this predicate
060     * @return <EMBED CLASS='external-html' DATA-FILE-ID=PRED_OR_RETURN>
061     * @throws NullPointerException if parameter {@code 'other'} is null.
062     */
063    default QuintPredicate<A, B, C, D, E> or
064        (QuintPredicate<? super A, ? super B, ? super C, ? super D, ? super E> other)
065    {
066        if (other == null)
067            throw new NullPointerException("null has been passed to parameter 'other");
068
069        return (A a, B b, C c, D d, E e) -> 
070            this.test(a, b, c, d, e) || other.test(a, b, c, d, e);
071    }
072}