001package Torello.Java.Function;
002
003/**
004 * Function-Pointer
005 * <SPAN CLASS=TJF>Input:</SPAN> {@code int, float}
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=float>
011 */
012@FunctionalInterface
013public interface IntFloatPredicate
014{
015    /**
016     * Evaluates this predicate on the given arguments.
017     * @param i The integer (first) argument to the predicate.
018     * @param f The float (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, float f);
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 IntFloatPredicate and(IntFloatPredicate other)
030    {
031        if (other == null)
032            throw new NullPointerException("null has been passed to parameter 'other");
033
034        return (int i, float f) -> this.test(i, f) && other.test(i, f);
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 IntFloatPredicate negate()
042    { return (int i, float f) -> ! this.test(i, f); }
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 IntFloatPredicate or(IntFloatPredicate other)
051    {
052        if (other == null)
053            throw new NullPointerException("null has been passed to parameter 'other");
054
055        return (int i, float f) -> this.test(i, f) || other.test(i, f);
056    }
057
058}