Uses of Interface
com.google.mu.util.Both
Package
Description
StringFormat, Substring, Optionals and more...
BiStream, BiCollector, MoreStreams, MoreCollectors etc.
-
Uses of Both in com.google.mu.util
Modifier and TypeMethodDescriptionstatic <A,
B> Both <A, B> Both.of
(A a, B b) Returns an instance with botha
andb
.Returns the pair if present, or else returns(a, b)
.BiOptional.orElseThrow()
Ensures that the pair must be present or else throwsNoSuchElementException
.BiOptional.orElseThrow
(String message, Object... args) Ensures that the pair must be present or else throwsNoSuchElementException
withmessage
formatted withargs
.BiOptional.orElseThrow
(Function<String, E> exceptionFactory, String message, Object... args) Ensures that the pair must be present or else throws the exception returned byexceptionFactory
withmessage
formatted withargs
.BiOptional.orElseThrow
(Supplier<E> exceptionSupplier) Ensures that the pair must be present or else throws the exception returned byexceptionSupplier
.Both.peek
(BiConsumer<? super A, ? super B> consumer) Invokesconsumer
with this pair and returns this object as is. -
Uses of Both in com.google.mu.util.stream
Modifier and TypeMethodDescriptionstatic <K,
V> BiCollector <K, V, Both<BiStream<K, V>, BiStream<K, V>>> BiCollectors.partitioningBy
(BiPredicate<? super K, ? super V> predicate) Returns a BiCollector that partitions the incoming pairs into two groups: elements that matchpredicate
, and those that don't.static <K,
V, R> BiCollector <K, V, Both<R, R>> BiCollectors.partitioningBy
(BiPredicate<? super K, ? super V> predicate, BiCollector<? super K, ? super V, ? extends R> downstream) Returns a BiCollector that partitions the incoming pairs into two groups: elements that matchpredicate
, and those that don't, and usedownstream
collector to collect the pairs.static <K,
V, T, F>
BiCollector<K, V, Both<T, F>> BiCollectors.partitioningBy
(BiPredicate<? super K, ? super V> predicate, BiCollector<? super K, ? super V, ? extends T> ifTrue, BiCollector<? super K, ? super V, ? extends F> ifFalse) Returns a BiCollector that partitions the incoming pairs into two groups: elements that matchpredicate
, and those that don't, and useifTrue
andifFalse
downstream collectors respectively to collect the pairs.static <T> Collector
<T, ?, Both<com.google.common.collect.ImmutableList<T>, com.google.common.collect.ImmutableList<T>>> GuavaCollectors.partitioningBy
(Predicate<? super T> predicate) Returns a collector that partitions the incoming elements into two groups: elements that matchpredicate
, and those that don't.MoreCollectors.partitioningBy
(Predicate<? super E> predicate, Collector<E, ?, ? extends R> downstream) Returns a collector that partitions the incoming elements into two groups: elements that matchpredicate
, and those that don't.MoreCollectors.partitioningBy
(Predicate<? super E> predicate, Collector<E, A1, ? extends T> downstreamIfTrue, Collector<E, A2, ? extends F> downstreamIfFalse) Returns a collector that partitions the incoming elements into two groups: elements that matchpredicate
, and those that don't, and usedownstreamIfTrue
anddownstreamIfFalse
respectively to collect the elements.Modifier and TypeMethodDescriptionstatic <K,
V, A, B, R>
BiCollector<K, V, R> BiCollectors.collectingAndThen
(BiCollector<K, V, ? extends Both<? extends A, ? extends B>> collector, BiFunction<? super A, ? super B, ? extends R> finisher) static <T,
A, B, R>
Collector<T, ?, R> MoreCollectors.collectingAndThen
(Collector<T, ?, ? extends Both<? extends A, ? extends B>> upstream, BiFunction<? super A, ? super B, ? extends R> finisher) static <K,
V> BiStream <K, V> Returns aBiStream
of the pairs fromstream
.final <K2,
V2> BiStream <K2, V2> BiStream.map
(BiFunction<? super K, ? super V, ? extends Both<? extends K2, ? extends V2>> mapper) Returns aBiStream
consisting of the result pairs of applyingmapper
to the pairs in thisBiStream
.static <K,
V, K1, V1, R>
BiCollector<K, V, R> BiCollectors.mapping
(BiFunction<? super K, ? super V, ? extends Both<? extends K1, ? extends V1>> mapper, BiCollector<K1, V1, R> downstream) Returns aBiCollector
that first maps the input pair into another pair usingmapper
.static <T,
A, B, R>
Collector<T, ?, R> MoreCollectors.mapping
(Function<? super T, ? extends Both<? extends A, ? extends B>> mapper, BiCollector<A, B, R> downstream) Analogous toCollectors.mapping()
, applies a mapping function to each input element before accumulation, except that themapper
function returns a pair of elements, which are then accumulated by a BiCollector.BiStream.toBiStream
(Function<? super E, ? extends Both<? extends K, ? extends V>> toPair) Returns aCollector
that splits each input element as a pair and collects them into aBiStream
.static <T,
K, V> Collector <T, ?, com.google.common.collect.ImmutableBiMap<K, V>> GuavaCollectors.toImmutableBiMap
(Function<? super T, ? extends Both<? extends K, ? extends V>> mapper) Returns a collector that first maps each input into a key-value pair, and then collects them into aImmutableBiMap
.static <T,
K, V> Collector <T, ?, com.google.common.collect.ImmutableListMultimap<K, V>> GuavaCollectors.toImmutableListMultimap
(Function<? super T, ? extends Both<? extends K, ? extends V>> mapper) Returns a collector that first maps each input into a key-value pair, and then collects them into aImmutableListMultimap
.static <T,
K, V> Collector <T, ?, com.google.common.collect.ImmutableMap<K, V>> GuavaCollectors.toImmutableMap
(Function<? super T, ? extends Both<? extends K, ? extends V>> mapper) Returns a collector that first maps each input into a key-value pair, and then collects them into aImmutableMap
.static <T,
K, V> Collector <T, ?, com.google.common.collect.ImmutableMap<K, V>> GuavaCollectors.toImmutableMapIgnoringDuplicateEntries
(Function<? super T, ? extends Both<? extends K, ? extends V>> mapper) Returns a collector that first maps each input into a key-value pair, and then collects them into aImmutableListMultimap
.static <T,
K, V> Collector <T, ?, com.google.common.collect.ImmutableSetMultimap<K, V>> GuavaCollectors.toImmutableSetMultimap
(Function<? super T, ? extends Both<? extends K, ? extends V>> mapper) Returns a collector that first maps each input into a key-value pair, and then collects them into aImmutableSetMultimap
.