public abstract static class Osgl.Predicate<T> extends Osgl.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 = Osgl.predicate(predicate);
...
}
| Constructor and Description |
|---|
Predicate() |
| Modifier and Type | Method and Description |
|---|---|
Osgl.Predicate<T> |
and(Osgl.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> Osgl.F1<T,Osgl.Option<R>> |
elseThen(Osgl.Function<? super T,R> func) |
<R> Osgl.F1<T,Osgl.Option<R>> |
ifThen(Osgl.Function<? super T,R> func) |
Osgl.Predicate<T> |
negate()
Returns a negate function of this
|
static <T> Osgl.Predicate<T> |
negate(Osgl.Function<T,Boolean> predicate) |
Osgl.Predicate<T> |
or(Osgl.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)
Osgl.FunctionIn 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)
t - the element to be testtrue or false depends on the implementationpublic Osgl.Predicate<T> negate()
public Osgl.Predicate<T> and(Osgl.Function<? super T,Boolean>... predicates)
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 Osgl.Predicate<T> or(Osgl.Function<? super T,Boolean>... predicates)
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> Osgl.F1<T,Osgl.Option<R>> ifThen(Osgl.Function<? super T,R> func)
public <R> Osgl.F1<T,Osgl.Option<R>> elseThen(Osgl.Function<? super T,R> func)
public static <T> Osgl.Predicate<T> negate(Osgl.Function<T,Boolean> predicate)
Copyright © 2017. All Rights Reserved.