T
- Type of this convertablepublic interface Convertable<T> extends java.lang.Iterable<T>, Fn0<T>, Visitable<T>
Modifier and Type | Interface and Description |
---|---|
static class |
Convertable.SupplierToConvertable<T> |
Fn0.FunctionalOperations<R>, Fn0.Instances, Fn0.SupplierKind<R>
Modifier and Type | Method and Description |
---|---|
default <R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
Collect the contents of the monad wrapped by this AnyM into supplied collector
A mutable reduction operation equivalent to Stream#collect
|
static <T> Convertable<T> |
fromSupplier(java.util.function.Supplier<T> supplier)
Construct a Convertable from a Supplier
|
T |
get()
Apply this function to the arguments.
|
default boolean |
isPresent() |
default java.util.Iterator<T> |
iterator() |
default T |
orElse(T value)
Get the contained value or else the provided alternative
|
default T |
orElseGet(java.util.function.Supplier<? extends T> value)
An equivalent operation to
Optional.orElseGet(Supplier)
Returns a value generated by the provided Supplier if this Convertable is empty or
contains a null value. |
default <X extends java.lang.Throwable> |
orElseThrow(java.util.function.Supplier<? extends X> ex)
Get the contained value or throw an exception if null
|
default java.util.concurrent.CompletableFuture<T> |
toCompletableFuture() |
default java.util.concurrent.CompletableFuture<T> |
toCompletableFutureAsync() |
default java.util.concurrent.CompletableFuture<T> |
toCompletableFutureAsync(java.util.concurrent.Executor exec) |
default Future<T> |
toFuture() |
default Future<T> |
toFutureWAsync() |
default Future<T> |
toFutureWAsync(java.util.concurrent.Executor ex)
This convertable converted to a Future asyncrhonously using the supplied Executor
|
default java.util.Optional<T> |
toOptional() |
default java.util.stream.Stream<T> |
toStream() |
default <R> R |
visit(java.util.function.Function<? super T,? extends R> present,
java.util.function.Supplier<? extends R> absent)
The provided function is executed with the value stored in this Visitable if one is present,
otherwise the provided Supplier is executed instead.
|
default <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
AnyM<Integer> monad1 = AnyM.fromStream(Stream.of(1,2,3));
AnyM<Integer> monad2 = AnyM.fromOptional(Optional.of(1));
List<Integer> list1 = monad1.collect(Collectors.toList());
List<Integer> list2 = monad2.collect(Collectors.toList());
collector
- JDK collector to perform mutable reductiondefault <R> R visit(java.util.function.Function<? super T,? extends R> present, java.util.function.Supplier<? extends R> absent)
Visitable
default boolean isPresent()
static <T> Convertable<T> fromSupplier(java.util.function.Supplier<T> supplier)
supplier
- That returns the convertable valueT get()
org.jooq.lambda.function.Function0
default T orElseGet(java.util.function.Supplier<? extends T> value)
Optional.orElseGet(Supplier)
Returns a value generated by the provided Supplier if this Convertable is empty or
contains a null value.value
- Supplier to generate value if this convertable is emptydefault java.util.Optional<T> toOptional()
default java.util.stream.Stream<T> toStream()
default T orElse(T value)
value
- default <X extends java.lang.Throwable> T orElseThrow(java.util.function.Supplier<? extends X> ex) throws X extends java.lang.Throwable
ex
- Supplier that returns an exception if this value is emptyX
- Exception type returned by provided SupplierX extends java.lang.Throwable
default java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
default Future<T> toFutureWAsync()
default Future<T> toFutureWAsync(java.util.concurrent.Executor ex)
ex
- Executor to execute the conversion ondefault java.util.concurrent.CompletableFuture<T> toCompletableFuture()
default java.util.concurrent.CompletableFuture<T> toCompletableFutureAsync()
default java.util.concurrent.CompletableFuture<T> toCompletableFutureAsync(java.util.concurrent.Executor exec)
exec
- Executor to asyncrhonously populate the CompletableFuture