T - public interface Convertable<T>
extends java.lang.Iterable<T>, java.util.function.Supplier<T>
| Modifier and Type | Interface and Description |
|---|---|
static class |
Convertable.SupplierToConvertable<T> |
| Modifier and Type | Method and Description |
|---|---|
static <T> Convertable<T> |
fromSupplier(java.util.function.Supplier<T> supplier)
Construct a Convertable from a Supplier
|
T |
get() |
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) |
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 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 java.util.Optional<T> |
when(java.util.function.Predicate<? super T> predicate) |
default <R> java.util.Optional<R> |
when(java.util.function.Predicate<? super T> predicate,
java.util.function.Function<? super T,? extends R> mapper)
Apply the predicate to this convertable value, followed by the supplied mapper.
|
default <R,R1 extends R> |
whenOrElse(R1 defaultValue,
java.util.function.Predicate<? super T> predicate,
java.util.function.Function<? super T,R1> mapper)
Apply the predicate to this convertable value, followed by the supplied mapper.
|
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 java.util.Optional<T> when(java.util.function.Predicate<? super T> predicate)
predicate - - to filter optional value withdefault <R> java.util.Optional<R> when(java.util.function.Predicate<? super T> predicate, java.util.function.Function<? super T,? extends R> mapper)
predicate - - to filter optional value withmapper - to convert value with if the predicate holdsdefault <R,R1 extends R> R1 whenOrElse(R1 defaultValue,
java.util.function.Predicate<? super T> predicate,
java.util.function.Function<? super T,R1> mapper)
defaultValue - - return value if null or predicate failspredicate - to filter optional value withmapper - to convert value with if the predicate holdsdefault 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 - XX extends java.lang.Throwabledefault java.util.List<T> toList()
default java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>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)
exec - Executor to asyncrhonously populate the CompletableFuture