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