001package Torello.Java.Function;
002
003/**
004 * <CODE>FloatPredicate Documentation.</CODE><BR /><BR />
005 * This is similar to Java's {@code IntPredicate}, except it explicity requires a {@code float}
006 * type in it's lambda {@code 'test'} method.
007 */
008@FunctionalInterface
009public interface FloatPredicate
010{
011    /**
012     * Evaluates this predicate on the given argument.
013     * @param f primitive-{@code float} input argument.
014     * @return <B>TRUE</B> if the input argument matches this predicate, and <B>FALSE</B> otherwise.
015     */
016    public boolean test(float f);
017
018    /**
019     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDMETH">
020     * @param other A predicate that will be logically-AND'ed with this predicate
021     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDRET">
022     * @throws NullPointerException if parameter {@code 'other'} is null.
023     */
024    default FloatPredicate and(FloatPredicate other)
025    {
026        if (other == null)
027            throw new NullPointerException("null has been passed to parameter 'other'");
028
029        return (float f) -> this.test(f) && other.test(f);
030    }
031
032    /**
033     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGMETH">
034     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGRET">
035     */
036    default FloatPredicate negate()
037    { return (float f) -> ! this.test(f); }
038
039    /**
040     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDORMETH">
041     * @param other a predicate that will be logically-ORed with this predicate
042     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDORRET">
043     * @throws NullPointerException if parameter {@code 'other'} is null.
044     */
045    default FloatPredicate or(FloatPredicate other)
046    {
047        if (other == null)
048            throw new NullPointerException("null has been passed to parameter 'other'");
049
050        return (float f) -> this.test(f) || other.test(f);
051    }
052}