T
- Input type for predicate and function (action)R
- Return type for function (action) which is executed if the predicate tests positiveX
- Type of Function - cyclops pattern matching builders use ActionWithReturn which is serialisable and retains type infopublic interface Case<T,R>
Modifier and Type | Method and Description |
---|---|
static <T,R,X extends java.util.function.Function<T,R>> |
empty() |
org.jooq.lambda.tuple.Tuple2<java.util.function.Predicate<? super T>,java.util.function.Function<? super T,? extends R>> |
get() |
default java.util.function.Function<? super T,? extends R> |
getAction() |
default java.util.function.Predicate<? super T> |
getPredicate() |
boolean |
isEmpty() |
default boolean |
isNotEmpty() |
default java.util.Optional<R> |
match(T value)
Match against the supplied value.
|
default java.util.concurrent.CompletableFuture<java.util.Optional<R>> |
matchAsync(java.util.concurrent.Executor executor,
T value)
Similar to Match, but executed asynchonously on supplied Executor.
|
static <T,R> Case<T,R> |
of(java.util.function.Predicate<? super T> predicate,
java.util.function.Function<? super T,? extends R> action)
Construct an instance of Case from supplied predicate and action
|
static <T,R> Case<T,R> |
of(org.jooq.lambda.tuple.Tuple2<java.util.function.Predicate<? super T>,java.util.function.Function<? super T,? extends R>> pattern)
Construct an instance of Case from supplied Tuple of predicate and action
|
static final Case empty
boolean isEmpty()
org.jooq.lambda.tuple.Tuple2<java.util.function.Predicate<? super T>,java.util.function.Function<? super T,? extends R>> get()
default java.util.function.Predicate<? super T> getPredicate()
default java.util.function.Function<? super T,? extends R> getAction()
default boolean isNotEmpty()
default java.util.Optional<R> match(T value)
value
- To match againstdefault java.util.concurrent.CompletableFuture<java.util.Optional<R>> matchAsync(java.util.concurrent.Executor executor, T value)
executor
- Executor to execute matching onvalue
- Value to match againstMatch against the supplied value.
Value will be passed into the current predicate
If it passes / holds, value will be passed to the current function.
The result of function application will be returned wrapped in an Optional.
If the predicate does not hold, Optional.empty() is returned.
static <T,R> Case<T,R> of(java.util.function.Predicate<? super T> predicate, java.util.function.Function<? super T,? extends R> action)
predicate
- That will be used to matchaction
- Function that is executed on succesful matchstatic <T,R> Case<T,R> of(org.jooq.lambda.tuple.Tuple2<java.util.function.Predicate<? super T>,java.util.function.Function<? super T,? extends R>> pattern)
pattern
- containing the predicate that will be used to match and the function that is executed on succesful matchstatic <T,R,X extends java.util.function.Function<T,R>> Case<T,R> empty()