T - The type of the wrapped value.@Deprecated
public interface Value<T>
extends java.lang.Iterable<T>
Value
type reflects the values in a functional setting. It can be seen as the result of a partial function application.
Hence the result may be undefined. If a value is undefined, we say it is empty.
How the empty state is interpreted depends on the context, i.e. it may be undefined, failed, no elements, etc.
Basic operations:
get()getOrElse(Object)getOrElse(Supplier)getOrElseThrow(Supplier)getOrElseTry(CheckedFunction0)getOrNull()map(Function)stringPrefix()collect(Collector)collect(Supplier, BiConsumer, BiConsumer)toArray()toCharSeq()toEither(Object)toEither(Supplier)toInvalid(Object)toInvalid(Supplier)toJavaArray()toJavaArray(Class)toJavaCollection(Function)toJavaList()toJavaList(Function)toJavaMap(Function)toJavaMap(Supplier, Function)toJavaMap(Supplier, Function, Function) toJavaOptional()toJavaParallelStream()toJavaSet()toJavaSet(Function)toJavaStream()toLeft(Object)toLeft(Supplier)toLinkedMap(Function)toLinkedMap(Function, Function)toLinkedSet()toList()toMap(Function)toMap(Function, Function)toOption()toPriorityQueue()toPriorityQueue(Comparator)toQueue()toRight(Object)toRight(Supplier)toSet()toSortedMap(Comparator, Function)toSortedMap(Comparator, Function, Function)toSortedMap(Function)toSortedMap(Function, Function)toSortedSet()toSortedSet(Comparator)toStream()toString()toTree()toTry()toTry(Supplier)toValid(Object)toValid(Supplier)toValidation(Object)toValidation(Supplier)toVector()| Modifier and Type | Method and Description |
|---|---|
default <R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
Deprecated.
Collects the underlying value(s) (if present) using the provided
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)
Deprecated.
Collects the underlying value(s) (if present) using the given
supplier, accumulator and
combiner. |
default boolean |
contains(T element)
Deprecated.
Shortcut for
exists(e -> Objects.equals(e, element)), tests if the given element is contained. |
default <U> boolean |
corresponds(java.lang.Iterable<U> that,
java.util.function.BiPredicate<? super T,? super U> predicate)
Deprecated.
Tests whether every element of this iterable relates to the corresponding element of another iterable by
satisfying a test predicate.
|
default boolean |
eq(java.lang.Object o)
Deprecated.
A smoothing replacement for
equals. |
boolean |
equals(java.lang.Object o)
Deprecated.
Clarifies that values have a proper equals() method implemented.
|
default boolean |
exists(java.util.function.Predicate<? super T> predicate)
Deprecated.
Checks, if an element exists such that the predicate holds.
|
default boolean |
forAll(java.util.function.Predicate<? super T> predicate)
Deprecated.
Checks, if the given predicate holds for all elements.
|
default void |
forEach(java.util.function.Consumer<? super T> action)
Deprecated.
Performs an action on each element.
|
T |
get()
Deprecated.
Gets the underlying value or throws if no value is present.
|
default T |
getOrElse(java.util.function.Supplier<? extends T> supplier)
Deprecated.
Returns the underlying value if present, otherwise
other. |
default T |
getOrElse(T other)
Deprecated.
Returns the underlying value if present, otherwise
other. |
default <X extends java.lang.Throwable> |
getOrElseThrow(java.util.function.Supplier<X> supplier)
Deprecated.
Returns the underlying value if present, otherwise throws
supplier.get(). |
default T |
getOrElseTry(CheckedFunction0<? extends T> supplier)
Deprecated.
Returns the underlying value if present, otherwise returns the result of
Try.of(supplier).get(). |
default T |
getOrNull()
Deprecated.
Returns the underlying value if present, otherwise
null. |
int |
hashCode()
Deprecated.
Clarifies that values have a proper hashCode() method implemented.
|
boolean |
isAsync()
Deprecated.
Checks if this
Value is asynchronously (short: async) computed. |
boolean |
isEmpty()
Deprecated.
Checks, this
Value is empty, i.e. |
boolean |
isLazy()
Deprecated.
Checks if this
Value is lazily evaluated. |
boolean |
isSingleValued()
Deprecated.
States whether this is a single-valued type.
|
Iterator<T> |
iterator()
Deprecated.
Returns a rich
io.vavr.collection.Iterator. |
<U> Value<U> |
map(java.util.function.Function<? super T,? extends U> mapper)
Deprecated.
Maps the underlying value to a different component type.
|
static <T> Value<T> |
narrow(Value<? extends T> value)
Deprecated.
Narrows a widened
Value<? extends T> to Value<T>
by performing a type-safe cast. |
default void |
out(java.io.PrintStream out)
Deprecated.
Sends the string representations of this to the
PrintStream. |
default void |
out(java.io.PrintWriter writer)
Deprecated.
Sends the string representations of this to the
PrintWriter. |
Value<T> |
peek(java.util.function.Consumer<? super T> action)
Deprecated.
Performs the given
action on the first element if this is an eager implementation. |
default java.util.Spliterator<T> |
spliterator()
Deprecated.
|
default void |
stderr()
Deprecated.
Sends the string representations of this to the standard error stream System.err.
|
default void |
stdout()
Deprecated.
Sends the string representations of this to the standard output stream System.out.
|
java.lang.String |
stringPrefix()
Deprecated.
Returns the name of this Value type, which is used by toString().
|
default Array<T> |
toArray()
Deprecated.
Converts this to a
Array. |
default CharSeq |
toCharSeq()
Deprecated.
Converts this to a
CharSeq. |
default java.util.concurrent.CompletableFuture<T> |
toCompletableFuture()
Deprecated.
Converts this to a
CompletableFuture |
default <L> Either<L,T> |
toEither(L left)
Deprecated.
Converts this to an
Either. |
default <L> Either<L,T> |
toEither(java.util.function.Supplier<? extends L> leftSupplier)
Deprecated.
Converts this to an
Either. |
default <U> Validation<T,U> |
toInvalid(java.util.function.Supplier<? extends U> valueSupplier)
Deprecated.
Use
toValidation(Supplier) instead. |
default <U> Validation<T,U> |
toInvalid(U value)
Deprecated.
Use
toValidation(Object) instead. |
default java.lang.Object[] |
toJavaArray()
Deprecated.
Converts this to a Java array with component type
Object |
default T[] |
toJavaArray(java.lang.Class<T> componentType)
Deprecated.
Use
toJavaArray(IntFunction) instead |
default T[] |
toJavaArray(java.util.function.IntFunction<T[]> arrayFactory)
Deprecated.
Converts this to a Java array having an accurate component type.
|
default <C extends java.util.Collection<T>> |
toJavaCollection(java.util.function.Function<java.lang.Integer,C> factory)
Deprecated.
Converts this to a specific mutable
Collection of type C. |
default java.util.List<T> |
toJavaList()
Deprecated.
Converts this to a mutable
List. |
default <LIST extends java.util.List<T>> |
toJavaList(java.util.function.Function<java.lang.Integer,LIST> factory)
Deprecated.
Converts this to a specific mutable
List. |
default <K,V> java.util.Map<K,V> |
toJavaMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Deprecated.
Converts this to a mutable
Map. |
default <K,V,MAP extends java.util.Map<K,V>> |
toJavaMap(java.util.function.Supplier<MAP> factory,
java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends V> valueMapper)
Deprecated.
Converts this to a specific mutable
Map. |
default <K,V,MAP extends java.util.Map<K,V>> |
toJavaMap(java.util.function.Supplier<MAP> factory,
java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Deprecated.
Converts this to a specific mutable
Map. |
default java.util.Optional<T> |
toJavaOptional()
Deprecated.
Converts this to an
Optional. |
default java.util.stream.Stream<T> |
toJavaParallelStream()
Deprecated.
Converts this to a parallel
Stream by calling
StreamSupport.stream(this.spliterator(), true). |
default java.util.Set<T> |
toJavaSet()
Deprecated.
Converts this to a mutable
Set. |
default <SET extends java.util.Set<T>> |
toJavaSet(java.util.function.Function<java.lang.Integer,SET> factory)
Deprecated.
Converts this to a specific
Set. |
default java.util.stream.Stream<T> |
toJavaStream()
Deprecated.
Converts this to a sequential
Stream by calling
StreamSupport.stream(this.spliterator(), false). |
default <R> Either<T,R> |
toLeft(R right)
Deprecated.
Use
toEither(Object) instead. |
default <R> Either<T,R> |
toLeft(java.util.function.Supplier<? extends R> right)
Deprecated.
Use
toEither(Supplier) instead. |
default <K,V> Map<K,V> |
toLinkedMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends V> valueMapper)
Deprecated.
Converts this to a
Map. |
default <K,V> Map<K,V> |
toLinkedMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Deprecated.
Converts this to a
Map. |
default Set<T> |
toLinkedSet()
Deprecated.
Converts this to a
Set. |
default List<T> |
toList()
Deprecated.
Converts this to a
List. |
default <K,V> Map<K,V> |
toMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends V> valueMapper)
Deprecated.
Converts this to a
Map. |
default <K,V> Map<K,V> |
toMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Deprecated.
Converts this to a
Map. |
default Option<T> |
toOption()
Deprecated.
Converts this to an
Option. |
default PriorityQueue<T> |
toPriorityQueue()
Deprecated.
Converts this to a
PriorityQueue. |
default PriorityQueue<T> |
toPriorityQueue(java.util.Comparator<? super T> comparator)
Deprecated.
Converts this to a
PriorityQueue. |
default Queue<T> |
toQueue()
Deprecated.
Converts this to a
Queue. |
default <L> Either<L,T> |
toRight(L left)
Deprecated.
Use
toEither(Object) instead. |
default <L> Either<L,T> |
toRight(java.util.function.Supplier<? extends L> left)
Deprecated.
Use
toEither(Supplier) instead. |
default Set<T> |
toSet()
Deprecated.
Converts this to a
Set. |
default <K,V> SortedMap<K,V> |
toSortedMap(java.util.Comparator<? super K> comparator,
java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends V> valueMapper)
Deprecated.
Converts this to a
Map. |
default <K,V> SortedMap<K,V> |
toSortedMap(java.util.Comparator<? super K> comparator,
java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Deprecated.
Converts this to a
Map. |
default <K extends java.lang.Comparable<? super K>,V> |
toSortedMap(java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends V> valueMapper)
Deprecated.
Converts this to a
Map. |
default <K extends java.lang.Comparable<? super K>,V> |
toSortedMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Deprecated.
Converts this to a
Map. |
default SortedSet<T> |
toSortedSet()
Deprecated.
Converts this to a
SortedSet. |
default SortedSet<T> |
toSortedSet(java.util.Comparator<? super T> comparator)
Deprecated.
Converts this to a
SortedSet. |
default Stream<T> |
toStream()
Deprecated.
Converts this to a
Stream. |
java.lang.String |
toString()
Deprecated.
Clarifies that values have a proper toString() method implemented.
|
default Tree<T> |
toTree()
Deprecated.
Converts this to a
Tree. |
default <ID> List<Tree.Node<T>> |
toTree(java.util.function.Function<? super T,? extends ID> idMapper,
java.util.function.Function<? super T,? extends ID> parentMapper)
Deprecated.
|
default Try<T> |
toTry()
Deprecated.
Converts this to a
Try. |
default Try<T> |
toTry(java.util.function.Supplier<? extends java.lang.Throwable> ifEmpty)
Deprecated.
Converts this to a
Try. |
default <E> Validation<E,T> |
toValid(E error)
Deprecated.
Use
toValidation(Object) instead. |
default <E> Validation<E,T> |
toValid(java.util.function.Supplier<? extends E> errorSupplier)
Deprecated.
Use
toValidation(Supplier) instead. |
default <E> Validation<E,T> |
toValidation(E invalid)
Deprecated.
Converts this to an
Validation. |
default <E> Validation<E,T> |
toValidation(java.util.function.Supplier<? extends E> invalidSupplier)
Deprecated.
Converts this to an
Validation. |
default Vector<T> |
toVector()
Deprecated.
Converts this to a
Vector. |
static <T> Value<T> narrow(Value<? extends T> value)
Value<? extends T> to Value<T>
by performing a type-safe cast. This is eligible because immutable/read-only
types are covariant.T - Component type of the Value.value - A Value.value instance as narrowed type Value<T>.default <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
collector.A - the mutable accumulation type of the reduction operationR - the result type of the reduction operationcollector - Collector performing reductiondefault <R> R collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super T> accumulator,
java.util.function.BiConsumer<R,R> combiner)
supplier, accumulator and
combiner.R - type of the resultsupplier - provide unit value for reductionaccumulator - perform reduction with unit valuecombiner - function for combining two values, which must be
compatible with the accumulator.default boolean contains(T element)
exists(e -> Objects.equals(e, element)), tests if the given element is contained.element - An Object of type A, may be null.default <U> boolean corresponds(java.lang.Iterable<U> that,
java.util.function.BiPredicate<? super T,? super U> predicate)
U - Component type of that iterablethat - the other iterablepredicate - the test predicate, which relates elements from both iterablestrue if both iterables have the same length and predicate(x, y)
is true for all corresponding elements x of this iterable and y of that,
otherwise false.default boolean eq(java.lang.Object o)
equals. It is similar to Scala's == but better in the way
that it is not limited to collection types, e.g. Some(1) eq List(1), None eq Failure(x) etc.
In a nutshell: eq checks congruence of structures and equality of contained values.
Example:
// ((1, 2), ((3))) => structure: (()(())) values: 1, 2, 3
final Value<?> i1 = List.of(List.of(1, 2), Arrays.asList(List.of(3)));
final Value<?> i2 = Queue.of(Stream.of(1, 2), List.of(Lazy.of(() -> 3)));
assertThat(i1.eq(i2)).isTrue();
Semantics:
o == this : true
o instanceof Value : iterable elements are eq, non-iterable elements equals, for all (o1, o2) in (this, o)
o instanceof Iterable : this eq Iterator.of((Iterable<?>) o);
otherwise : false
o - An objectdefault boolean exists(java.util.function.Predicate<? super T> predicate)
predicate - A Predicatejava.lang.NullPointerException - if predicate is nulldefault boolean forAll(java.util.function.Predicate<? super T> predicate)
predicate - A Predicatejava.lang.NullPointerException - if predicate is nulldefault void forEach(java.util.function.Consumer<? super T> action)
forEach in interface java.lang.Iterable<T>action - A Consumerjava.lang.NullPointerException - if action is nullT get()
IMPORTANT! This method will throw an undeclared Throwable if isEmpty() == true is true.
Because the 'empty' state indicates that there is no value present that can be returned,
get() has to throw in such a case. Generally, implementing classes should throw a
NoSuchElementException if isEmpty() returns true.
However, there exist use-cases, where implementations may throw other exceptions. See Try.get().
Additional note: Dynamic proxies will wrap an undeclared exception in a UndeclaredThrowableException.
get() throws a Throwabledefault T getOrElse(T other)
other.other - An alternative value.Tdefault T getOrElse(java.util.function.Supplier<? extends T> supplier)
other.supplier - An alternative value supplier.Tjava.lang.NullPointerException - if supplier is nulldefault <X extends java.lang.Throwable> T getOrElseThrow(java.util.function.Supplier<X> supplier) throws X extends java.lang.Throwable
supplier.get().X - a Throwable typesupplier - An exception supplier.T.java.lang.NullPointerException - if supplier is nullX - if no value is presentX extends java.lang.Throwabledefault T getOrElseTry(CheckedFunction0<? extends T> supplier)
Try.of(supplier).get().supplier - An alternative value supplier.T.java.lang.NullPointerException - if supplier is nulldefault T getOrNull()
null.T or null.boolean isAsync()
Value is asynchronously (short: async) computed.
Methods of a Value instance that operate on the underlying value may block the current thread
until the value is present and the computation can be performed.
Value is async (like Future), false otherwise.boolean isEmpty()
Value is empty, i.e. if the underlying value is absent.boolean isLazy()
Value is lazily evaluated.boolean isSingleValued()
true if this is single-valued, false otherwise.<U> Value<U> map(java.util.function.Function<? super T,? extends U> mapper)
U - The new component typemapper - A mapperValue<T> peek(java.util.function.Consumer<? super T> action)
action 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.action - The action that will be performed on the element(s).java.lang.String stringPrefix()
default void out(java.io.PrintStream out)
PrintStream.
If this value consists of multiple elements, each element is displayed in a new line.out - The PrintStream to write tojava.lang.IllegalStateException - if PrintStream.checkError() is true after writing to stream.default void out(java.io.PrintWriter writer)
PrintWriter.
If this value consists of multiple elements, each element is displayed in a new line.writer - The PrintWriter to write tojava.lang.IllegalStateException - if PrintWriter.checkError() is true after writing to writer.default void stderr()
java.lang.IllegalStateException - if PrintStream.checkError() is true after writing to stderr.default void stdout()
java.lang.IllegalStateException - if PrintStream.checkError() is true after writing to stdout.Iterator<T> iterator()
io.vavr.collection.Iterator.iterator in interface java.lang.Iterable<T>default CharSeq toCharSeq()
CharSeq.CharSeq.default java.util.concurrent.CompletableFuture<T> toCompletableFuture()
CompletableFutureCompletableFuture containing the value@Deprecated default <U> Validation<T,U> toInvalid(U value)
toValidation(Object) instead.Validation.U - value type of a Validvalue - An instance of a Valid valueValidation.Valid containing the given value if this is empty, otherwise
a new Validation.Invalid containing this value.@Deprecated default <U> Validation<T,U> toInvalid(java.util.function.Supplier<? extends U> valueSupplier)
toValidation(Supplier) instead.Validation.U - value type of a ValidvalueSupplier - A supplier of a Valid valueValidation.Valid containing the result of valueSupplier if this is empty,
otherwise a new Validation.Invalid containing this value.java.lang.NullPointerException - if valueSupplier is nulldefault java.lang.Object[] toJavaArray()
Object
// = [] of type Object[]
Future.<String> of(() -> { throw new Error(); })
.toJavaArray()
// = [ok] of type Object[]
Try.of(() -> "ok")
.toJavaArray()
// = [1, 2, 3] of type Object[]
List.of(1, 2, 3)
.toJavaArray()
@Deprecated default T[] toJavaArray(java.lang.Class<T> componentType)
toJavaArray(IntFunction) instead
// = [] of type String[]
Future.<String> of(() -> { throw new Error(); })
.toJavaArray(String.class)
// = [ok] of type String[]
Try.of(() -> "ok")
.toJavaArray(String.class)
// = [1, 2, 3] of type Integer[]
List.of(1, 2, 3)
.toJavaArray(Integer.class)
componentType - Component type of the arrayjava.lang.NullPointerException - if componentType is nulldefault T[] toJavaArray(java.util.function.IntFunction<T[]> arrayFactory)
// = [] of type String[]
Future.<String> of(() -> { throw new Error(); })
.toJavaArray(String[]::new)
// = [ok] of type String[]
Try.of(() -> "ok")
.toJavaArray(String[]::new)
// = [1, 2, 3] of type Integer[]
List.of(1, 2, 3)
.toJavaArray(Integer[]::new)
arrayFactory - an int argument function that
creates an array of the correct component
type with the specified sizeValue.java.lang.NullPointerException - if componentType is nulldefault <C extends java.util.Collection<T>> C toJavaCollection(java.util.function.Function<java.lang.Integer,C> factory)
Collection of type C.
Elements are added by calling Collection.add(Object).
// = []
Future.<String> of(() -> { throw new Error(); })
.toJavaCollection(java.util.HashSet::new)
// = [ok]
Try.of(() -> "ok")
.toJavaCollection(java.util.HashSet::new)
// = [1, 2, 3]
List.of(1, 2, 3)
.toJavaCollection(java.util.LinkedHashSet::new)
C - a sub-type of java.util.Collectionfactory - A factory that returns an empty mutable java.util.Collection with the specified initial capacityjava.util.Collection of type Cdefault java.util.List<T> toJavaList()
List.
Elements are added by calling List.add(Object).
// = []
Future.<String> of(() -> { throw new Error(); })
.toJavaList()
// = [ok]
Try.of(() -> "ok")
.toJavaList()
// = [1, 2, 3]
List.of(1, 2, 3)
.toJavaList()
ArrayList.default <LIST extends java.util.List<T>> LIST toJavaList(java.util.function.Function<java.lang.Integer,LIST> factory)
List.
Elements are added by calling List.add(Object).
// = []
Future.<String> of(() -> { throw new Error(); })
.toJavaList(java.util.ArrayList::new)
// = [ok]
Try.of(() -> "ok")
.toJavaList(java.util.ArrayList::new)
// = [1, 2, 3]
List.of(1, 2, 3)
.toJavaList(java.util.ArrayList::new)
// = [1, 2, 3]
List.of(1, 2, 3)
.toJavaList(capacity -> new java.util.LinkedList<>())
LIST - A sub-type of java.util.Listfactory - A factory that returns an empty mutable java.util.List with the specified initial capacityjava.util.List of type LISTdefault <K,V> java.util.Map<K,V> toJavaMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Map.
Elements are added by calling Map.put(Object, Object).
// = {}
Future.<String> of(() -> { throw new Error(); })
.toJavaMap(s -> Tuple.of(s, s.length()))
// = {ok=2}
Try.of(() -> "ok")
.toJavaMap(s -> Tuple.of(s, s.length()))
// = {1=A, 2=B, 3=C}
List.of(1, 2, 3)
.toJavaMap(i -> Tuple.of(i, (char) (i + 64)))
K - The key typeV - The value typef - A function that maps an element to a key/value pair represented by Tuple2HashMap.default <K,V,MAP extends java.util.Map<K,V>> MAP toJavaMap(java.util.function.Supplier<MAP> factory,
java.util.function.Function<? super T,? extends K> keyMapper,
java.util.function.Function<? super T,? extends V> valueMapper)
Map.
Elements are added by calling Map.put(Object, Object).
// = {}
Future.<String> of(() -> { throw new Error(); })
.toJavaMap(java.util.HashMap::new, s -> s, String::length)
// = {ok=2}
Try.of(() -> "ok")
.toJavaMap(java.util.TreeMap::new, s -> s, String::length)
// = {1=A, 2=B, 3=C}
List.of(1, 2, 3)
.toJavaMap(java.util.TreeMap::new, i -> i, i -> (char) (i + 64))
K - The key typeV - The value typeMAP - a sub-type of java.util.Mapfactory - A factory that creates an empty mutable java.util.MapkeyMapper - A function that maps an element to a keyvalueMapper - A function that maps an element to a valuejava.util.Map of type MAPdefault <K,V,MAP extends java.util.Map<K,V>> MAP toJavaMap(java.util.function.Supplier<MAP> factory,
java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Map.
Elements are added by calling Map.put(Object, Object).
// = {}
Future.<String> of(() -> { throw new Error(); })
.toJavaMap(java.util.HashMap::new, s -> Tuple.of(s, s.length()))
// = {ok=2}
Try.of(() -> "ok")
.toJavaMap(java.util.TreeMap::new, s -> Tuple.of(s, s.length()))
// = {1=A, 2=B, 3=C}
List.of(1, 2, 3)
.toJavaMap(java.util.TreeMap::new, i -> Tuple.of(i, (char) (i + 64)))
K - The key typeV - The value typeMAP - a sub-type of java.util.Mapfactory - A factory that creates an empty mutable java.util.Mapf - A function that maps an element to a key/value pair represented by Tuple2java.util.Map of type MAPdefault java.util.Optional<T> toJavaOptional()
Optional.
// = Optional.empty
Future.of(() -> { throw new Error(); })
.toJavaOptional()
// = Optional[ok]
Try.of(() -> "ok")
.toJavaOptional()
// = Optional[1]
List.of(1, 2, 3)
.toJavaOptional()
Optional.default java.util.Set<T> toJavaSet()
Set.
Elements are added by calling Set.add(Object).
// = []
Future.of(() -> { throw new Error(); })
.toJavaSet()
// = [ok]
Try.of(() -> "ok")
.toJavaSet()
// = [1, 2, 3]
List.of(1, 2, 3)
.toJavaSet()
HashSet.default <SET extends java.util.Set<T>> SET toJavaSet(java.util.function.Function<java.lang.Integer,SET> factory)
Set.
Elements are added by calling Set.add(Object).
// = []
Future.of(() -> { throw new Error(); })
.toJavaSet(java.util.HashSet::new)
// = [ok]
Try.of(() -> "ok")
.toJavaSet(java.util.HashSet::new)
// = [3, 2, 1]
List.of(1, 2, 3)
.toJavaSet(capacity -> new java.util.TreeSet<>(Comparator.reverseOrder()))
SET - a sub-type of java.util.Setfactory - A factory that returns an empty mutable java.util.Set with the specified initial capacityjava.util.Set of type SETdefault java.util.stream.Stream<T> toJavaStream()
Stream by calling
StreamSupport.stream(this.spliterator(), false).
// empty Stream
Future.of(() -> { throw new Error(); })
.toJavaStream()
// Stream containing "ok"
Try.of(() -> "ok")
.toJavaStream()
// Stream containing 1, 2, 3
List.of(1, 2, 3)
.toJavaStream()
Stream.spliterator()default java.util.stream.Stream<T> toJavaParallelStream()
Stream by calling
StreamSupport.stream(this.spliterator(), true).
// empty Stream
Future.of(() -> { throw new Error(); })
.toJavaParallelStream()
// Stream containing "ok"
Try.of(() -> "ok")
.toJavaParallelStream()
// Stream containing 1, 2, 3
List.of(1, 2, 3)
.toJavaParallelStream()
Stream.spliterator()@Deprecated default <R> Either<T,R> toLeft(R right)
toEither(Object) instead.Either.R - right typeright - An instance of a right valueEither.Right containing the value of right if this is empty, otherwise
a new Either.Left containing this value.@Deprecated default <R> Either<T,R> toLeft(java.util.function.Supplier<? extends R> right)
toEither(Supplier) instead.Either.R - right typeright - A supplier of a right valueEither.Right containing the result of right if this is empty, otherwise
a new Either.Left containing this value.java.lang.NullPointerException - if right is nulldefault <K,V> Map<K,V> toMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends V> valueMapper)
Map.K - The key typeV - The value typekeyMapper - A function that maps an element to a keyvalueMapper - A function that maps an element to a valueHashMap.default <K,V> Map<K,V> toMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Map.K - The key typeV - The value typef - A function that maps an element to a key/value pair represented by Tuple2HashMap.default <K,V> Map<K,V> toLinkedMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends V> valueMapper)
Map.K - The key typeV - The value typekeyMapper - A function that maps an element to a keyvalueMapper - A function that maps an element to a valueLinkedHashMap.default <K,V> Map<K,V> toLinkedMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Map.K - The key typeV - The value typef - A function that maps an element to a key/value pair represented by Tuple2LinkedHashMap.default <K extends java.lang.Comparable<? super K>,V> SortedMap<K,V> toSortedMap(java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends V> valueMapper)
Map.K - The key typeV - The value typekeyMapper - A function that maps an element to a keyvalueMapper - A function that maps an element to a valueTreeMap.default <K extends java.lang.Comparable<? super K>,V> SortedMap<K,V> toSortedMap(java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Map.K - The key typeV - The value typef - A function that maps an element to a key/value pair represented by Tuple2TreeMap.default <K,V> SortedMap<K,V> toSortedMap(java.util.Comparator<? super K> comparator, java.util.function.Function<? super T,? extends K> keyMapper, java.util.function.Function<? super T,? extends V> valueMapper)
Map.K - The key typeV - The value typecomparator - A comparator that induces an order of the Map keys.keyMapper - A function that maps an element to a keyvalueMapper - A function that maps an element to a valueTreeMap.default <K,V> SortedMap<K,V> toSortedMap(java.util.Comparator<? super K> comparator, java.util.function.Function<? super T,? extends Tuple2<? extends K,? extends V>> f)
Map.K - The key typeV - The value typecomparator - A comparator that induces an order of the Map keys.f - A function that maps an element to a key/value pair represented by Tuple2TreeMap.default Option<T> toOption()
Option.Option.default <L> Either<L,T> toEither(java.util.function.Supplier<? extends L> leftSupplier)
Either.default <E> Validation<E,T> toValidation(E invalid)
Validation.E - Validation error component typeinvalid - An invalid value for the ValidationValidation.default <E> Validation<E,T> toValidation(java.util.function.Supplier<? extends E> invalidSupplier)
Validation.E - Validation error component typeinvalidSupplier - A Supplier for the invalid value for the ValidationValidation.default PriorityQueue<T> toPriorityQueue()
PriorityQueue.PriorityQueue.default PriorityQueue<T> toPriorityQueue(java.util.Comparator<? super T> comparator)
PriorityQueue.comparator - A comparator that induces an order of the PriorityQueue elements.PriorityQueue.@Deprecated default <L> Either<L,T> toRight(L left)
toEither(Object) instead.Either.L - left typeleft - An instance of a left valueEither.Left containing the value of left if this is empty, otherwise
a new Either.Right containing this value.@Deprecated default <L> Either<L,T> toRight(java.util.function.Supplier<? extends L> left)
toEither(Supplier) instead.Either.L - left typeleft - A supplier of a left valueEither.Left containing the result of left if this is empty, otherwise
a new Either.Right containing this value.java.lang.NullPointerException - if left is nulldefault Set<T> toLinkedSet()
Set.LinkedHashSet.default SortedSet<T> toSortedSet() throws java.lang.ClassCastException
SortedSet.
Current items must be comparableTreeSet.java.lang.ClassCastException - if items are not comparabledefault SortedSet<T> toSortedSet(java.util.Comparator<? super T> comparator)
SortedSet.comparator - A comparator that induces an order of the SortedSet elements.TreeSet.default Try<T> toTry()
Try.
If this value is undefined, i.e. empty, then a new Failure(NoSuchElementException) is returned,
otherwise a new Success(value) is returned.
Try.default Try<T> toTry(java.util.function.Supplier<? extends java.lang.Throwable> ifEmpty)
Try.
If this value is undefined, i.e. empty, then a new Failure(ifEmpty.get()) is returned,
otherwise a new Success(value) is returned.
ifEmpty - an exception supplierTry.default <ID> List<Tree.Node<T>> toTree(java.util.function.Function<? super T,? extends ID> idMapper, java.util.function.Function<? super T,? extends ID> parentMapper)
ID - Id typeidMapper - A mapper from source item to unique identifier of that itemparentMapper - A mapper from source item to unique identifier of parent item. Need return null for root itemsTree.Tree.build(Iterable, Function, Function)@Deprecated default <E> Validation<E,T> toValid(E error)
toValidation(Object) instead.Validation.E - error type of an Invaliderror - An errorValidation.Invalid containing the given error if this is empty, otherwise
a new Validation.Valid containing this value.@Deprecated default <E> Validation<E,T> toValid(java.util.function.Supplier<? extends E> errorSupplier)
toValidation(Supplier) instead.Validation.E - error type of an InvaliderrorSupplier - A supplier of an errorValidation.Invalid containing the result of errorSupplier if this is empty,
otherwise a new Validation.Valid containing this value.java.lang.NullPointerException - if valueSupplier is nulldefault java.util.Spliterator<T> spliterator()
spliterator in interface java.lang.Iterable<T>boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - An objectint hashCode()
See Object.hashCode().
hashCode in class java.lang.Objectjava.lang.String toString()
See Object.toString().
toString in class java.lang.Object