@Deprecated public final class Lazy<T> extends java.lang.Object implements Value<T>, java.util.function.Supplier<T>, java.io.Serializable
final Lazy<Double> l = Lazy.of(Math::random);
l.isEvaluated(); // = false
l.get(); // = 0.123 (random generated)
l.isEvaluated(); // = true
l.get(); // = 0.123 (memoized)
Example of creating a real lazy value (works only with interfaces):
final CharSequence chars = Lazy.val(() -> "Yay!", CharSequence.class);| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
Deprecated.
Clarifies that values have a proper equals() method implemented.
|
Option<T> |
filter(java.util.function.Predicate<? super T> predicate)
Deprecated.
|
Option<T> |
filterNot(java.util.function.Predicate<? super T> predicate)
Deprecated.
|
T |
get()
Deprecated.
Evaluates this lazy value and caches it, when called the first time.
|
int |
hashCode()
Deprecated.
Clarifies that values have a proper hashCode() method implemented.
|
boolean |
isAsync()
Deprecated.
A
Lazy's value is computed synchronously. |
boolean |
isEmpty()
Deprecated.
Checks, this
Value is empty, i.e. |
boolean |
isEvaluated()
Deprecated.
Checks, if this lazy value is evaluated.
|
boolean |
isLazy()
Deprecated.
A
Lazy's value is computed lazily. |
boolean |
isSingleValued()
Deprecated.
States whether this is a single-valued type.
|
Iterator<T> |
iterator()
Deprecated.
Returns a rich
io.vavr.collection.Iterator. |
<U> Lazy<U> |
map(java.util.function.Function<? super T,? extends U> mapper)
Deprecated.
Maps the underlying value to a different component type.
|
static <T> Lazy<T> |
narrow(Lazy<? extends T> lazy)
Deprecated.
Narrows a widened
Lazy<? extends T> to Lazy<T>
by performing a type-safe cast. |
static <T> Lazy<T> |
of(java.util.function.Supplier<? extends T> supplier)
Deprecated.
Creates a
Lazy that requests its value from a given Supplier. |
Lazy<T> |
peek(java.util.function.Consumer<? super T> action)
Deprecated.
Performs the given
action on the first element if this is an eager implementation. |
static <T> Lazy<Seq<T>> |
sequence(java.lang.Iterable<? extends Lazy<? extends T>> values)
Deprecated.
Reduces many
Lazy values into a single Lazy by transforming an
Iterable<Lazy<? extends T>> into a Lazy<Seq<T>>. |
java.lang.String |
stringPrefix()
Deprecated.
Returns the name of this Value type, which is used by toString().
|
java.lang.String |
toString()
Deprecated.
Clarifies that values have a proper toString() method implemented.
|
<U> U |
transform(java.util.function.Function<? super Lazy<T>,? extends U> f)
Deprecated.
Transforms this
Lazy. |
static <T> T |
val(java.util.function.Supplier<? extends T> supplier,
java.lang.Class<T> type)
Deprecated.
Creates a real _lazy value_ of type
T, backed by a Proxy which delegates
to a Lazy instance. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcollect, collect, contains, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, narrow, out, out, spliterator, stderr, stdout, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVectorpublic static <T> Lazy<T> narrow(Lazy<? extends T> lazy)
Lazy<? extends T> to Lazy<T>
by performing a type-safe cast. This is eligible because immutable/read-only
collections are covariant.T - Component type of the Lazy.lazy - A Lazy.lazy instance as narrowed type Lazy<T>.public static <T> Lazy<T> of(java.util.function.Supplier<? extends T> supplier)
Lazy that requests its value from a given Supplier. The supplier is asked only once,
the value is memoized.T - type of the lazy valuesupplier - A supplierpublic static <T> Lazy<Seq<T>> sequence(java.lang.Iterable<? extends Lazy<? extends T>> values)
Lazy values into a single Lazy by transforming an
Iterable<Lazy<? extends T>> into a Lazy<Seq<T>>.T - Type of the lazy values.values - An iterable of lazy values.java.lang.NullPointerException - if values is nullpublic static <T> T val(java.util.function.Supplier<? extends T> supplier,
java.lang.Class<T> type)
T, backed by a Proxy which delegates
to a Lazy instance.T - type of the lazy valuesupplier - A suppliertype - An interfacepublic T get()
public boolean isAsync()
Lazy's value is computed synchronously.public boolean isEmpty()
ValueValue is empty, i.e. if the underlying value is absent.public boolean isEvaluated()
Note: A value is internally evaluated (once) by calling get().
java.lang.UnsupportedOperationException - if this value is undefinedpublic boolean isLazy()
Lazy's value is computed lazily.public boolean isSingleValued()
ValueisSingleValued in interface Value<T>true if this is single-valued, false otherwise.public Iterator<T> iterator()
Valueio.vavr.collection.Iterator.public <U> Lazy<U> map(java.util.function.Function<? super T,? extends U> mapper)
Valuepublic Lazy<T> peek(java.util.function.Consumer<? super T> action)
Valueaction on the first element if this is an eager implementation.
Performs the given action on all elements (the first immediately, successive deferred),
if this is a lazy implementation.public <U> U transform(java.util.function.Function<? super Lazy<T>,? extends U> f)
Lazy.U - Type of transformation resultf - A transformationUjava.lang.NullPointerException - if f is nullpublic java.lang.String stringPrefix()
ValuestringPrefix in interface Value<T>public boolean equals(java.lang.Object o)
Valuepublic int hashCode()
ValueSee Object.hashCode().
public java.lang.String toString()
ValueSee Object.toString().