001package Torello.Java.Function;
002
003/**
004 * Function-Pointer
005 * <SPAN CLASS=TJF>Input:</SPAN> {@code int, long}
006 * <SPAN CLASS=TJF>Output:</SPAN> {@code boolean}.
007 * 
008 * <BR /><BR />
009 * <EMBED CLASS='external-html' DATA-FILE-ID=TWO_PRIMITIVE_PRED>
010 * <EMBED CLASS="globalDefs" DATA-Type1=int DATA-Type2=long>
011 */
012@FunctionalInterface
013public interface IntLongPredicate
014{
015    /**
016     * Evaluates this predicate on the given arguments.
017     * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=FUNC_INTER_METH>
018     *
019     * @param i The integer (first) argument to the predicate.
020     * @param l The long (second) argument to the predicate.
021     * @return {@code TRUE} if the input arguments match this predicate, and <B>FALSE</B> otherwise.
022     */
023    public boolean test(int i, long l);
024
025    /**
026     * <EMBED CLASS='external-html' DATA-FILE-ID=PRED_AND_METHOD>
027     * @param other A predicate that will be logically-AND'ed with this predicate
028     * @return <EMBED CLASS='external-html' DATA-FILE-ID=PRED_AND_RETURN>
029     * @throws NullPointerException if parameter {@code 'other'} is null.
030     */
031    default IntLongPredicate and(IntLongPredicate other)
032    {
033        if (other == null)
034            throw new NullPointerException("null has been passed to parameter 'other");
035
036        return (int i, long l) -> this.test(i, l) && other.test(i, l);
037    }
038
039    /**
040     * <EMBED CLASS='external-html' DATA-FILE-ID=PRED_NEGATE_METHOD>
041     * @return <EMBED CLASS='external-html' DATA-FILE-ID=PRED_NEGATE_RETURN>
042     */
043    default IntLongPredicate negate()
044    { return (int i, long l) -> ! this.test(i, l); }
045
046    /**
047     * <EMBED CLASS='external-html' DATA-FILE-ID=PRED_OR_METHOD>
048     * @param other a predicate that will be logically-ORed with this predicate
049     * @return <EMBED CLASS='external-html' DATA-FILE-ID=PRED_OR_RETURN>
050     * @throws NullPointerException if parameter {@code 'other'} is null.
051     */
052    default IntLongPredicate or(IntLongPredicate other)
053    {
054        if (other == null)
055            throw new NullPointerException("null has been passed to parameter 'other");
056
057        return (int i, long l) -> this.test(i, l) || other.test(i, l);
058    }
059}