public final class Fun extends Object
Map.Entry type is treated as a 2-n tuple, or pair, for mapping Map.entrySet() streams
to bifunctions, bipredicates, and biconsumers.
Some methods here serve a very simple purpose of supporting immediate type inference of method references,
like infer1(Function), which allows infer1(String::valueOf).andThen().
To support method overloads in lambda and method ref type inference is in play, many method names have a numeric
suffix of 0, 1, or 2. (Sometimes the 1 is omitted even when "0" and "2" overloads are defined). This suffix indicates
the highest *arity of function arguments, and often represents the arity of a returned function type as well.
A Supplier argument represents an *arity of 0, because it takes 0 arguments in order to return a value. A Function
has an *arity of 1, because it accepts one argument to return one value. A BiFunction accepts two arguments, and
therefore has an *arity of 2. Consumers and Predicates also have an *arity of 1, and BiConsumers and BiPredicates also
have an *arity of 2.
Another area of treatment is transformation of checked signatures to unchecked signatures via the following functional
interfaces:
Fun.ThrowingFunctionFun.ThrowingBiFunctionFun.ThrowingConsumerFun.ThrowingBiConsumerFun.ThrowingPredicateFun.ThrowingBiPredicateFun.ThrowingSupplieruncheck* methods will catch any checked exception thrown by the above types and rethrow as a
Fun.FunRuntimeException.
The result* methods will catch any exception (checked or not) and transform the return type signature to wrap
with Result.
For Fun.ThrowingConsumer and Fun.ThrowingBiConsumer, there is no return type to wrap, so
resultNothing1(ThrowingConsumer) and resultNothing2(ThrowingBiConsumer) will transform the consumers
to equivalent functions that return a Result wrapping the Nothing sentinel type.| Modifier and Type | Class and Description |
|---|---|
static class |
Fun.FunRuntimeException
Wrapping runtime error type for unchecked throwing functions.
|
static interface |
Fun.ThrowingBiConsumer<K,V>
Inferrable type for
BiConsumers that throw. |
static interface |
Fun.ThrowingBiFunction<K,V,R>
Inferrable type for
BiFunctions that throw. |
static interface |
Fun.ThrowingBiPredicate<K,V>
Inferrable type for
BiPredicates that throw. |
static interface |
Fun.ThrowingConsumer<T>
Inferrable type for
Consumers that throw. |
static interface |
Fun.ThrowingFunction<T,R>
Inferrable type for
Functions that throw. |
static interface |
Fun.ThrowingPredicate<T>
Inferrable type for
Predicates that throw |
static interface |
Fun.ThrowingSupplier<R>
Inferrable type for
Suppliers that throw. |
| Modifier and Type | Method and Description |
|---|---|
static <R,S> Supplier<S> |
compose0(@NotNull Supplier<? extends R> before,
@NotNull Function<? super R,? extends S> after)
Compose a Supplier with a Function that maps the original supplied type to a new supplied type.
|
static <T,I,R> Function<T,R> |
compose1(@NotNull Function<T,? extends I> before,
@NotNull Function<? super I,? extends R> after)
Essentially the same as calling
Function.andThen(Function), except needing no cast for a method reference
as the before argument, resulting in function composition of before followed by after. |
static <K,V,I,R> BiFunction<K,V,R> |
compose2(@NotNull BiFunction<K,V,? extends I> before,
@NotNull Function<? super I,? extends R> after)
Essentially the same as calling
BiFunction.andThen(Function), except needing no cast for a method reference
as the before argument, resulting in function composition of before followed by after. |
static <T,P> Predicate<T> |
composeTest1(@NotNull Function<? super T,? extends P> inputFunction,
@NotNull Predicate<? super P> testResult)
Compose a Predicate with a preceding input Function that maps the stream element type to the input type of the
Predicate.
|
static <K,V,P> BiPredicate<K,V> |
composeTest2(@NotNull BiFunction<? super K,? super V,? extends P> inputFunction,
@NotNull Predicate<? super P> testResult)
Compose a BiPredicate with a single preceding BiFunction that maps the stream Entry element key and value types to
the input type of the provided Predicate.
|
static <K,V,P,Q> BiPredicate<K,V> |
composeTest2(@NotNull Function<? super K,? extends P> inputTFunction,
@NotNull Function<? super V,? extends Q> inputUFunction,
@NotNull BiPredicate<? super P,? super Q> testResult)
Compose a BiPredicate with preceding left and right input Functions that map the stream Entry element key and value
types to the respective input type of the provided BiPredicate.
|
static <M,R> Supplier<M> |
composeTry0(@NotNull Function<? super R,? extends M> monoidSuccess,
@NotNull Function<? super Exception,? extends M> monoidError,
@NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet)
|
static <M,R> Supplier<M> |
composeTry0(@NotNull Function<? super R,? extends M> monadUnit,
@NotNull Supplier<? extends M> monadZero,
@NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet,
@Nullable Consumer<? super Exception> onError)
|
static <M,T,R> Function<T,M> |
composeTry1(@NotNull Function<? super R,? extends M> monoidSuccess,
@NotNull Function<? super Exception,? extends M> monoidError,
@NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply)
|
static <M,T,R> Function<T,M> |
composeTry1(@NotNull Function<? super R,? extends M> monadUnit,
@NotNull Supplier<? extends M> monadZero,
@NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply,
@Nullable BiConsumer<? super T,? super Exception> onError)
|
static <M,K,V,R> BiFunction<K,V,M> |
composeTry2(@NotNull Function<? super R,? extends M> monoidSuccess,
@NotNull Function<? super Exception,? extends M> monoidError,
@NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply)
|
static <M,K,V,R> BiFunction<K,V,M> |
composeTry2(@NotNull Function<? super R,? extends M> monadUnit,
@NotNull Supplier<? extends M> monadZero,
@NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply,
@Nullable BiConsumer<? super Map.Entry<? super K,? super V>,? super Exception> onError)
|
static <T,R> @NotNull Function<T,R> |
constantly1(@NotNull Supplier<? extends R> supplier)
Fits a supplier into a pipeline as a constant
Function. |
static <K,V,R> @NotNull BiFunction<K,V,R> |
constantly2(@NotNull Supplier<? extends R> supplier)
Fits a supplier into a pipeline as a constant
BiFunction. |
static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> |
entriesToMap()
Shorthand for
Collectors.toMap(Function, Function) for collecting streams of Map.Entry, except
using keepLastMerger() as the merge function, and LinkedHashMap as the supplied map type. |
static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> |
entriesToMap(@NotNull BinaryOperator<V> mergeFunction)
Shorthand for
Collectors.toMap(Function, Function, BinaryOperator, Supplier) for collecting streams of
Map.Entry, except using LinkedHashMap as the supplied map type. |
static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> |
entriesToMapOfType(@NotNull Supplier<Map<K,V>> mapSupplier)
Shorthand for
Collectors.toMap(Function, Function, BinaryOperator, Supplier) for collecting streams of
Map.Entry, except using keepLastMerger() as the merge function. |
static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> |
entriesToMapOfType(@NotNull Supplier<Map<K,V>> mapSupplier,
@NotNull BinaryOperator<V> mergeFunction)
Shorthand for
Collectors.toMap(Function, Function, BinaryOperator, Supplier) for collecting streams of
Map.Entry. |
static <K,V> Function<Map.Entry<K,V>,Map.Entry<K,V>> |
entryTee(@NotNull BiConsumer<? super K,? super V> consumer)
Like
tee(Consumer), this method transforms a BiConsumer into a "tee" (like the Unix command,
evoking the shape of the letter, 'T') function for Map.Entry streams, that passes the input entry to output
after calling BiConsumer.accept(Object, Object) with the input entry key and value. |
static <T> Supplier<T> |
infer0(@NotNull Supplier<? extends T> methodRef)
Infers a method ref to a Supplier.
|
static <T,R> Function<T,R> |
infer1(@NotNull Function<? super T,? extends R> methodRef)
Infers a static method ref to a Function.
|
static <K,V,R> BiFunction<K,V,R> |
infer2(@NotNull BiFunction<? super K,? super V,? extends R> methodRef)
Infers a static method ref to a BiFunction.
|
static <T> Predicate<T> |
inferTest1(@NotNull Predicate<? super T> methodRef)
Infers a method ref to a Predicate.
|
static <K,V> BiPredicate<K,V> |
inferTest2(@NotNull BiPredicate<? super K,? super V> methodRef)
Infers a method ref to a BiPredicate.
|
static <T,S extends Collection<? super T>> |
inSet(S haystack)
This method is used to support type inference around the
Collection.contains(Object) method, whose argument
is not otherwise typed with the element type parameter of the collection. |
static <K,M extends Map<? super K,?>> |
isKeyIn(M haystack)
This method is used to support type inference around the
Map.containsKey(Object) method, whose argument
is not otherwise typed with the key type parameter of the Map. |
static <V,M extends Map<?,? super V>> |
isValueIn(M haystack)
This method is used to support type inference around the
Map.containsValue(Object) method, whose argument
is not otherwise typed with the value type parameter of the Map. |
static <V> BinaryOperator<V> |
keepFirstMerger()
A merge function for
entriesToMap(BinaryOperator) and entriesToMapOfType(Supplier, BinaryOperator)
that keeps the first element defined for a key when merging duplicates. |
static <V> BinaryOperator<V> |
keepLastMerger()
A merge function for
entriesToMap(BinaryOperator) and entriesToMapOfType(Supplier, BinaryOperator)
that keeps the last element defined for a key when merging duplicates. |
static <K,V,R> Function<Map.Entry<K,V>,R> |
mapEntry(@NotNull BiFunction<? super K,? super V,? extends R> biMapFunction)
Transform a
BiFunction to a Function over Map.Entry stream elements of the same key and
value type parameters. |
static <K,V,L> Function<Map.Entry<K,V>,Map.Entry<L,V>> |
mapKey(@NotNull BiFunction<? super K,? super V,? extends L> keyBiFunction)
Transform a
BiFunction to a Function over Map.Entry stream elements of the same key and
value type parameters, that returns new Map.Entry elements that retain the input value but take the output
of the BiFunction as the new key. |
static <K,V,L> Function<Map.Entry<K,V>,Map.Entry<L,V>> |
mapKey(@NotNull Function<? super K,? extends L> keyFunction)
|
static <K,V,W> Function<Map.Entry<K,V>,Map.Entry<K,W>> |
mapValue(@NotNull BiFunction<? super K,? super V,? extends W> valueBiFunction)
Transform a
BiFunction to a Function over Map.Entry stream elements of the same key and
value type parameters, that returns new Map.Entry elements that retain the input key but take the output
of the BiFunction as the new value. |
static <K,V,W> Function<Map.Entry<K,V>,Map.Entry<K,W>> |
mapValue(@NotNull Function<? super V,? extends W> valueFunction)
|
static <K,V> Consumer<Map.Entry<K,V>> |
onEntry(@NotNull BiConsumer<? super K,? super V> biConsumer)
Transform a
BiConsumer to a Consumer of Map.Entry stream elements with matching respective
key and value type parameters. |
static <K,V> Consumer<Map.Entry<K,V>> |
onKey(@NotNull Consumer<? super K> consumer)
|
static <K,V> Consumer<Map.Entry<K,V>> |
onValue(@NotNull Consumer<? super V> consumer)
|
static <R> Supplier<Result<R>> |
result0(@NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet)
Transform a
Fun.ThrowingSupplier to a Supplier of Result whose success type parameter is the
same as the type parameter of the Fun.ThrowingSupplier. |
static <T,R> Function<T,Result<R>> |
result1(@NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply)
Transform a
Fun.ThrowingFunction to a Function over the same input type parameter, which returns a
Result whose success type parameter is the same as the output type of the Fun.ThrowingFunction. |
static <K,V,R> BiFunction<K,V,Result<R>> |
result2(@NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply)
Transform a
Fun.ThrowingBiFunction to a BiFunction over the same input type parameters, which returns
a Result whose success type parameter is the same as the output type of the Fun.ThrowingBiFunction. |
static <T> Function<T,Result<Nothing>> |
resultNothing1(@NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Transform a
Fun.ThrowingConsumer to a Function over the same input type parameter, but which returns
a Result of success type Nothing. |
static <K,V> BiFunction<K,V,Result<Nothing>> |
resultNothing2(@NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Transform a
Fun.ThrowingBiConsumer to a BiFunction over the same input type parameters, but which returns
a Result of success type Nothing. |
static <T> Stream<T> |
streamIt(T element)
What's the most efficient way to stream a single nullable element? I don't know, but maybe I randomly got it
right under the hood.
|
static <T> Stream<T> |
streamOpt(@NotNull Optional<T> element)
Use this to transform a less useful Optional into an equivalent single-element stream.
|
static <T> @NotNull Function<T,T> |
tee(@NotNull Consumer<? super T> consumer)
Transform a consumer into a "tee" (like the Unix command, evoking the shape of the letter, 'T') function that
passes the input argument to output after calling
Consumer.accept(Object) with the input. |
static <K,V> Predicate<? super Map.Entry<K,V>> |
testEntry(@NotNull BiPredicate<? super K,? super V> biPredicate)
Transform a
BiPredicate to a Predicate testing Map.Entry stream elements with matching
respective key and value type parameters. |
static <K,V> Predicate<? super Map.Entry<K,V>> |
testKey(@NotNull Predicate<? super K> keyPredicate)
|
static <T> Predicate<T> |
testOrDefault1(@NotNull Fun.ThrowingPredicate<? super T> mayThrowOnTest,
boolean defaultValue)
Transform a
Fun.ThrowingPredicate to a Predicate, providing a default boolean value to return if an
exception is thrown. |
static <K,V> BiPredicate<K,V> |
testOrDefault2(@NotNull Fun.ThrowingBiPredicate<? super K,? super V> mayThrowOnTest,
boolean defaultValue)
Transform a
Fun.ThrowingBiPredicate to a BiPredicate, providing a default boolean value to return if
an exception is thrown. |
static <K,V> Predicate<? super Map.Entry<K,V>> |
testValue(@NotNull Predicate<? super V> valuePredicate)
|
static <V> BinaryOperator<V> |
throwingMerger()
A merge function for
entriesToMap(BinaryOperator) and entriesToMapOfType(Supplier, BinaryOperator)
that throws an IllegalStateException when merging duplicates to guarantee distinct pairs. |
static <T> Fun.ThrowingFunction<T,Nothing> |
throwingVoidToNothing1(@NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Parallel method to
Nothing.voidToNothing1(Consumer), for transforming a Fun.ThrowingConsumer to a
Fun.ThrowingFunction that returns Nothing. |
static <K,V> Fun.ThrowingBiFunction<K,V,Nothing> |
throwingVoidToNothing2(@NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Parallel method to
Nothing.voidToNothing2(BiConsumer), for transforming a Fun.ThrowingBiConsumer to a
Fun.ThrowingBiFunction that returns Nothing. |
static <K,V> Map.Entry<K,V> |
toEntry(K key,
V value)
An alias for creating a
AbstractMap.SimpleImmutableEntry for the provided key and value. |
static <T> Consumer<T> |
toVoid1(@NotNull Function<? super T,?> inputFunction)
Infers a
Function.apply(Object) signature as a Consumer. |
static <K,V> BiConsumer<K,V> |
toVoid2(@NotNull BiFunction<? super K,? super V,?> inputFunction)
Infers a
BiFunction.apply(Object, Object) signature as a BiConsumer. |
static <R> Supplier<R> |
tryOrDefault0(@NotNull Fun.ThrowingSupplier<R> mayThrowOnGet,
R defaultValue)
Transform a
Fun.ThrowingSupplier to a Supplier, providing a default value to return if
an exception is thrown. |
static <T,R> Function<T,R> |
tryOrDefault1(@NotNull Fun.ThrowingFunction<? super T,R> mayThrowOnApply,
R defaultValue)
Transform a
Fun.ThrowingFunction to a Function, providing a default value to return if
an exception is thrown. |
static <K,V,R> BiFunction<K,V,R> |
tryOrDefault2(@NotNull Fun.ThrowingBiFunction<? super K,? super V,R> mayThrowOnApply,
R defaultValue)
Transform a
Fun.ThrowingBiFunction to a BiFunction, providing a default value to return if
an exception is thrown. |
static <R> Supplier<Optional<R>> |
tryOrOptional0(@NotNull Fun.ThrowingSupplier<R> mayThrowOnGet)
|
static <T,R> Function<T,Optional<R>> |
tryOrOptional1(@NotNull Fun.ThrowingFunction<? super T,R> mayThrowOnApply)
Transform a
Fun.ThrowingFunction to a Function of the same input type, with the output type wrapped in
an Optional. |
static <K,V,R> BiFunction<K,V,Optional<R>> |
tryOrOptional2(@NotNull Fun.ThrowingBiFunction<? super K,? super V,R> mayThrowOnApply)
Transform a
Fun.ThrowingBiFunction to a BiFunction of the same input types, with the output type
wrapped in an Optional. |
static <T> Consumer<T> |
tryOrVoid1(@NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Transform a
Fun.ThrowingConsumer to a Consumer of the same input type, that simply suppresses any
exceptions if thrown. |
static <K,V> BiConsumer<K,V> |
tryOrVoid2(@NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Transform a
Fun.ThrowingBiConsumer to a BiConsumer of the same input types, that simply suppresses any
exceptions if thrown. |
static <R> Supplier<R> |
uncheck0(@NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet)
Transform a
Fun.ThrowingSupplier to an unchecked Supplier of the same supplied type parameter. |
static <T,R> Function<T,R> |
uncheck1(@NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply)
Transform a
Fun.ThrowingFunction to an unchecked Function of the same input and output type parameters. |
static <K,V,R> BiFunction<K,V,R> |
uncheck2(@NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply)
Transform a
Fun.ThrowingBiFunction to an unchecked BiFunction of the same input and output type
parameters. |
static <T> Predicate<T> |
uncheckTest1(@NotNull Fun.ThrowingPredicate<? super T> mayThrowOnTest)
Transform a
Fun.ThrowingPredicate to a Predicate of the same input type parameter. |
static <K,V> BiPredicate<K,V> |
uncheckTest2(@NotNull Fun.ThrowingBiPredicate<? super K,? super V> mayThrowOnTest)
Transform a
Fun.ThrowingBiPredicate to a BiPredicate of the same input type parameter. |
static <T> Consumer<T> |
uncheckVoid1(@NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Transform a
Fun.ThrowingConsumer to a Consumer of the same input type parameter. |
static <K,V> BiConsumer<K,V> |
uncheckVoid2(@NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Transform a
Fun.ThrowingBiConsumer to a BiConsumer of the same input type parameter. |
static <K,V> Function<K,Map.Entry<K,V>> |
zipKeysWithValueFunc(@NotNull Function<? super K,? extends V> valueFunc)
Zips stream elements into
Map.Entry elements as keys, with values mapped from the provided function, which
can, for example, be a Map.get(Object) method reference to perform a lookup. |
static <K,V> Function<V,Map.Entry<K,V>> |
zipValuesWithKeyFunc(@NotNull Function<? super V,? extends K> keyFunction)
Zips stream elements into
Map.Entry elements as values, with keys mapped from the provided function, which
can, for example, be a Map.get(Object) method reference to perform a lookup. |
public static <T> Stream<T> streamIt(@Nullable T element)
T - the type of the element within the streamelement - the single element to streampublic static <T> Stream<T> streamOpt(@NotNull @NotNull Optional<T> element)
T - the type of the element within the streamelement - the single element to stream, wrapped in an Optional@NotNull public static <T> @NotNull Function<T,T> tee(@NotNull @NotNull Consumer<? super T> consumer)
Consumer.accept(Object) with the input.T - the input typeconsumer - the consumer@NotNull public static <T,R> @NotNull Function<T,R> constantly1(@NotNull @NotNull Supplier<? extends R> supplier)
Function.T - the (ignored) input typeR - the supplied output typesupplier - the supplier@NotNull public static <K,V,R> @NotNull BiFunction<K,V,R> constantly2(@NotNull @NotNull Supplier<? extends R> supplier)
BiFunction.K - the (ignored) input entry key typeV - the (ignored) input entry value typeR - the supplied output typesupplier - the supplierpublic static <T,I,R> Function<T,R> compose1(@NotNull @NotNull Function<T,? extends I> before, @NotNull @NotNull Function<? super I,? extends R> after)
Function.andThen(Function), except needing no cast for a method reference
as the before argument, resulting in function composition of before followed by after.T - the input typeI - the intermediate typeR - the output typebefore - the before functionafter - the after functionpublic static <R,S> Supplier<S> compose0(@NotNull @NotNull Supplier<? extends R> before, @NotNull @NotNull Function<? super R,? extends S> after)
R - the original supplied typeS - the new supplied typebefore - the supplierafter - the after functionpublic static <K,V,I,R> BiFunction<K,V,R> compose2(@NotNull @NotNull BiFunction<K,V,? extends I> before, @NotNull @NotNull Function<? super I,? extends R> after)
BiFunction.andThen(Function), except needing no cast for a method reference
as the before argument, resulting in function composition of before followed by after.K - the input stream entry key typeV - the input stream entry value typeI - the intermediate typeR - the output typebefore - the before functionafter - the after functionpublic static <T,P> Predicate<T> composeTest1(@NotNull @NotNull Function<? super T,? extends P> inputFunction, @NotNull @NotNull Predicate<? super P> testResult)
T - the pipeline element typeP - the original predicate input typeinputFunction - the preceding input functiontestResult - the predicatepublic static <K,V,P,Q> BiPredicate<K,V> composeTest2(@NotNull @NotNull Function<? super K,? extends P> inputTFunction, @NotNull @NotNull Function<? super V,? extends Q> inputUFunction, @NotNull @NotNull BiPredicate<? super P,? super Q> testResult)
K - the stream entry key typeV - the stream entry value typeP - the original predicate left input typeQ - the original predicate right input typeinputTFunction - the preceding left input functioninputUFunction - the preceding right input functiontestResult - the predicatepublic static <K,V,P> BiPredicate<K,V> composeTest2(@NotNull @NotNull BiFunction<? super K,? super V,? extends P> inputFunction, @NotNull @NotNull Predicate<? super P> testResult)
K - the stream entry key typeV - the stream entry value typeP - the original predicate input typeinputFunction - the preceding input BiFunctiontestResult - the predicatepublic static <T> Consumer<T> toVoid1(@NotNull @NotNull Function<? super T,?> inputFunction)
Function.apply(Object) signature as a Consumer.T - the consumed input typeinputFunction - the Function to use as a Consumerpublic static <K,V> BiConsumer<K,V> toVoid2(@NotNull @NotNull BiFunction<? super K,? super V,?> inputFunction)
BiFunction.apply(Object, Object) signature as a BiConsumer.K - the consumed stream entry key typeV - the consumed stream entry value typeinputFunction - the BiFunction to use as a BiConsumerpublic static <T,R> Function<T,R> infer1(@NotNull @NotNull Function<? super T,? extends R> methodRef)
T - the input typeR - the output typemethodRef - the method refpublic static <K,V,R> BiFunction<K,V,R> infer2(@NotNull @NotNull BiFunction<? super K,? super V,? extends R> methodRef)
K - the input key typeV - the input value typeR - the return typemethodRef - the method refpublic static <T> Supplier<T> infer0(@NotNull @NotNull Supplier<? extends T> methodRef)
T - the supplied typemethodRef - the method refpublic static <T> Predicate<T> inferTest1(@NotNull @NotNull Predicate<? super T> methodRef)
T - the input typemethodRef - the method refpublic static <K,V> BiPredicate<K,V> inferTest2(@NotNull @NotNull BiPredicate<? super K,? super V> methodRef)
K - the input key typeV - the input value typemethodRef - the method refpublic static <T> Fun.ThrowingFunction<T,Nothing> throwingVoidToNothing1(@NotNull @NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Nothing.voidToNothing1(Consumer), for transforming a Fun.ThrowingConsumer to a
Fun.ThrowingFunction that returns Nothing.T - the consumed typemayThrowOnAccept - the throwing consumerFun.ThrowingFunction that returns Nothingpublic static <K,V> Fun.ThrowingBiFunction<K,V,Nothing> throwingVoidToNothing2(@NotNull @NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Nothing.voidToNothing2(BiConsumer), for transforming a Fun.ThrowingBiConsumer to a
Fun.ThrowingBiFunction that returns Nothing.K - the consumed key typeV - the consumed value typemayThrowOnAccept - the throwing BiConsumerFun.ThrowingBiFunction that returns Nothingpublic static <K,V> Function<Map.Entry<K,V>,Map.Entry<K,V>> entryTee(@NotNull @NotNull BiConsumer<? super K,? super V> consumer)
tee(Consumer), this method transforms a BiConsumer into a "tee" (like the Unix command,
evoking the shape of the letter, 'T') function for Map.Entry streams, that passes the input entry to output
after calling BiConsumer.accept(Object, Object) with the input entry key and value.K - the input entry key typeV - the input entry value typeconsumer - the BiConsumer functionpublic static <K,V> Function<K,Map.Entry<K,V>> zipKeysWithValueFunc(@NotNull @NotNull Function<? super K,? extends V> valueFunc)
Map.Entry elements as keys, with values mapped from the provided function, which
can, for example, be a Map.get(Object) method reference to perform a lookup.K - the stream element and entry key typeV - the entry value typevalueFunc - the function to map a stream element as a key to an associated value for the constructed Map.Entrypublic static <K,V> Function<V,Map.Entry<K,V>> zipValuesWithKeyFunc(@NotNull @NotNull Function<? super V,? extends K> keyFunction)
Map.Entry elements as values, with keys mapped from the provided function, which
can, for example, be a Map.get(Object) method reference to perform a lookup.K - the entry key typeV - the stream element and entry value typekeyFunction - the function to map a stream element as a value to an associated key for the constructed Map.Entrypublic static <K,V> Map.Entry<K,V> toEntry(@Nullable K key, @Nullable V value)
AbstractMap.SimpleImmutableEntry for the provided key and value.K - the entry key typeV - the entry value typekey - the entry keyvalue - the entry valueMap.Entrypublic static <V> BinaryOperator<V> keepFirstMerger()
entriesToMap(BinaryOperator) and entriesToMapOfType(Supplier, BinaryOperator)
that keeps the first element defined for a key when merging duplicates.V - the entry value typepublic static <V> BinaryOperator<V> keepLastMerger()
entriesToMap(BinaryOperator) and entriesToMapOfType(Supplier, BinaryOperator)
that keeps the last element defined for a key when merging duplicates.V - the entry value typepublic static <V> BinaryOperator<V> throwingMerger()
entriesToMap(BinaryOperator) and entriesToMapOfType(Supplier, BinaryOperator)
that throws an IllegalStateException when merging duplicates to guarantee distinct pairs.V - the entry value typepublic static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> entriesToMap()
Collectors.toMap(Function, Function) for collecting streams of Map.Entry, except
using keepLastMerger() as the merge function, and LinkedHashMap as the supplied map type. This
preserves stream sequence by default.K - the entry key typeV - the entry value typeCollector for a stream of Map.Entrypublic static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> entriesToMapOfType(@NotNull @NotNull Supplier<Map<K,V>> mapSupplier)
Collectors.toMap(Function, Function, BinaryOperator, Supplier) for collecting streams of
Map.Entry, except using keepLastMerger() as the merge function.K - the entry key typeV - the entry value typemapSupplier - a Map constructor method referenceCollector for a stream of Map.Entrypublic static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> entriesToMap(@NotNull @NotNull BinaryOperator<V> mergeFunction)
Collectors.toMap(Function, Function, BinaryOperator, Supplier) for collecting streams of
Map.Entry, except using LinkedHashMap as the supplied map type.K - the entry key typeV - the entry value typemergeFunction - a function to merge entry values on key duplication.Collector for a stream of Map.EntrykeepFirstMerger(),
keepLastMerger(),
throwingMerger()public static <K,V> Collector<Map.Entry<K,V>,?,Map<K,V>> entriesToMapOfType(@NotNull @NotNull Supplier<Map<K,V>> mapSupplier, @NotNull @NotNull BinaryOperator<V> mergeFunction)
Collectors.toMap(Function, Function, BinaryOperator, Supplier) for collecting streams of
Map.Entry.K - the entry key typeV - the entry value typemapSupplier - a Map constructor method referencemergeFunction - a function to merge entry values on key duplication.Collector for a stream of Map.EntrykeepFirstMerger(),
keepLastMerger(),
throwingMerger()public static <K,V,R> Function<Map.Entry<K,V>,R> mapEntry(@NotNull @NotNull BiFunction<? super K,? super V,? extends R> biMapFunction)
BiFunction to a Function over Map.Entry stream elements of the same key and
value type parameters.K - the entry key typeV - the entry value typeR - the output typebiMapFunction - the mapping BiFunctionMap.Entry elementspublic static <K,V,W> Function<Map.Entry<K,V>,Map.Entry<K,W>> mapValue(@NotNull @NotNull BiFunction<? super K,? super V,? extends W> valueBiFunction)
BiFunction to a Function over Map.Entry stream elements of the same key and
value type parameters, that returns new Map.Entry elements that retain the input key but take the output
of the BiFunction as the new value.K - the input and output entry key typeV - the input entry value typeW - the output entry value typevalueBiFunction - the mapping BiFunctionMap.Entry elementspublic static <K,V,W> Function<Map.Entry<K,V>,Map.Entry<K,W>> mapValue(@NotNull @NotNull Function<? super V,? extends W> valueFunction)
Function over value types to a Function over Map.Entry stream elements whose
value type matches the input type of the Function, that returns new Map.Entry elements that retain
the input key but take the output of the Function as the new value.K - the input and output entry key typeV - the input entry value typeW - the output entry value typevalueFunction - the mapping FunctionMap.Entry elementspublic static <K,V,L> Function<Map.Entry<K,V>,Map.Entry<L,V>> mapKey(@NotNull @NotNull BiFunction<? super K,? super V,? extends L> keyBiFunction)
BiFunction to a Function over Map.Entry stream elements of the same key and
value type parameters, that returns new Map.Entry elements that retain the input value but take the output
of the BiFunction as the new key.K - the input entry key typeV - the input and output entry value typeL - the output entry key typekeyBiFunction - the mapping FunctionMap.Entry elementspublic static <K,V,L> Function<Map.Entry<K,V>,Map.Entry<L,V>> mapKey(@NotNull @NotNull Function<? super K,? extends L> keyFunction)
Function over key types to a Function over Map.Entry stream elements whose
key type matches the input type of the Function, that returns new Map.Entry elements that retain
the input value but take the output of the Function as the new key.K - the input entry key typeV - the input and output entry value typeL - the output entry key typekeyFunction - the mapping FunctionMap.Entry elementspublic static <K,V> Consumer<Map.Entry<K,V>> onEntry(@NotNull @NotNull BiConsumer<? super K,? super V> biConsumer)
BiConsumer to a Consumer of Map.Entry stream elements with matching respective
key and value type parameters.K - the stream entry key typeV - the stream entry value typebiConsumer - the BiConsumerConsumer of Map.Entrypublic static <K,V> Consumer<Map.Entry<K,V>> onKey(@NotNull @NotNull Consumer<? super K> consumer)
Consumer of key types to a Consumer of Map.Entry stream elements with a matching
key type parameter.K - the input type and stream entry key typeV - the stream entry value typeconsumer - the key consumerConsumer of Map.Entry stream elementspublic static <K,V> Consumer<Map.Entry<K,V>> onValue(@NotNull @NotNull Consumer<? super V> consumer)
Consumer of value types to a Consumer of Map.Entry stream elements with a matching
value type parameter.K - the stream entry key typeV - the input type and stream entry value typeconsumer - the key consumerConsumer of Map.Entry stream elementspublic static <K,V> Predicate<? super Map.Entry<K,V>> testEntry(@NotNull @NotNull BiPredicate<? super K,? super V> biPredicate)
BiPredicate to a Predicate testing Map.Entry stream elements with matching
respective key and value type parameters.K - the input key typeV - the input value typebiPredicate - the BiPredicatePredicate filtering Map.Entry stream elementspublic static <K,V> Predicate<? super Map.Entry<K,V>> testValue(@NotNull @NotNull Predicate<? super V> valuePredicate)
Predicate of value types to a Predicate testing Map.Entry stream elements with
a matching value type parameter.K - the stream entry key typeV - the input type and stream entry value typevaluePredicate - the PredicatePredicate filtering Map.Entry stream elementspublic static <K,V> Predicate<? super Map.Entry<K,V>> testKey(@NotNull @NotNull Predicate<? super K> keyPredicate)
Predicate of key types to a Predicate testing Map.Entry stream elements with
a matching key type parameter.K - the input value and stream entry key typeV - the stream entry value typekeyPredicate - the PredicatePredicate filtering Map.Entry stream elementspublic static <T,S extends Collection<? super T>> Predicate<T> inSet(@NotNull S haystack)
Collection.contains(Object) method, whose argument
is not otherwise typed with the element type parameter of the collection. This returns the method reference for the
provided collection's contains method as a Predicate, but with restrictive type parameters so that it does
not break inference by introducing Object as the input type bound.T - the stream element typeS - the collection type wildcardhaystack - the collection possibly containing stream elementshaystack::contains as a properly bounded predicatepublic static <K,M extends Map<? super K,?>> Predicate<K> isKeyIn(@NotNull M haystack)
Map.containsKey(Object) method, whose argument
is not otherwise typed with the key type parameter of the Map. This returns the method reference for the
provided map's containsKey method as a Predicate, but with restrictive type parameters so that it does
not break inference by introducing Object as the input type bound.K - the stream element typeM - the map type wildcardhaystack - the map possibly containing stream elements as keyshaystack::containsKey as a properly bounded predicatepublic static <V,M extends Map<?,? super V>> Predicate<V> isValueIn(@NotNull M haystack)
Map.containsValue(Object) method, whose argument
is not otherwise typed with the value type parameter of the Map. This returns the method reference for the
provided map's containsValue method as a Predicate, but with restrictive type parameters so that it does
not break inference by introducing Object as the input type bound.V - the stream element typeM - the map type wildcardhaystack - the map possibly containing stream elements as valueshaystack::containsValue as a properly bounded predicatepublic static <M,T,R> Function<T,M> composeTry1(@NotNull @NotNull Function<? super R,? extends M> monadUnit, @NotNull @NotNull Supplier<? extends M> monadZero, @NotNull @NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply, @Nullable @Nullable BiConsumer<? super T,? super Exception> onError)
Stream,
Optional, etc. Useful for eliminating clumsy try/catch blocks from lambdas.M - The captured monad type, which must match the return types of the monadUnit and
monadZero functions, but which is not involved in the onElement or
onError functions.T - The input type mapped by the monoid/monad, i.e. the String type in Stream<String>.R - The output type mapped by the monoid/monad, i.e. the URL type in Stream<URL>.monadUnit - the "unit" (or "single") function defined by the appropriate monoid/monad. I.E. Stream::of,
Optional::of, or Optional::ofNullable.monadZero - the "zero" (or "empty") function defined by the appropriate monoid/monad, as in Stream::empty,
or Optional::emptymayThrowOnApply - some function that produces type R when applied to an input of type T, or fails
with an Exception.onError - an optional consumer function to perform some logic when the parser function throws.
Receives both the failing input element and the caught Exception.public static <M,T,R> Function<T,M> composeTry1(@NotNull @NotNull Function<? super R,? extends M> monoidSuccess, @NotNull @NotNull Function<? super Exception,? extends M> monoidError, @NotNull @NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply)
Stream,
Optional, etc. Useful for eliminating clumsy try/catch blocks from lambdas.
This variation is geared towards use with Result or some other union type with an Exception constructor.M - The captured monoid type, which must match the return types of the monoidSuccess and
monoidError functions, but which is not involved in the mayThrowOnApply function.T - The input type mapped by the monoid/monad, i.e. the String type in Stream<String>.R - The output type mapped by the monoid/monad, i.e. the URL type in Stream<URL>.monoidSuccess - the "successful" function defined by the appropriate monoid/monad. I.E. Result::success,
Optional::of, or Optional::ofNullable.monoidError - the "failure" function defined by the appropriate monoid/monad, as in Result::failure.mayThrowOnApply - some function that produces type R when given an object of type T, or fails
with an Exception.public static <M,R> Supplier<M> composeTry0(@NotNull @NotNull Function<? super R,? extends M> monadUnit, @NotNull @NotNull Supplier<? extends M> monadZero, @NotNull @NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet, @Nullable @Nullable Consumer<? super Exception> onError)
Stream,
Optional, etc. Useful for eliminating clumsy try/catch blocks from lambdas.M - The captured monad type, which must match the return types of the monadUnit and
monadZero functions, but which is not involved in the onElement or
onError functions.R - The output type mapped by the monoid/monad, i.e. the URL type in Stream<URL>.monadUnit - the "unit" (or "single") function defined by the appropriate monoid/monad. I.E. Stream::of,
Optional::of, or Optional::ofNullable.monadZero - the "zero" (or "empty") function defined by the appropriate monoid/monad, as in Stream::empty,
or Optional::emptymayThrowOnGet - some supplier that produces type R, or fails
with an Exception.onError - an optional consumer function to perform some logic when the parser function throws.
Receives both the failing input element and the caught Exception.public static <M,R> Supplier<M> composeTry0(@NotNull @NotNull Function<? super R,? extends M> monoidSuccess, @NotNull @NotNull Function<? super Exception,? extends M> monoidError, @NotNull @NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet)
Stream,
Optional, etc. Useful for eliminating clumsy try/catch blocks from lambdas.
This variation is geared towards use with Result or some other union type with an Exception constructor.M - The captured monoid type, which must match the return types of the monoidSuccess and
monoidError functions, but which is not involved in the mayThrowOnApply function.R - The output type mapped by the monoid/monad, i.e. the URL type in Stream<URL>.monoidSuccess - the "successful" function defined by the appropriate monoid/monad. I.E. Result::success,
Optional::of, or Optional::ofNullable.monoidError - the "failure" function defined by the appropriate monoid/monad, as in Result::failure.mayThrowOnGet - some function that produces type R when given an object of type T, or fails
with an Exception.public static <M,K,V,R> BiFunction<K,V,M> composeTry2(@NotNull @NotNull Function<? super R,? extends M> monadUnit, @NotNull @NotNull Supplier<? extends M> monadZero, @NotNull @NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply, @Nullable @Nullable BiConsumer<? super Map.Entry<? super K,? super V>,? super Exception> onError)
Stream,
Optional, etc. Useful for eliminating clumsy try/catch blocks from lambdas.M - The captured monad type, which must match the return types of the monadUnit and
monadZero functions, but which is not involved in the onElement or
onError functions.K - The left input type mapped by the function, i.e. the String type in Stream<String>.V - The right input type mapped by the function, i.e. the String type in Stream<String>.R - The output type mapped by the monoid/monad, i.e. the URL type in Stream<URL>.monadUnit - the "unit" (or "single") function defined by the appropriate monoid/monad. I.E. Stream::of,
Optional::of, or Optional::ofNullable.monadZero - the "zero" (or "empty") function defined by the appropriate monoid/monad, as in Stream::empty,
or Optional::emptymayThrowOnApply - some function that produces type R when applied to inputs of type T and U,
or fails with an Exception.onError - an optional consumer function to perform some logic when the parser function throws.
Receives both the failing input element and the caught Exception.public static <M,K,V,R> BiFunction<K,V,M> composeTry2(@NotNull @NotNull Function<? super R,? extends M> monoidSuccess, @NotNull @NotNull Function<? super Exception,? extends M> monoidError, @NotNull @NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply)
Stream,
Optional, etc. Useful for eliminating clumsy try/catch blocks from lambdas.
This variation is geared towards use with Result or some other union type with an Exception constructor.M - The captured monoid type, which must match the return types of the monoidSuccess and
monoidError functions, but which is not involved in the mayThrowOnApply function.K - The left input type mapped by the functionV - The right input type mapped by the functionR - The output type mapped by the monoid/monad, i.e. the URL type in Stream<URL>.monoidSuccess - the "successful" function defined by the appropriate monoid/monad. I.E. Result::success,
Optional::of, or Optional::ofNullable.monoidError - the "failure" function defined by the appropriate monoid/monad, as in Result::failure.mayThrowOnApply - some function that produces type R when given inputs of type T and U,
or fails with an Exception.public static <R> Supplier<R> uncheck0(@NotNull @NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet)
Fun.ThrowingSupplier to an unchecked Supplier of the same supplied type parameter.
Exceptions will be caught and rethrown as Fun.FunRuntimeExceptions.R - the supplied typemayThrowOnGet - the ThrowingSupplierSupplierpublic static <R> Supplier<Result<R>> result0(@NotNull @NotNull Fun.ThrowingSupplier<? extends R> mayThrowOnGet)
Fun.ThrowingSupplier to a Supplier of Result whose success type parameter is the
same as the type parameter of the Fun.ThrowingSupplier.public static <T,R> Function<T,R> uncheck1(@NotNull @NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply)
Fun.ThrowingFunction to an unchecked Function of the same input and output type parameters.
Exceptions will be caught and rethrown as Fun.FunRuntimeExceptions.T - the input typeR - the output typemayThrowOnApply - the ThrowingFunctionFunctionpublic static <T,R> Function<T,Result<R>> result1(@NotNull @NotNull Fun.ThrowingFunction<? super T,? extends R> mayThrowOnApply)
Fun.ThrowingFunction to a Function over the same input type parameter, which returns a
Result whose success type parameter is the same as the output type of the Fun.ThrowingFunction.public static <K,V,R> BiFunction<K,V,R> uncheck2(@NotNull @NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply)
Fun.ThrowingBiFunction to an unchecked BiFunction of the same input and output type
parameters. Exceptions will be caught and rethrown as Fun.FunRuntimeExceptions.K - the input entry key typeV - the input entry value typeR - the output typemayThrowOnApply - the ThrowingBiFunctionBiFunctionpublic static <K,V,R> BiFunction<K,V,Result<R>> result2(@NotNull @NotNull Fun.ThrowingBiFunction<? super K,? super V,? extends R> mayThrowOnApply)
Fun.ThrowingBiFunction to a BiFunction over the same input type parameters, which returns
a Result whose success type parameter is the same as the output type of the Fun.ThrowingBiFunction.K - the input entry key typeV - the input entry value typeR - the original output typemayThrowOnApply - the ThrowingBiFunctionBiFunction over the same inputs returning a Result of type Rpublic static <T> Predicate<T> uncheckTest1(@NotNull @NotNull Fun.ThrowingPredicate<? super T> mayThrowOnTest)
Fun.ThrowingPredicate to a Predicate of the same input type parameter. Exceptions will be
caught and rethrown as Fun.FunRuntimeExceptions.T - the input typemayThrowOnTest - the ThrowingPredicatePredicatepublic static <K,V> BiPredicate<K,V> uncheckTest2(@NotNull @NotNull Fun.ThrowingBiPredicate<? super K,? super V> mayThrowOnTest)
Fun.ThrowingBiPredicate to a BiPredicate of the same input type parameter. Exceptions will
be caught and rethrown as Fun.FunRuntimeExceptions.K - the input entry key typeV - the input entry value typemayThrowOnTest - the ThrowingBiPredicateBiPredicatepublic static <T> Consumer<T> uncheckVoid1(@NotNull @NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Fun.ThrowingConsumer to a Consumer of the same input type parameter. Exceptions will
be caught and rethrown as Fun.FunRuntimeExceptions.T - the input typemayThrowOnAccept - the ThrowingConsumerConsumerpublic static <T> Function<T,Result<Nothing>> resultNothing1(@NotNull @NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Fun.ThrowingConsumer to a Function over the same input type parameter, but which returns
a Result of success type Nothing.public static <K,V> BiConsumer<K,V> uncheckVoid2(@NotNull @NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Fun.ThrowingBiConsumer to a BiConsumer of the same input type parameter. Exceptions will
be caught and rethrown as Fun.FunRuntimeExceptions.K - the input entry key typeV - the input entry value typemayThrowOnAccept - the ThrowingBiConsumerBiConsumerpublic static <K,V> BiFunction<K,V,Result<Nothing>> resultNothing2(@NotNull @NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Fun.ThrowingBiConsumer to a BiFunction over the same input type parameters, but which returns
a Result of success type Nothing.K - the input entry key typeV - the input entry value typemayThrowOnAccept - the ThrowingBiConsumerBiFunction returning a Result of type Nothingpublic static <T> Predicate<T> testOrDefault1(@NotNull @NotNull Fun.ThrowingPredicate<? super T> mayThrowOnTest, boolean defaultValue)
Fun.ThrowingPredicate to a Predicate, providing a default boolean value to return if an
exception is thrown.T - the input typemayThrowOnTest - the ThrowingPredicatedefaultValue - the value to return when an exception is thrownPredicate that returns a default value when an exception is thrownpublic static <K,V> BiPredicate<K,V> testOrDefault2(@NotNull @NotNull Fun.ThrowingBiPredicate<? super K,? super V> mayThrowOnTest, boolean defaultValue)
Fun.ThrowingBiPredicate to a BiPredicate, providing a default boolean value to return if
an exception is thrown.K - the input entry key typeV - the input entry value typemayThrowOnTest - the ThrowingBiPredicatedefaultValue - the value to return when an exception is thrownBiPredicate that returns a default value when an exception is thrownpublic static <R> Supplier<R> tryOrDefault0(@NotNull @NotNull Fun.ThrowingSupplier<R> mayThrowOnGet, @Nullable R defaultValue)
Fun.ThrowingSupplier to a Supplier, providing a default value to return if
an exception is thrown.R - the supplied typemayThrowOnGet - the ThrowingSupplierdefaultValue - the value to return when an exception is thrownSupplier that supplies a default value when an exception is thrownpublic static <T,R> Function<T,R> tryOrDefault1(@NotNull @NotNull Fun.ThrowingFunction<? super T,R> mayThrowOnApply, @Nullable R defaultValue)
Fun.ThrowingFunction to a Function, providing a default value to return if
an exception is thrown.T - the input typeR - the output typemayThrowOnApply - the ThrowingFunctiondefaultValue - the value to return when an exception is thrownFunction that returns a default value when an exception is thrownpublic static <K,V,R> BiFunction<K,V,R> tryOrDefault2(@NotNull @NotNull Fun.ThrowingBiFunction<? super K,? super V,R> mayThrowOnApply, @Nullable R defaultValue)
Fun.ThrowingBiFunction to a BiFunction, providing a default value to return if
an exception is thrown.K - the input entry key typeV - the input entry value typeR - the output typemayThrowOnApply - the ThrowingBiFunctiondefaultValue - the value to return when an exception is thrownBiFunction that returns a default value when an exception is thrownpublic static <R> Supplier<Optional<R>> tryOrOptional0(@NotNull @NotNull Fun.ThrowingSupplier<R> mayThrowOnGet)
Fun.ThrowingSupplier to a Supplier of the same type, wrapped in an Optional.
The Optional value will be empty if an exception is thrown.R - the originally supplied typemayThrowOnGet - the ThrowingSupplierSupplier that supplies an optional value that is empty if an exception is thrownpublic static <T,R> Function<T,Optional<R>> tryOrOptional1(@NotNull @NotNull Fun.ThrowingFunction<? super T,R> mayThrowOnApply)
Fun.ThrowingFunction to a Function of the same input type, with the output type wrapped in
an Optional. The Optional value will be empty if an exception is thrown.T - the input typeR - the original output typemayThrowOnApply - the ThrowingFunctionFunction that returns an optional value that is empty if an exception is thrownpublic static <K,V,R> BiFunction<K,V,Optional<R>> tryOrOptional2(@NotNull @NotNull Fun.ThrowingBiFunction<? super K,? super V,R> mayThrowOnApply)
Fun.ThrowingBiFunction to a BiFunction of the same input types, with the output type
wrapped in an Optional. The Optional value will be empty if an exception is thrown.K - the input entry key typeV - the input entry value typeR - the original output typemayThrowOnApply - the ThrowingBiFunctionBiFunction that returns an optional value that is empty if an exception is thrownpublic static <T> Consumer<T> tryOrVoid1(@NotNull @NotNull Fun.ThrowingConsumer<? super T> mayThrowOnAccept)
Fun.ThrowingConsumer to a Consumer of the same input type, that simply suppresses any
exceptions if thrown.T - the input typemayThrowOnAccept - the ThrowingConsumerConsumer that suppresses any exceptions if thrownpublic static <K,V> BiConsumer<K,V> tryOrVoid2(@NotNull @NotNull Fun.ThrowingBiConsumer<? super K,? super V> mayThrowOnAccept)
Fun.ThrowingBiConsumer to a BiConsumer of the same input types, that simply suppresses any
exceptions if thrown.K - the input entry key typeV - the input entry value typemayThrowOnAccept - the ThrowingBiConsumerConsumer that suppresses any exceptions if thrownCopyright © 2017–2020. All rights reserved.