1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package Torello.Java.Function;

/**
 * <CODE>FloatPredicate Documentation.</CODE><BR /><BR />
 * This is similar to Java's {@code IntPredicate}, except it explicity requires a {@code float}
 * type in it's lambda {@code 'test'} method.
 */
@FunctionalInterface
public interface FloatPredicate
{
    /**
     * Evaluates this predicate on the given argument.
     * @param f primitive-{@code float} input argument.
     * @return <B>TRUE</B> if the input argument matches this predicate, and <B>FALSE</B> otherwise.
     */
    public boolean test(float f);

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDMETH">
     * @param other A predicate that will be logically-AND'ed with this predicate
     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDANDRET">
     * @throws NullPointerException if parameter {@code 'other'} is null.
     */
    default FloatPredicate and(FloatPredicate other)
    {
        if (other == null)
            throw new NullPointerException("null has been passed to parameter 'other'");

        return (float f) -> this.test(f) && other.test(f);
    }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGMETH">
     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDNEGRET">
     */
    default FloatPredicate negate()
    { return (float f) -> ! this.test(f); }

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="PREDORMETH">
     * @param other a predicate that will be logically-ORed with this predicate
     * @return <EMBED CLASS="external-html" DATA-FILE-ID="PREDORRET">
     * @throws NullPointerException if parameter {@code 'other'} is null.
     */
    default FloatPredicate or(FloatPredicate other)
    {
        if (other == null)
            throw new NullPointerException("null has been passed to parameter 'other'");

        return (float f) -> this.test(f) || other.test(f);
    }
}