Class Tries
java.lang.Object
dmx.fun.Tries
Collector facade for
Stream<Try<V>>.
Centralises all Try collector factories as static methods, mirroring the role of
Collectors. The underlying factories on Try are kept for
backward compatibility; this class simply delegates to them.
Usage:
import static dmx.fun.Tries.*;
Try<List<String>> result = stream.collect(Tries.toList());
Tries.Partition<String> p = stream.collect(Tries.partitioning());
p.successes(); // List<String>
p.failures(); // List<Throwable>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordTransparent alias forTry.Partitionso callers can useTries.Partitionwithout importingTrydirectly. -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> Collector<Try<V>, ?, Tries.Partition<V>> Returns aCollectorthat partitions aStream<Try<V>>into successes and failures.toList()Returns aCollectorthat accumulates aStream<Try<V>>into a singleTry<List<V>>, failing on the firstFailureencountered.
-
Method Details
-
toList
Returns aCollectorthat accumulates aStream<Try<V>>into a singleTry<List<V>>, failing on the firstFailureencountered.Delegates to
Try.toList().- Type Parameters:
V- the success value type- Returns:
- a collector producing
Try<List<V>>
-
partitioning
Returns aCollectorthat partitions aStream<Try<V>>into successes and failures.Delegates to
Try.partitioningBy().- Type Parameters:
V- the success value type- Returns:
- a collector producing a
Tries.Partition
-