T
- Type of this convertablepublic interface Convertable<T> extends java.lang.Iterable<T>, java.util.function.Supplier<T>, Visitable<T>
Modifier and Type | Interface and Description |
---|---|
static class |
Convertable.SupplierToConvertable<T> |
Modifier and Type | Method and Description |
---|---|
default <R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
An equivalent operation to
Stream.collect(Collector) |
default <R> R |
collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super T> accumulator,
java.util.function.BiConsumer<R,R> combiner)
An equivalent operation to
Stream.collect(Supplier, BiConsumer, BiConsumer) |
static <T> Convertable<T> |
fromSupplier(java.util.function.Supplier<T> supplier)
Construct a Convertable from a Supplier
|
T |
get() |
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.atomic.AtomicReference<T> |
toAtomicReference() |
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 FutureW<T> |
toFutureW() |
default FutureW<T> |
toFutureWAsync() |
default FutureW<T> |
toFutureWAsync(java.util.concurrent.Executor ex)
This convertable converted to a FutureW asyncrhonously using the supplied Executor
|
default java.util.List<T> |
toList() |
default java.util.Optional<T> |
toOptional() |
default java.util.Optional<java.util.concurrent.atomic.AtomicReference<T>> |
toOptionalAtomicReference() |
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)
Stream.collect(Collector)
collector
- Collector to create new Collectiondefault <R> R collect(java.util.function.Supplier<R> supplier, java.util.function.BiConsumer<R,? super T> accumulator, java.util.function.BiConsumer<R,R> combiner)
Stream.collect(Supplier, BiConsumer, BiConsumer)
supplier
- Supplier that creates the datastructure to collect results inaccumulator
- Accumulation functioncombiner
- Combinerdefault <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()
get
in interface java.util.function.Supplier<T>
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 java.util.concurrent.atomic.AtomicReference<T> toAtomicReference()
default java.util.Optional<java.util.concurrent.atomic.AtomicReference<T>> toOptionalAtomicReference()
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.List<T> toList()
default java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
default FutureW<T> toFutureWAsync()
default FutureW<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