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=TWOPRIMPRED>
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     * @param i The integer (first) argument to the predicate.
018     * @param l The long (second) argument to the predicate.
019     * @return <B>TRUE</B> if the input arguments match this predicate, and <B>FALSE</B> otherwise.
020     */
021    public boolean test(int i, long l);
022
023    /**
024     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDMETH">
025     * @param other A predicate that will be logically-AND'ed with this predicate
026     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDRET">
027     * @throws NullPointerException if parameter {@code 'other'} is null.
028     */
029    default IntLongPredicate and(IntLongPredicate other)
030    {
031        if (other == null)
032            throw new NullPointerException("null has been passed to parameter 'other");
033
034        return (int i, long l) -> this.test(i, l) && other.test(i, l);
035    }
036
037    /**
038     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGMETH">
039     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGRET">
040     */
041    default IntLongPredicate negate()
042    { return (int i, long l) -> ! this.test(i, l); }
043
044    /**
045     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDORMETH">
046     * @param other a predicate that will be logically-ORed with this predicate
047     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDORRET">
048     * @throws NullPointerException if parameter {@code 'other'} is null.
049     */
050    default IntLongPredicate or(IntLongPredicate other)
051    {
052        if (other == null)
053            throw new NullPointerException("null has been passed to parameter 'other");
054
055        return (int i, long l) -> this.test(i, l) || other.test(i, l);
056    }
057}