001package Torello.Java.Function;
002
003/**
004 * <CODE>QuadPredicate Documentation.</CODE><BR /><BR />
005 * <EMBED CLASS="external-html" DATA-FILE-ID=BIGPRED>
006 * <EMBED CLASS="globalDefs" DATA-Name='Quad Predicate' DATA-Number=four>
007 * @param <A> The type of the first input-parameter.
008 * @param <B> The type of the second input-parameter.
009 * @param <C> The type of the third input-parameter.
010 * @param <D> The type of the last input-parameter.
011 */
012@FunctionalInterface
013public interface QuadPredicate<A, B, C, D>
014{
015    /**
016     * Evaluates {@code "this"} predicate on the given arguments.
017     * @param a the first input argument
018     * @param b the second input argument
019     * @param c the third input argument
020     * @param d the fourth input argument
021     * @return <B>TRUE</B> if the input arguments match the predicate, otherwise <B>FALSE</B>
022     */
023    public boolean test(A a, B b, C c, D d);
024
025    /**
026     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDMETH">
027     * @param other A predicate that will be logically-AND'ed with this predicate
028     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDRET">
029     * @throws NullPointerException if parameter {@code 'other'} is null.
030     */
031    default QuadPredicate<A, B, C, D> and
032        (QuadPredicate<? super A, ? super B, ? super C, ? super D> other)
033    {
034        if (other == null)
035            throw new NullPointerException("null has been passed to parameter 'other");
036
037        return (A a, B b, C c, D d) ->
038            this.test(a, b, c, d) && other.test(a, b, c, d);
039    }
040
041    /**
042     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGMETH">
043     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGRET">
044     */
045    default QuadPredicate<A, B, C, D> negate()
046    { return (A a, B b, C c, D d) -> ! this.test(a, b, c, d); }
047
048    /**
049     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDORMETH">
050     * @param other a predicate that will be logically-ORed with this predicate
051     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDORRET">
052     * @throws NullPointerException if parameter {@code 'other'} is null.
053     */
054    default QuadPredicate<A, B, C, D> or
055        (QuadPredicate<? super A, ? super B, ? super C, ? super D> other)
056    {
057        if (other == null)
058            throw new NullPointerException("null has been passed to parameter 'other");
059
060        return (A a, B b, C c, D d) ->
061            this.test(a, b, c, d) || other.test(a, b, c, d);
062    }
063}