1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package Torello.Java.Function;

/**
 * <CODE>QuadPredicate Documentation.</CODE><BR /><BR />
 * <EMBED CLASS="external-html" DATA-FILE-ID=BIGPRED>
 * <EMBED CLASS="globalDefs" DATA-Name='Quad Predicate' DATA-Number=four>
 * @param <A> The type of the first input-parameter.
 * @param <B> The type of the second input-parameter.
 * @param <C> The type of the third input-parameter.
 * @param <D> The type of the last input-parameter.
 */
@FunctionalInterface
public interface QuadPredicate<A, B, C, D>
{
    /**
     * Evaluates {@code "this"} predicate on the given arguments.
     * @param a the first input argument
     * @param b the second input argument
     * @param c the third input argument
     * @param d the fourth input argument
     * @return <B>TRUE</B> if the input arguments match the predicate, otherwise <B>FALSE</B>
     */
    public boolean test(A a, B b, C c, D d);

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDMETH">
     * @param other A predicate that will be logically-AND'ed with this predicate
     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDRET">
     * @throws NullPointerException if parameter {@code 'other'} is null.
     */
    default QuadPredicate<A, B, C, D> and
        (QuadPredicate<? super A, ? super B, ? super C, ? super D> other)
    {
        if (other == null)
            throw new NullPointerException("null has been passed to parameter 'other");

        return (A a, B b, C c, D d) ->
            this.test(a, b, c, d) && other.test(a, b, c, d);
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGMETH">
     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGRET">
     */
    default QuadPredicate<A, B, C, D> negate()
    { return (A a, B b, C c, D d) -> ! this.test(a, b, c, d); }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDORMETH">
     * @param other a predicate that will be logically-ORed with this predicate
     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDORRET">
     * @throws NullPointerException if parameter {@code 'other'} is null.
     */
    default QuadPredicate<A, B, C, D> or
        (QuadPredicate<? super A, ? super B, ? super C, ? super D> other)
    {
        if (other == null)
            throw new NullPointerException("null has been passed to parameter 'other");

        return (A a, B b, C c, D d) ->
            this.test(a, b, c, d) || other.test(a, b, c, d);
    }
}