public abstract static class Lang.Predicate<T> extends Lang.F1<T,Boolean>
Predicate is a predefined Function<Boolean, T> typed function with a set of utilities dealing with boolean operations. This is often known as Predicate
Note in user application, it should NOT assume an argument is of Predicate typed function, instead the argument should always be declared as Function<Boolean T>:
// bad way void foo(Predicate<MyData> predicate) { … } // good way void foo(Function<Boolean, MyData> predicate) { Predicate<MyData> p = predicate(predicate); … } | Constructor and Description |
|---|
Predicate() |
| Modifier and Type | Method and Description |
|---|---|
Lang.Predicate<T> |
and(Lang.Function<? super T,Boolean>... predicates)
Return an
Predicate predicate from a list of Function<Boolean, T> with AND operation. |
Boolean |
apply(T t)
Apply this function to <T> type parameter.
|
<R> Lang.F1<T,Lang.Option<R>> |
elseThen(Lang.Function<? super T,R> func) |
<R> Lang.F1<T,Lang.Option<R>> |
ifThen(Lang.Function<? super T,R> func) |
Lang.Predicate<T> |
negate()
Returns a negate function of this
|
static <T> Lang.Predicate<T> |
negate(Lang.Function<T,Boolean> predicate) |
Lang.Predicate<T> |
or(Lang.Function<? super T,Boolean>... predicates)
Return an
Predicate predicate from a list of Function<Boolean, T> with OR operation. |
abstract boolean |
test(T t)
Sub class to implement this method to test on the supplied elements
|
andThen, andThen, applyOrElse, compose, compose, compose, compose, compose, compose, curry, invert, lift, orElse, timesbreakOutpublic final Boolean apply(T t)
Lang.FunctionApply this function to <T> type parameter.
In case implementing a partial function, it can throw out an NotAppliedException if the function is not defined for the given parameter(s)
t - the argumentU type resultpublic abstract boolean test(T t)
Sub class to implement this method to test on the supplied elements
t - the element to be testtrue or false depends on the implementationpublic Lang.Predicate<T> negate()
Returns a negate function of this
public Lang.Predicate<T> and(Lang.Function<? super T,Boolean>... predicates)
Return an Predicate predicate from a list of Function<Boolean, T> with AND operation. For any T t to be tested, if any specified predicates must returns false on it, the resulting predicate will return false.
predicates - the predicate function arraytrue only when all functions in predicates returns true on a given argumentpublic Lang.Predicate<T> or(Lang.Function<? super T,Boolean>... predicates)
Return an Predicate predicate from a list of Function<Boolean, T> with OR operation. For any T t to be tested, if any specified predicates must returns true on it, the resulting predicate will return true.
predicates - the predicate functionstrue if any one of the predicate functions returns true on a given argumentpublic <R> Lang.F1<T,Lang.Option<R>> ifThen(Lang.Function<? super T,R> func)
public <R> Lang.F1<T,Lang.Option<R>> elseThen(Lang.Function<? super T,R> func)
public static <T> Lang.Predicate<T> negate(Lang.Function<T,Boolean> predicate)
Copyright © 2014–2021 OSGL (Open Source General Library). All rights reserved.