Uses of Class
com.google.mu.util.BiOptional
Package
Description
StringFormat, Substring, Optionals and more...
BiStream, BiCollector, MoreStreams, MoreCollectors etc.
-
Uses of BiOptional in com.google.mu.util
Modifier and TypeMethodDescriptionstatic <A,
B> BiOptional <A, B> Ifa
andb
are present, returns aBiOptional
instance containing them; otherwise returns an emptyBiOptional
.static <A,
B> BiOptional <A, B> BiOptional.empty()
Returns an emptyBiOptional
instance.abstract BiOptional
<A, B> BiOptional.filter
(BiPredicate<? super A, ? super B> predicate) If a pair of values is present and matchespredicate
, return thisBiOptional instance
.default BiOptional
<A, B> Both.filter
(BiPredicate<? super A, ? super B> condition) static <T,
A, B> BiOptional <A, B> BiOptional.flatMap
(Optional<T> optional, Function<? super T, ? extends BiOptional<? extends A, ? extends B>> mapper) Maps the value contained inoptional
to aBiOptional
usingmapper
, or else returns empty.static <T> BiOptional
<T, T> Ifoptional
is present with valuev
, adapts it toBiOptional
containing values(v, v)
.static <A,
B> BiOptional <A, B> Optionals.inOrder
(Optional<? extends A> step1, Function<? super A, ? extends Optional<? extends B>> step2) Similar toOptionals.both(java.util.Optional<? extends A>, java.util.Optional<? extends B>)
, but only evaluatesstep2
ifstep1
is present.static <A,
B> BiOptional <A, B> Similar toOptionals.both(java.util.Optional<? extends A>, java.util.Optional<? extends B>)
, but only evaluatesstep2
ifstep1
is present.abstract <A2,
B2> BiOptional <A2, B2> BiOptional.map
(BiFunction<? super A, ? super B, ? extends A2> aMapper, BiFunction<? super A, ? super B, ? extends B2> bMapper) If a pair of values is present, applyaMapper
andbMapper
to them, and if both results are non-null, return a newBiOptional
instance containing the results.abstract <A2,
B2> BiOptional <A2, B2> If a pair of values is present, applyaMapper
andbMapper
to each respectively, and if both results are non-null, return a newBiOptional
instance containing the results.static <A,
B> BiOptional <A, B> BiOptional.of
(A a, B b) Returns aBiOptional
containing the pair(a, b)
.abstract BiOptional
<A, B> BiOptional.or
(Supplier<? extends BiOptional<? extends A, ? extends B>> alternative) If a pair of values are present, return thisBiOptional
instance.abstract BiOptional
<A, B> BiOptional.peek
(BiConsumer<? super A, ? super B> consumer) Invokesconsumer
with the pair if present and returns this object as is.BiOptional
<A, B> BiOptional.skipIf
(BiPredicate<? super A, ? super B> predicate) If a pair of values is present and matchespredicate
, the pair is skipped (returns empty).default BiOptional
<A, B> Both.skipIf
(BiPredicate<? super A, ? super B> predicate) If the pair matchespredicate
, it's skipped (returns empty).final BiOptional
<String, String> Substring.Pattern.split
(CharSequence string) Splitsstring
into two parts that are separated by this separator pattern.final BiOptional
<String, String> Substring.Pattern.splitThenTrim
(CharSequence string) Splitsstring
into two parts that are separated by this separator pattern, with leading and trailing whitespaces trimmed.Modifier and TypeMethodDescriptionOptionals.ifPresent
(BiOptional<A, B> optional, CheckedBiConsumer<? super A, ? super B, E> consumer) Runsaction
if the pair is present.Modifier and TypeMethodDescriptionstatic <T,
A, B> BiOptional <A, B> BiOptional.flatMap
(Optional<T> optional, Function<? super T, ? extends BiOptional<? extends A, ? extends B>> mapper) Maps the value contained inoptional
to aBiOptional
usingmapper
, or else returns empty.abstract BiOptional
<A, B> BiOptional.or
(Supplier<? extends BiOptional<? extends A, ? extends B>> alternative) If a pair of values are present, return thisBiOptional
instance. -
Uses of BiOptional in com.google.mu.util.stream
Modifier and TypeMethodDescriptionfinal BiOptional
<K, V> BiStream.findAny()
Returns any pair from this stream, orBiOptional.empty()
if the stream is empty.final BiOptional
<K, V> BiStream.findFirst()
Returns the first pair from this stream, orBiOptional.empty()
if the stream is empty.Modifier and TypeMethodDescriptionstatic <K,
V> BiCollector <K, V, BiOptional<K, V>> BiCollectors.maxBy
(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) Returns aBiCollector
that finds the maximum pair according tokeyComparator
and thenvalueComparator
for equal keys.static <K,
V> BiCollector <K, V, BiOptional<K, V>> BiCollectors.maxByKey
(Comparator<? super K> comparator) Returns aBiCollector
that finds the pair with the maximum key according tocomparator
.static <K,
V> BiCollector <K, V, BiOptional<K, V>> BiCollectors.maxByValue
(Comparator<? super V> comparator) Returns aBiCollector
that finds the pair with the maximum value according tocomparator
.static <K,
V> BiCollector <K, V, BiOptional<K, V>> BiCollectors.minBy
(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) Returns aBiCollector
that finds the minimum pair according tokeyComparator
and thenvalueComparator
for equal keys.static <K,
V> BiCollector <K, V, BiOptional<K, V>> BiCollectors.minByKey
(Comparator<? super K> comparator) Returns aBiCollector
that finds the pair with the minimum key according tocomparator
.static <K,
V> BiCollector <K, V, BiOptional<K, V>> BiCollectors.minByValue
(Comparator<? super V> comparator) Returns aBiCollector
that finds the pair with the minimum value according tocomparator
.static <T> Collector
<T, ?, BiOptional<T, T>> MoreCollectors.minMax
(Comparator<? super T> comparator) Returns a collector that collects the minimum and maximum elements from the input elements.Modifier and TypeMethodDescriptionfinal <K2,
V2> BiStream <K2, V2> BiStream.mapIfPresent
(BiFunction<? super K, ? super V, ? extends BiOptional<? extends K2, ? extends V2>> mapper) Returns aBiStream
consisting of the results of applyingmapper
function to the pairs in thisBiStream
.