001package Torello.Java.Function;
002
003/**
004 * Function-Pointer
005 * <SPAN CLASS=TJF>Input:</SPAN> {@code int, short}
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=short>
011 */
012@FunctionalInterface
013public interface IntShortPredicate
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 s The short (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, short s);
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 IntShortPredicate and(IntShortPredicate other)
032    {
033        if (other == null)
034            throw new NullPointerException("null has been passed to parameter 'other");
035
036        return (int i, short s) -> this.test(i, s) && other.test(i, s);
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 IntShortPredicate negate()
044    { return (int i, short s) -> ! this.test(i, s); }
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 IntShortPredicate or(IntShortPredicate other)
053    {
054        if (other == null)
055            throw new NullPointerException("null has been passed to parameter 'other");
056
057        return (int i, short s) -> this.test(i, s) || other.test(i, s);
058    }
059}