001package Torello.Java.Function;
002
003/**
004 * Function-Pointer
005 * <SPAN CLASS=TJF>Input:</SPAN> {@code A, B, C}
006 * <SPAN CLASS=TJF>Output:</SPAN> {@code boolean}.
007 * 
008 * <BR /><BR />
009 * <EMBED CLASS="external-html" DATA-FILE-ID=BIGPRED>
010 * <EMBED CLASS="globalDefs" DATA-Name='Tri Predicate' DATA-Number=three>
011 * @param <A> The type of the first input-parameter.
012 * @param <B> The type of the second input-parameter.
013 * @param <C> The type of the last input-parameter.
014 */
015@FunctionalInterface
016public interface TriPredicate<A, B, C>
017{
018    /**
019     * Evaluates {@code "this"} predicate on the given arguments.
020     * @param a the first input argument
021     * @param b the second input argument
022     * @param c the third input argument
023     * @return <B>TRUE</B> if the input arguments match the predicate, otherwise <B>FALSE</B>
024     */
025    public boolean test(A a, B b, C c);
026
027    /**
028     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDMETH">
029     * @param other A predicate that will be logically-AND'ed with this predicate
030     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDRET">
031     * @throws NullPointerException if parameter {@code 'other'} is null.
032     */
033    default TriPredicate<A, B, C> and(TriPredicate<? super A, ? super B, ? super C> other)
034    { 
035        if (other == null)
036            throw new NullPointerException("null has been passed to parameter 'other");
037
038        return (A a, B b, C c) -> this.test(a, b, c) && other.test(a, b, c);
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 TriPredicate<A, B, C> negate()
046    { return (A a, B b, C c) -> ! this.test(a, b, c); }
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 TriPredicate<A, B, C> or(TriPredicate<? super A, ? super B, ? super C> other)
055    {
056        if (other == null)
057            throw new NullPointerException("null has been passed to parameter 'other");
058
059        return (A a, B b, C c) -> this.test(a, b, c) || other.test(a, b, c);
060    }
061}