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