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=TWOPRIMPRED>
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     * @param i The integer (first) argument to the predicate.
018     * @param s The short (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, short s);
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 IntShortPredicate and(IntShortPredicate other)
030    {
031        if (other == null)
032            throw new NullPointerException("null has been passed to parameter 'other");
033
034        return (int i, short s) -> this.test(i, s) && other.test(i, s);
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 IntShortPredicate negate()
042    { return (int i, short s) -> ! this.test(i, s); }
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 IntShortPredicate or(IntShortPredicate other)
051    {
052        if (other == null)
053            throw new NullPointerException("null has been passed to parameter 'other");
054
055        return (int i, short s) -> this.test(i, s) || other.test(i, s);
056    }
057}